зеркало из https://github.com/github/ruby.git
* lib/net/http/header.rb: Warn nil variable on HTTP Header.
It caused to NoMethodError. [fix GH-952][fix GH-641] Patch by @teosz * test/net/http/test_httpheader.rb: Added test for nil HTTP Header. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0897a6df5e
Коммит
809d3770e6
|
@ -1,3 +1,9 @@
|
|||
Fri Jan 29 10:44:56 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* lib/net/http/header.rb: Warn nil variable on HTTP Header.
|
||||
It caused to NoMethodError. [fix GH-952][fix GH-641] Patch by @teosz
|
||||
* test/net/http/test_httpheader.rb: Added test for nil HTTP Header.
|
||||
|
||||
Thu Jan 28 17:31:43 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c (sock_gethostname): support unlimited size
|
||||
|
|
|
@ -15,7 +15,11 @@ module Net::HTTPHeader
|
|||
return unless initheader
|
||||
initheader.each do |key, value|
|
||||
warn "net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
|
||||
@header[key.downcase] = [value.strip]
|
||||
if value.nil?
|
||||
warn "net/http: warning: nil HTTP header: #{key}" if $VERBOSE
|
||||
else
|
||||
@header[key.downcase] = [value.strip]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -450,4 +454,3 @@ module Net::HTTPHeader
|
|||
private :tokens
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -82,6 +82,12 @@ class HTTPHeaderTest < Test::Unit::TestCase
|
|||
assert_equal ['test string'], @c.get_fields('my-header')
|
||||
end
|
||||
|
||||
class D; include Net::HTTPHeader; end
|
||||
|
||||
def test_nil_variable_header
|
||||
assert_nothing_raised { D.new.initialize_http_header({Authorization: nil}) }
|
||||
end
|
||||
|
||||
def test_delete
|
||||
@c['My-Header'] = 'test'
|
||||
assert_equal 'test', @c['My-Header']
|
||||
|
|
Загрузка…
Ссылка в новой задаче