mirror of
https://github.com/openziti/zrok.git
synced 2025-06-25 20:22:45 +02:00
tidy py sdk
This commit is contained in:
parent
fe056a2ccc
commit
6d4cc020ce
@ -40,7 +40,7 @@ def main():
|
|||||||
target=args.target_url,
|
target=args.target_url,
|
||||||
unique_name=args.unique_name
|
unique_name=args.unique_name
|
||||||
)
|
)
|
||||||
|
|
||||||
# Log access information and start the proxy
|
# Log access information and start the proxy
|
||||||
logger.info(f"Access proxy at: {', '.join(proxy_share.endpoints)}")
|
logger.info(f"Access proxy at: {', '.join(proxy_share.endpoints)}")
|
||||||
proxy_share.run()
|
proxy_share.run()
|
||||||
|
@ -128,13 +128,13 @@ class ProxyShare:
|
|||||||
def proxy(path):
|
def proxy(path):
|
||||||
# Construct the target URL
|
# Construct the target URL
|
||||||
url = urllib.parse.urljoin(self.target, path)
|
url = urllib.parse.urljoin(self.target, path)
|
||||||
|
|
||||||
# Forward the request
|
# Forward the request
|
||||||
resp = requests.request(
|
resp = requests.request(
|
||||||
method=request.method,
|
method=request.method,
|
||||||
url=url,
|
url=url,
|
||||||
headers={key: value for (key, value) in request.headers
|
headers={key: value for (key, value) in request.headers
|
||||||
if key.lower() not in HOP_BY_HOP_HEADERS},
|
if key.lower() not in HOP_BY_HOP_HEADERS},
|
||||||
data=request.get_data(),
|
data=request.get_data(),
|
||||||
cookies=request.cookies,
|
cookies=request.cookies,
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
@ -144,7 +144,7 @@ class ProxyShare:
|
|||||||
# Create the response
|
# Create the response
|
||||||
excluded_headers = HOP_BY_HOP_HEADERS.union({'host'})
|
excluded_headers = HOP_BY_HOP_HEADERS.union({'host'})
|
||||||
headers = [(name, value) for (name, value) in resp.raw.headers.items()
|
headers = [(name, value) for (name, value) in resp.raw.headers.items()
|
||||||
if name.lower() not in excluded_headers]
|
if name.lower() not in excluded_headers]
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
resp.iter_content(chunk_size=10*1024),
|
resp.iter_content(chunk_size=10*1024),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user