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 | 4642ffdf4a41073a1382f49072e5f2f062485687 (patch) | |
| tree | 4f0b8725f22c7bac5542e497ec55befe83c6af8f /lib | |
| parent | afda1bdb62ce3f6256b73f64b4cf2c93fcd2ade1 (diff) | |
| download | ruby-4642ffdf4a41073a1382f49072e5f2f062485687.tar.gz ruby-4642ffdf4a41073a1382f49072e5f2f062485687.tar.xz ruby-4642ffdf4a41073a1382f49072e5f2f062485687.zip | |
* lib/net/http.rb (HTTPHeader#content_length): should return nil unless header exists. [ruby-dev:22519]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -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 90c473eaf..90843576b 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 |
