Add request.client_ip (#2790)

Co-authored-by: L. Kärkkäinen <Tronic@users.noreply.github.com>
This commit is contained in:
L. Kärkkäinen
2023-07-13 21:01:02 +01:00
committed by GitHub
parent dc3c4d1393
commit 31d7ba8f8c
2 changed files with 20 additions and 6 deletions

View File

@@ -513,6 +513,7 @@ def test_standard_forwarded(app):
request, response = app.test_client.get("/", headers=headers)
assert response.json == {"for": "127.0.0.2", "proto": "ws"}
assert request.remote_addr == "127.0.0.2"
assert request.client_ip == "127.0.0.2"
assert request.scheme == "ws"
assert request.server_name == "local.site"
assert request.server_port == 80
@@ -737,6 +738,7 @@ def test_remote_addr_with_two_proxies(app):
headers = {"X-Forwarded-For": "127.0.1.1"}
request, response = app.test_client.get("/", headers=headers)
assert request.remote_addr == ""
assert request.client_ip == "127.0.0.1"
assert response.body == b""
headers = {"X-Forwarded-For": "127.0.0.1, 127.0.1.2"}