mirror of
https://git.0x0.st/mia/0x0.git
synced 2024-12-22 16:18:57 -05:00
Add X-Expires to file response headers
Tells clients when files will expire, in milliseconds since Unix epoch. Closes #50.
This commit is contained in:
parent
e168534258
commit
9214bb4832
1 changed files with 5 additions and 2 deletions
7
fhost.py
7
fhost.py
|
@ -344,6 +344,7 @@ def store_file(f, requested_expiration: typing.Optional[int], addr):
|
||||||
sf, isnew = File.store(f, requested_expiration, addr)
|
sf, isnew = File.store(f, requested_expiration, addr)
|
||||||
|
|
||||||
response = make_response(sf.geturl())
|
response = make_response(sf.geturl())
|
||||||
|
response.headers["X-Expires"] = sf.expiration
|
||||||
|
|
||||||
if isnew:
|
if isnew:
|
||||||
response.headers["X-Token"] = sf.mgmt_token
|
response.headers["X-Token"] = sf.mgmt_token
|
||||||
|
@ -427,9 +428,11 @@ def get(path):
|
||||||
response.headers["Content-Type"] = f.mime
|
response.headers["Content-Type"] = f.mime
|
||||||
response.headers["Content-Length"] = fpath.stat().st_size
|
response.headers["Content-Length"] = fpath.stat().st_size
|
||||||
response.headers["X-Accel-Redirect"] = "/" + str(fpath)
|
response.headers["X-Accel-Redirect"] = "/" + str(fpath)
|
||||||
return response
|
|
||||||
else:
|
else:
|
||||||
return send_from_directory(app.config["FHOST_STORAGE_PATH"], f.sha256, mimetype = f.mime)
|
response = send_from_directory(app.config["FHOST_STORAGE_PATH"], f.sha256, mimetype = f.mime)
|
||||||
|
|
||||||
|
response.headers["X-Expires"] = f.expiration
|
||||||
|
return response
|
||||||
else:
|
else:
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
abort(405)
|
abort(405)
|
||||||
|
|
Loading…
Reference in a new issue