diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-04-14 10:41:35 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-04-14 10:41:35 +0000 |
commit | fd003e6a8fb13425ad68514412eed1126f84ea80 (patch) | |
tree | 841de7537c87c43badd41b6370f18c714bc344f4 | |
parent | fa590861fec271a4a6c7d888473b59976ab2cbe6 (diff) | |
download | ruby-fd003e6a8fb13425ad68514412eed1126f84ea80.tar.gz ruby-fd003e6a8fb13425ad68514412eed1126f84ea80.tar.xz ruby-fd003e6a8fb13425ad68514412eed1126f84ea80.zip |
o pop.rb: accept illegal timestamp (reported by WATANABE Hirofumi)
o http.rb: when body was chunked, does not set 'Content-Length'
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/net/http.rb | 17 | ||||
-rw-r--r-- | lib/net/pop.rb | 6 | ||||
-rw-r--r-- | lib/net/protocol.rb | 2 |
3 files changed, 11 insertions, 14 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index 4a61e0c74..db6a5747b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -170,6 +170,7 @@ All "key" is case-insensitive. resp end + def post( path, data, u_header = nil, dest = nil, &block ) u_header = procheader( u_header ) dest, ret = HTTP.procdest( dest, block ) @@ -193,6 +194,7 @@ All "key" is case-insensitive. } end + # not tested because I could not setup apache (__;;; def put( path, src, u_header = nil ) u_header = procheader( u_header ) @@ -592,7 +594,7 @@ All "key" is case-insensitive. str = @socket.readline m = /\AHTTP\/(\d+\.\d+)?\s+(\d\d\d)\s*(.*)\z/i.match( str ) unless m then - raise HTTPBadResponse, "wrong status line format: #{str}" + raise HTTPBadResponse, "wrong status line: #{str}" end @http_version = m[1] status = m[2] @@ -605,7 +607,6 @@ All "key" is case-insensitive. end def read_chunked( ret, header ) - line = nil len = nil total = 0 @@ -613,20 +614,16 @@ All "key" is case-insensitive. line = @socket.readline m = /[0-9a-hA-H]+/.match( line ) unless m then - raise HTTPBadResponse, "chunk size not given" + raise HTTPBadResponse, "wrong chunk size line: #{line}" end len = m[0].hex break if len == 0 @socket.read( len, ret ); total += len @socket.read 2 # \r\n end - while true do - line = @socket.readline - break if line.empty? + until @socket.readline.empty? do + ; end - - header.delete 'transfer-encoding' - header[ 'content-length' ] = total.to_s end @@ -644,7 +641,7 @@ All "key" is case-insensitive. def chunked?( header ) str = header[ 'transfer-encoding' ] - if str and /(\A|\s+)chunked(?:\s+|\z)/i === str then + if str and /(?:\A|\s+)chunked(?:\s+|\z)/i === str then true else false diff --git a/lib/net/pop.rb b/lib/net/pop.rb index 65cd498f5..046763e0a 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -329,11 +329,11 @@ Net::POP3 def initialize( sock ) rep = super( sock ) - /<[^@]+@[^@>]+>/o === rep.msg - @stamp = $& - unless @stamp then + m = /<.+>/.match( rep.msg ) + unless m then raise ProtoAuthError, "This is not APOP server: can't login" end + @stamp = m[0] end diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index aa994016f..5fbfb5323 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -15,7 +15,7 @@ require 'socket' module Net - Version = '1.1.12' + Version = '1.1.13' =begin |