diff options
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 |