Skip to content

Commit

Permalink
Attempt to rewrite redirect URL to http
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Jan 11, 2022
1 parent 7fa2f00 commit cb91636
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ def get(path):
if app.config["USER_AGENT"]:
headers["User-Agent"] = app.config["USER_AGENT"]
resp = session.get(url, params=request.args, headers=headers)
try:
if "content-type" in resp.headers.keys():
g.content_type = resp.headers["Content-Type"]
except:
print("Info: No Content-Type header in response to GET request")
print("Content-type in response header: " + g.content_type)
if "location" in resp.headers.keys():
g.location = resp.headers["Location"].replace("https://", "http://", 1)
print("Location in response header: " + g.location)
if resp.headers["Content-Type"].startswith("text/html"):
return transcode_html(
resp.content,
Expand All @@ -54,14 +56,12 @@ def post(path):
if app.config["USER_AGENT"]:
headers["User-Agent"] = app.config["USER_AGENT"]
resp = session.post(url, data=request.form, headers=headers, allow_redirects=True)
try:
if "content-type" in resp.headers.keys():
g.content_type = resp.headers["Content-Type"]
except:
print("Info: No Content-Type header in response to POST request")
try:
g.location = resp.headers["Location"]
except:
print("Info: No Location header in response to POST request")
print("Content-type in response header: " + g.content_type)
if "location" in resp.headers.keys():
g.location = resp.headers["Location"].replace("https://", "http://", 1)
print("Location in response header: " + g.location)
if resp.headers["Content-Type"].startswith("text/html"):
return transcode_html(
resp.content,
Expand Down

0 comments on commit cb91636

Please sign in to comment.