1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

add an explicit test for this behavior

This commit is contained in:
James Brown 2021-06-30 13:22:56 -07:00 committed by Nate Berkopec
parent 0302cc9727
commit 2955a13062
No known key found for this signature in database
GPG key ID: 19616755F4328D71

View file

@ -1383,4 +1383,17 @@ EOF
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"
assert_equal "user", data.split("\r\n").last
end
def test_remote_address_header
server_run(remote_address: :header, remote_address_header: 'HTTP_X_REMOTE_IP') do |env|
[200, {}, [env['REMOTE_ADDR']]]
end
remote_addr = send_http_and_read("GET / HTTP/1.1\r\nX-Remote-IP: 1.2.3.4\r\n\r\n").split("\r\n").last
assert_equal '1.2.3.4', remote_addr
# TODO: it would be great to test a connection from a non-localhost IP, but we can't really do that. For
# now, at least test that it doesn't return garbage.
remote_addr = send_http_and_read("GET / HTTP/1.1\r\n\r\n").split("\r\n").last
assert_equal @host, remote_addr
end
end