From 5de2c3c2d3aedc304ca87ff224c9e4a6ec7cb14a Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 23 Jan 2012 12:25:19 +0000 Subject: [PATCH] Writing entire packet at once to avoid incomplete transmission Signed-off-by: URABE, Shyouhei git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 53093492c22f24..b6e5de0a540bfd 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -811,15 +811,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