문제

I am doing an HTTP GET request but need to be able to add the port as it is not 80. Here is my code:

response = Net::HTTP.get(URI.parse("http://#{@hs_host}/dir/testpage.asp?event=#{CGI::escape(event_name)}"))

Which works perfect when the server is on port 80. What if the server is on port 85? Normally I would add :85 after the host but that seems to error.

도움이 되었습니까?

해결책

uri = URI.parse(http://#{@hs_host}/dir/testpage.asp?event=#{CGI::escape(event_name)}")
uri.port = 8080

Or even:

uri = URI.parse(http://#{@hs_host}:8080/dir/testpage.asp?event=#{CGI::escape(event_name)}")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top