fix: add x-forwarded-host header
This commit is contained in:
@@ -136,6 +136,7 @@ class BaseHandler(abc.ABC, http.server.BaseHTTPRequestHandler):
|
|||||||
def send_proxy(self, url: str) -> None:
|
def send_proxy(self, url: str) -> None:
|
||||||
headers = dict(self.headers)
|
headers = dict(self.headers)
|
||||||
headers["Host"] = urllib.parse.urlparse(url).netloc
|
headers["Host"] = urllib.parse.urlparse(url).netloc
|
||||||
|
headers["X-Forwarded-Host"] = self.host
|
||||||
headers["X-Forwarded-For"] = self.client_address[0]
|
headers["X-Forwarded-For"] = self.client_address[0]
|
||||||
headers["X-Real-IP"] = self.client_address[0]
|
headers["X-Real-IP"] = self.client_address[0]
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -756,6 +756,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": None,
|
"data": None,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "localhost",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
},
|
},
|
||||||
@@ -795,6 +796,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": b"hello",
|
"data": b"hello",
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "localhost",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
"Content-Length": "5",
|
"Content-Length": "5",
|
||||||
@@ -834,6 +836,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": None,
|
"data": None,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "localhost",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
},
|
},
|
||||||
@@ -864,6 +867,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": None,
|
"data": None,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "localhost",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
},
|
},
|
||||||
@@ -903,6 +907,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": None,
|
"data": None,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "localhost",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
},
|
},
|
||||||
@@ -939,6 +944,7 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
"data": None,
|
"data": None,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Host": "example.com",
|
"Host": "example.com",
|
||||||
|
"X-Forwarded-Host": "host",
|
||||||
"X-Forwarded-For": "127.0.0.1",
|
"X-Forwarded-For": "127.0.0.1",
|
||||||
"X-Real-IP": "127.0.0.1",
|
"X-Real-IP": "127.0.0.1",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user