merge revision(s) 55581,55582: [Backport #12557]

* lib/net/http/generic_rquest.rb (write_header): A Request-Line must
	  not contain CR or LF.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2016-08-12 02:46:40 +00:00
parent 9bfab3c125
commit 26df8ea5bb
4 changed files with 23 additions and 2 deletions

View file

@ -320,7 +320,12 @@ class Net::HTTPGenericRequest
end
def write_header(sock, ver, path)
buf = "#{@method} #{path} HTTP/#{ver}\r\n"
reqline = "#{@method} #{path} HTTP/#{ver}"
if /[\r\n]/ =~ reqline
raise ArgumentError, "A Request-Line must not contain CR or LF"
end
buf = ""
buf << reqline << "\r\n"
each_capitalized do |k,v|
buf << "#{k}: #{v}\r\n"
end