0

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.

toro2k
  • 19,020
  • 7
  • 64
  • 71
SeeleyBoothe
  • 261
  • 6
  • 18

1 Answers1

0
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)}")
i-blis
  • 3,149
  • 24
  • 31
  • Ok not sure what I did wrong the first 50 times. But your second example is what I thought I was doing. It now works. Guess I must be slow this morning. Thank you. – SeeleyBoothe May 08 '13 at 14:28