mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 17:13:38 -05:00
send a strong etag for the output.pdf file, needed for byte ranges in pdf.js
This commit is contained in:
parent
c119d2ba79
commit
95373d2b7e
1 changed files with 7 additions and 0 deletions
|
@ -38,10 +38,17 @@ app.get "/project/:project_id/sync/pdf", CompileController.syncFromPdf
|
||||||
staticServer = express.static Settings.path.compilesDir, setHeaders: (res, path, stat) ->
|
staticServer = express.static Settings.path.compilesDir, setHeaders: (res, path, stat) ->
|
||||||
if Path.basename(path) == "output.pdf"
|
if Path.basename(path) == "output.pdf"
|
||||||
res.set("Content-Type", "application/pdf")
|
res.set("Content-Type", "application/pdf")
|
||||||
|
# Calculate an etag in the same way as nginx
|
||||||
|
# https://github.com/tj/send/issues/65
|
||||||
|
etag = (path, stat) ->
|
||||||
|
'"' + Math.ceil(+stat.mtime / 1000).toString(16) +
|
||||||
|
'-' + Number(stat.size).toString(16) + '"'
|
||||||
|
res.set("Etag", etag(path, stat))
|
||||||
else
|
else
|
||||||
# Force plain treatment of other file types to prevent hosting of HTTP/JS files
|
# Force plain treatment of other file types to prevent hosting of HTTP/JS files
|
||||||
# that could be used in same-origin/XSS attacks.
|
# that could be used in same-origin/XSS attacks.
|
||||||
res.set("Content-Type", "text/plain")
|
res.set("Content-Type", "text/plain")
|
||||||
|
|
||||||
app.get "/project/:project_id/output/*", (req, res, next) ->
|
app.get "/project/:project_id/output/*", (req, res, next) ->
|
||||||
req.url = "/#{req.params.project_id}/#{req.params[0]}"
|
req.url = "/#{req.params.project_id}/#{req.params[0]}"
|
||||||
staticServer(req, res, next)
|
staticServer(req, res, next)
|
||||||
|
|
Loading…
Reference in a new issue