forked from forks/microblog.pub
Fix the media proxy
This commit is contained in:
parent
181328d518
commit
2cd0835208
1 changed files with 2 additions and 2 deletions
4
app.py
4
app.py
|
@ -258,7 +258,7 @@ def proxy(scheme: str, url: str) -> Any:
|
||||||
}
|
}
|
||||||
req_headers["Host"] = urlparse(url).netloc
|
req_headers["Host"] = urlparse(url).netloc
|
||||||
resp = requests.get(url, stream=True, headers=req_headers)
|
resp = requests.get(url, stream=True, headers=req_headers)
|
||||||
app.logger.info(f"proxied req {url}: {resp!r}")
|
app.logger.info(f"proxied req {url} {req_headers}: {resp!r}")
|
||||||
|
|
||||||
def data():
|
def data():
|
||||||
for chunk in resp.raw.stream(decode_content=False):
|
for chunk in resp.raw.stream(decode_content=False):
|
||||||
|
@ -278,7 +278,7 @@ def proxy(scheme: str, url: str) -> Any:
|
||||||
"last-modified",
|
"last-modified",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return Response(data(), headers=resp_headers)
|
return Response(data(), headers=resp_headers, status=resp.status_code)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/media/<media_id>")
|
@app.route("/media/<media_id>")
|
||||||
|
|
Loading…
Reference in a new issue