Skip to content

Commit

Permalink
aamine
Browse files Browse the repository at this point in the history
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30
* lib/net/protocol.rb, smtp.rb: Command#critical_ok -> error_ok
* lib/net/http.rb: read header when also "100 Continue"


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
aamine committed Nov 7, 2000
1 parent faeb170 commit 41e41d3
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 70 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Tue Nov 7 20:29:56 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>

* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30

* lib/net/protocol.rb, smtp.rb: Command#critical_ok -> error_ok

* lib/net/http.rb: read header when also "100 Continue"

Thu Nov 2 18:01:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* random.c (rb_f_rand): half-baked float support fixed. This fix
Expand Down
152 changes: 89 additions & 63 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=begin
= net/http.rb version 1.1.29
= net/http.rb version 1.1.30
maintained by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
This file is derived from "http-access.rb".
Expand Down Expand Up @@ -670,6 +670,12 @@ def inspect
end


###
### request
###

public

def get( path, u_header )
return unless begin_critical
request sprintf('GET %s HTTP/%s', path, HTTPVersion), u_header
Expand Down Expand Up @@ -703,9 +709,39 @@ def quit
end


private

def request( req, u_header )
@socket.writeline req
if u_header then
header = @in_header.dup.update( u_header )
else
header = @in_header
end
header.each do |n,v|
@socket.writeline n + ': ' + v
end
@socket.writeline ''
end


###
### response line & header
###

public

def get_response
resp = get_resp0
resp = get_resp0 while ContinueCode === resp
resp
end


private

def get_resp0
resp = get_reply
resp = get_reply while ContinueCode === resp

while true do
line = @socket.readline
Expand All @@ -727,56 +763,22 @@ def get_response
resp
end


def get_body( resp, dest )
if chunked? resp then
read_chunked( dest, resp )
else
clen = content_length( resp )
if clen then
@socket.read clen, dest
else
clen = range_length( resp )
if clen then
@socket.read clen, dest
else
tmp = resp['connection']
if tmp and /close/i === tmp then
@socket.read_all dest
else
tmp = resp['proxy-connection']
if tmp and /close/i === tmp then
@socket.read_all dest
end
end
end
end
end
end_critical
end

def no_body
end_critical
end


private


def request( req, u_header )
@socket.writeline req
if u_header then
header = @in_header.dup.update( u_header )
else
header = @in_header
end
header.each do |n,v|
@socket.writeline n + ': ' + v
def get_reply
str = @socket.readline
m = /\AHTTP\/(\d+\.\d+)?\s+(\d\d\d)\s*(.*)\z/i.match( str )
unless m then
raise HTTPBadResponse, "wrong status line: #{str}"
end
@socket.writeline ''
@http_version = m[1]
status = m[2]
discrip = m[3]

code = HTTPCODE_TO_OBJ[status] ||
HTTPCODE_CLASS_TO_OBJ[status[0,1]] ||
UnknownCode
HTTPResponse.new( code, status, discrip )
end


HTTPCODE_CLASS_TO_OBJ = {
'1' => HTTPInformationCode,
'2' => HTTPSuccessCode,
Expand Down Expand Up @@ -829,22 +831,47 @@ def request( req, u_header )
'505' => HTTPVersionNotSupported
}

def get_reply
str = @socket.readline
m = /\AHTTP\/(\d+\.\d+)?\s+(\d\d\d)\s*(.*)\z/i.match( str )
unless m then
raise HTTPBadResponse, "wrong status line: #{str}"

###
### body
###

public

def get_body( resp, dest )
if chunked? resp then
read_chunked( dest, resp )
else
clen = content_length( resp )
if clen then
@socket.read clen, dest
else
clen = range_length( resp )
if clen then
@socket.read clen, dest
else
tmp = resp['connection']
if tmp and /close/i === tmp then
@socket.read_all dest
else
tmp = resp['proxy-connection']
if tmp and /close/i === tmp then
@socket.read_all dest
end
end
end
end
end
@http_version = m[1]
status = m[2]
discrip = m[3]

code = HTTPCODE_TO_OBJ[status] ||
HTTPCODE_CLASS_TO_OBJ[status[0,1]] ||
UnknownCode
HTTPResponse.new( code, status, discrip )
end_critical
end

def no_body
end_critical
end


private

def read_chunked( ret, header )
len = nil
total = 0
Expand All @@ -865,7 +892,6 @@ def read_chunked( ret, header )
end
end


def content_length( header )
if header.key? 'content-length' then
m = /\d+/.match( header['content-length'] )
Expand Down
2 changes: 1 addition & 1 deletion lib/net/pop.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=begin
= net/pop.rb version 1.1.29
= net/pop.rb version 1.1.30
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
Expand Down
8 changes: 4 additions & 4 deletions lib/net/protocol.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=begin
= net/protocol.rb version 1.1.29
= net/protocol.rb version 1.1.30
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
Expand Down Expand Up @@ -69,7 +69,7 @@ module Net

class Protocol

Version = '1.1.29'
Version = '1.1.30'


class << self
Expand Down Expand Up @@ -421,10 +421,10 @@ def end_critical
@critical = false
end

def critical_ok
def error_ok
@critical = false
end
public :critical_ok
public :error_ok

end

Expand Down
4 changes: 2 additions & 2 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=begin
= net/smtp.rb version 1.1.29
= net/smtp.rb version 1.1.30
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
Expand Down Expand Up @@ -146,7 +146,7 @@ def do_start( helodom = nil,
rescue ProtocolError
if @esmtp then
@esmtp = false
@command.critical_ok
@command.error_ok
retry
else
raise
Expand Down

0 comments on commit 41e41d3

Please sign in to comment.