From 7a635a7d12fc127da76bc4eca78414602db6350c Mon Sep 17 00:00:00 2001 From: mame Date: Mon, 26 Nov 2018 05:29:45 +0000 Subject: lib/webrick: explicitly convert header values to a string The values of @header are expected to be all strings; WEBrick::HTTPResponse::[]=(key, val) explicitly converts the second argument to a string and assigns it to @header hash. However, there were some points in WEBrick internal code that assigns non-String to @header. This change fixes the issues. The values are checked by `header_value =~ /\r\n/` in check_header. The type confusion caused conflict with removal of `Object#=~` [Feature #15231]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/httpresponse.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/webrick/httpresponse.rb') diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb index bc1dacc837..41a2510e6f 100644 --- a/lib/webrick/httpresponse.rb +++ b/lib/webrick/httpresponse.rb @@ -254,7 +254,7 @@ module WEBrick @header.delete('content-length') elsif @header['content-length'].nil? unless @body.is_a?(IO) - @header['content-length'] = @body ? @body.bytesize : 0 + @header['content-length'] = (@body ? @body.bytesize : 0).to_s end end @@ -277,7 +277,7 @@ module WEBrick # Location is a single absoluteURI. if location = @header['location'] if @request_uri - @header['location'] = @request_uri.merge(location) + @header['location'] = @request_uri.merge(location).to_s end end end -- cgit v1.2.3