Skip to content

Commit

Permalink
Proxy the location in the response header, which makes search engines…
Browse files Browse the repository at this point in the history
… work better
  • Loading branch information
rdmark committed Jan 11, 2022
1 parent bb3d65d commit 7fa2f00
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get(path):
try:
g.content_type = resp.headers["Content-Type"]
except:
print("Warning: No Content-Type header detected")
print("Info: No Content-Type header in response to GET request")
if resp.headers["Content-Type"].startswith("text/html"):
return transcode_html(
resp.content,
Expand Down Expand Up @@ -57,7 +57,11 @@ def post(path):
try:
g.content_type = resp.headers["Content-Type"]
except:
print("Warning: No Content-Type header detected")
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")
if resp.headers["Content-Type"].startswith("text/html"):
return transcode_html(
resp.content,
Expand All @@ -77,6 +81,10 @@ def apply_caching(resp):
resp.headers["Content-Type"] = g.content_type
except:
pass
try:
resp.headers["Location"] = g.location
except:
pass
return resp

if __name__ == "__main__":
Expand Down

0 comments on commit 7fa2f00

Please sign in to comment.