ruby-changes:56630
From: Nobuyoshi <ko1@a...>
Date: Wed, 24 Jul 2019 00:32:43 +0900 (JST)
Subject: [ruby-changes:56630] Nobuyoshi Nakada: c9826c20d2 (master): Show the caller's location
https://git.ruby-lang.org/ruby.git/commit/?id=c9826c20d2 From c9826c20d204d4b8894e6fd51e5913959676776d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 24 Jul 2019 00:24:12 +0900 Subject: Show the caller's location * lib/net/http/header.rb: show the caller's location instead of the current lines. diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 7865814..356b08d 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -14,9 +14,9 @@ module Net::HTTPHeader https://github.com/ruby/ruby/blob/trunk/lib/net/http/header.rb#L14 @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 diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb index cb4678a..cfbe36b 100644 --- a/test/net/http/test_httpheader.rb +++ b/test/net/http/test_httpheader.rb @@ -119,7 +119,19 @@ class HTTPHeaderTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpheader.rb#L119 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/