Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Writing entire packet at once to avoid incomplete transmission #72

Closed
wants to merge 1 commit into from

2 participants

Jason Kay Urabe, Shyouhei
Jason Kay

Current code using writeline was causing sub-optimal conversing with a proxy due to the connect tunnel request headers being split over multiple packets. The modification I made allows the connect request to be written as one packet, avoiding problems and optimizing the conversation.

Urabe, Shyouhei

Merged as of r34362. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2011
  1. Jason Kay
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 5 lib/net/http.rb
10 lib/net/http.rb
View
@@ -804,15 +804,15 @@ def connect
if use_ssl?
begin
if proxy?
- @socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
- @address, @port, HTTPVersion)
- @socket.writeline "Host: #{@address}:#{@port}"
+ buf = "CONNECT #{@address}:#{@port} HTTP/#{HTTPVersion}\r\n"
+ buf << "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m')
credential.delete!("\r\n")
- @socket.writeline "Proxy-Authorization: Basic #{credential}"
+ buf << "Proxy-Authorization: Basic #{credential}\r\n"
end
- @socket.writeline ''
+ buf << "\r\n"
+ @socket.write(buf)
HTTPResponse.read_new(@socket).value
end
# Server Name Indication (SNI) RFC 3546
Something went wrong with that request. Please try again.