summaryrefslogtreecommitdiff
path: root/lib/webrick/httpproxy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/webrick/httpproxy.rb')
-rw-r--r--lib/webrick/httpproxy.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/webrick/httpproxy.rb b/lib/webrick/httpproxy.rb
index c5ed44f1da..14e3499775 100644
--- a/lib/webrick/httpproxy.rb
+++ b/lib/webrick/httpproxy.rb
@@ -15,6 +15,14 @@ require "net/http"
Net::HTTP::version_1_2 if RUBY_VERSION < "1.7"
module WEBrick
+ NullReader = Object.new
+ class << NullReader
+ def read(*args)
+ nil
+ end
+ alias gets read
+ end
+
class HTTPProxyServer < HTTPServer
def initialize(config)
super
@@ -111,6 +119,7 @@ module WEBrick
proxy_port = proxy.port
if proxy.userinfo
credentials = "Basic " + [proxy.userinfo].pack("m*")
+ credentials.chomp!
header['proxy-authorization'] = credentials
end
end
@@ -171,6 +180,7 @@ module WEBrick
proxy_request_line = "CONNECT #{host}:#{port} HTTP/1.0"
if proxy.userinfo
credentials = "Basic " + [proxy.userinfo].pack("m*")
+ credentials.chomp!
end
host, port = proxy.host, proxy.port
end
@@ -211,6 +221,10 @@ module WEBrick
end
res.send_response(ua)
access_log(@config, req, res)
+
+ # Should clear request-line not to send the sesponse twice.
+ # see: HTTPServer#run
+ req.parse(NullReader) rescue nil
end
begin