diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-07 11:42:21 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-07 11:42:21 +0000 |
commit | 7050611cf98fc25d012d7dcdab92915b7fcb7f35 (patch) | |
tree | 4f0b8725f22c7bac5542e497ec55befe83c6af8f /lib/net/http.rb | |
parent | 6abca35457d4e16b561fed8b7936b06068b33697 (diff) | |
download | ruby-7050611cf98fc25d012d7dcdab92915b7fcb7f35.tar.gz |
* 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
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r-- | lib/net/http.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index 90c473eaf4..90843576ba 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -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 |