Skip to content
Browse files

* added test for #195.

  • Loading branch information...
1 parent 62b8a2f commit d20241294fc3826de2efe6527dd2eb2b1084b613 nahi committed Jan 22, 2009
Showing with 17 additions and 0 deletions.
  1. +17 −0 test/test_httpclient.rb
View
17 test/test_httpclient.rb
@@ -165,11 +165,28 @@ def test_proxy
#
@proxyio.string = ""
@client.proxy = @proxyurl
+ @client.debug_dev = str = ""
assert_equal(200, @client.head(@url).status)
assert(/accept/ =~ @proxyio.string)
+ assert(/Host: localhost:17171/ =~ str)
end
end
+ def test_host_header
+ @client.proxy = @proxyurl
+ @client.debug_dev = str = ""
+ @client.test_loopback_http_response << "HTTP/1.0 200 OK\r\n\r\n"
+ assert_equal(200, @client.head('http://www.example.com/foo').status)
+ # ensure no ':80' is added. some servers dislike that.
+ assert(/\r\nHost: www\.example\.com\r\n/ =~ str)
+ #
+ @client.debug_dev = str = ""
+ @client.test_loopback_http_response << "HTTP/1.0 200 OK\r\n\r\n"
+ assert_equal(200, @client.head('http://www.example.com:12345/foo').status)
+ # ensure ':12345' exists.
+ assert(/\r\nHost: www\.example\.com:12345\r\n/ =~ str)
+ end
+
def test_proxy_env
setup_proxyserver
escape_env do

0 comments on commit d202412

Please sign in to comment.
Something went wrong with that request. Please try again.