1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Multiple values X-Forwarded-Proto in webrick

* lib/webrick/httprequest.rb (setup_forwarded_info): Use the first
  value in X-Forwarded-Proto, if header contains multiple comma
  separated values.  Some middlewares may add these values to the
  list, not replacing.  [Fix GH-1386]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-06-21 10:32:26 +00:00
parent bcf0a198f1
commit 978ee6d1ef
3 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Tue Jun 21 19:32:23 2016 Mark St.Godard <markstgodard@gmail.com>
* lib/webrick/httprequest.rb (setup_forwarded_info): Use the first
value in X-Forwarded-Proto, if header contains multiple comma
separated values. Some middlewares may add these values to the
list, not replacing. [Fix GH-1386]
Tue Jun 21 17:17:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp> Tue Jun 21 17:17:42 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* test/ruby/test_io.rb: Skip test_readpartial_with_not_empty_buffer, * test/ruby/test_io.rb: Skip test_readpartial_with_not_empty_buffer,

View file

@ -567,7 +567,9 @@ module WEBrick
if @forwarded_server = self["x-forwarded-server"] if @forwarded_server = self["x-forwarded-server"]
@forwarded_server = @forwarded_server.split(",", 2).first @forwarded_server = @forwarded_server.split(",", 2).first
end end
@forwarded_proto = self["x-forwarded-proto"] if @forwarded_proto = self["x-forwarded-proto"]
@forwarded_proto = @forwarded_proto.split(",", 2).first
end
if host_port = self["x-forwarded-host"] if host_port = self["x-forwarded-host"]
host_port = host_port.split(",", 2).first host_port = host_port.split(",", 2).first
@forwarded_host, tmp = host_port.split(":", 2) @forwarded_host, tmp = host_port.split(":", 2)

View file

@ -301,7 +301,7 @@ GET /
GET /foo HTTP/1.1 GET /foo HTTP/1.1
Host: localhost:10080 Host: localhost:10080
Client-IP: 234.234.234.234 Client-IP: 234.234.234.234
X-Forwarded-Proto: https X-Forwarded-Proto: https, http
X-Forwarded-For: 192.168.1.10, 10.0.0.1, 123.123.123.123 X-Forwarded-For: 192.168.1.10, 10.0.0.1, 123.123.123.123
X-Forwarded-Host: forward.example.com X-Forwarded-Host: forward.example.com
X-Forwarded-Server: server.example.com X-Forwarded-Server: server.example.com