mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Show the caller's location
* lib/net/http/header.rb: show the caller's location instead of the current lines.
This commit is contained in:
parent
325f7b6008
commit
c9826c20d2
2 changed files with 15 additions and 3 deletions
|
@ -14,9 +14,9 @@ module Net::HTTPHeader
|
|||
@header = {}
|
||||
return unless initheader
|
||||
initheader.each do |key, value|
|
||||
warn "net/http: duplicated HTTP header: #{key}", uplevel: 1 if key?(key) and $VERBOSE
|
||||
warn "net/http: duplicated HTTP header: #{key}", uplevel: 3 if key?(key) and $VERBOSE
|
||||
if value.nil?
|
||||
warn "net/http: nil HTTP header: #{key}", uplevel: 1 if $VERBOSE
|
||||
warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
|
||||
else
|
||||
value = value.strip # raise error for invalid byte sequences
|
||||
if value.count("\r\n") > 0
|
||||
|
|
|
@ -119,7 +119,19 @@ class HTTPHeaderTest < Test::Unit::TestCase
|
|||
class D; include Net::HTTPHeader; end
|
||||
|
||||
def test_nil_variable_header
|
||||
assert_nothing_raised { D.new.initialize_http_header({Authorization: nil}) }
|
||||
assert_nothing_raised do
|
||||
assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: nil HTTP header: Authorization\n") do
|
||||
D.new.initialize_http_header({Authorization: nil})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_duplicated_variable_header
|
||||
assert_nothing_raised do
|
||||
assert_warning("#{__FILE__}:#{__LINE__+1}: warning: net/http: duplicated HTTP header: Authorization\n") do
|
||||
D.new.initialize_http_header({"AUTHORIZATION": "yes", "Authorization": "no"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_delete
|
||||
|
|
Loading…
Add table
Reference in a new issue