diff options
| author | Mia Herkt <mia@0x0.st> | 2022-11-30 02:28:19 +0100 |
|---|---|---|
| committer | Mia Herkt <mia@0x0.st> | 2022-11-30 02:30:52 +0100 |
| commit | 9214bb483289cbcba8268654129e08d1369c4b24 (patch) | |
| tree | ca8083afbc4c659c33f67de7622dea1cf40db1db /fhost.py | |
| parent | e1685342581604b83b4b1b6ab9b10bcde5ef9d01 (diff) | |
Add X-Expires to file response headers
Tells clients when files will expire, in milliseconds since Unix epoch.
Closes #50.
Diffstat (limited to 'fhost.py')
| -rwxr-xr-x | fhost.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -344,6 +344,7 @@ def store_file(f, requested_expiration: typing.Optional[int], addr): sf, isnew = File.store(f, requested_expiration, addr) response = make_response(sf.geturl()) + response.headers["X-Expires"] = sf.expiration if isnew: response.headers["X-Token"] = sf.mgmt_token @@ -427,9 +428,11 @@ def get(path): response.headers["Content-Type"] = f.mime response.headers["Content-Length"] = fpath.stat().st_size response.headers["X-Accel-Redirect"] = "/" + str(fpath) - return response 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: if request.method == "POST": abort(405) |
