Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在执行 HTTP GET 请求,但需要能够添加端口,因为它不是 80。这是我的代码:
response = Net::HTTP.get(URI.parse("http://#{@hs_host}/dir/testpage.asp?event=#{CGI::escape(event_name)}"))
当服务器在端口 80 上时,这很完美。如果服务器在端口 85 上怎么办?通常我会在主机之后添加 :85 但这似乎是错误的。
uri = URI.parse(http://#{@hs_host}/dir/testpage.asp?event=#{CGI::escape(event_name)}") uri.port = 8080
甚至:
uri = URI.parse(http://#{@hs_host}:8080/dir/testpage.asp?event=#{CGI::escape(event_name)}")