* lib/net/http.rb (HTTPHeader#content_length): should return nil unless header exists. [ruby-dev:22519]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2004-01-07 11:42:21 +00:00
parent 6abca35457
commit 7050611cf9
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Wed Jan 7 20:42:06 2004 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb (HTTPHeader#content_length): should return nil
unless header exists. [ruby-dev:22519]
Wed Jan 7 14:26:05 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb (TkPanedWindow): use epath for embedded windows.

View File

@ -1032,7 +1032,8 @@ module Net # :nodoc:
# Returns an Integer object which represents the Content-Length: header field
# or +nil+ if that field is not provided.
def content_length
len = @header['content-length'].to_s.slice(/\d+/) or
return nil unless @header.key?('content-length')
len = @header['content-length'].slice(/\d+/) or
raise HTTPHeaderSyntaxError, 'wrong Content-Length format'
len.to_i
end