mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 09:01:53 +00:00
whitelist proxied headers when requesting pdfs from clsi
This commit is contained in:
parent
35b6abe79c
commit
a4ddfd5725
2 changed files with 22 additions and 4 deletions
|
@ -78,7 +78,12 @@ module.exports = CompileController =
|
|||
url = "#{compilerUrl}#{url}"
|
||||
logger.log url: url, "proxying to CLSI"
|
||||
oneMinute = 60 * 1000
|
||||
proxy = request(url: url, method: req.method, timeout: oneMinute, headers: req.headers)
|
||||
# pass through If-* and Range headers for byte serving pdfs
|
||||
# do not send any others, potential proxying loop if Host: is passed!
|
||||
newHeaders = {}
|
||||
for h, v of req.headers
|
||||
newHeaders[h] = req.headers[h] if h.match /^(If-|Range)/i
|
||||
proxy = request(url: url, method: req.method, timeout: oneMinute, headers: newHeaders)
|
||||
proxy.pipe(res)
|
||||
proxy.on "error", (error) ->
|
||||
logger.warn err: error, url: url, "CLSI proxy error"
|
||||
|
|
|
@ -137,7 +137,12 @@ describe "CompileController", ->
|
|||
statusCode: 204
|
||||
headers: { "mock": "header" }
|
||||
@req.method = "mock-method"
|
||||
@req.headers = { 'Mock': 'Headers' }
|
||||
@req.headers = {
|
||||
'Mock': 'Headers',
|
||||
'Range': 'should be passed - Range'
|
||||
'If-Range': 'should be passed - If-Range'
|
||||
'If-Modified-Since': 'should be passed - If-Modified-Since'
|
||||
}
|
||||
|
||||
describe "user with standard priority", ->
|
||||
|
||||
|
@ -152,7 +157,11 @@ describe "CompileController", ->
|
|||
method: @req.method
|
||||
url: "#{@settings.apis.clsi.url}#{@url}",
|
||||
timeout: 60 * 1000
|
||||
headers: @req.headers
|
||||
headers: {
|
||||
'Range': 'should be passed - Range'
|
||||
'If-Range': 'should be passed - If-Range'
|
||||
'If-Modified-Since': 'should be passed - If-Modified-Since'
|
||||
}
|
||||
)
|
||||
.should.equal true
|
||||
|
||||
|
@ -176,7 +185,11 @@ describe "CompileController", ->
|
|||
method: @req.method
|
||||
url: "#{@settings.apis.clsi_priority.url}#{@url}",
|
||||
timeout: 60 * 1000
|
||||
headers: @req.headers
|
||||
headers: {
|
||||
'Range': 'should be passed - Range'
|
||||
'If-Range': 'should be passed - If-Range'
|
||||
'If-Modified-Since': 'should be passed - If-Modified-Since'
|
||||
}
|
||||
)
|
||||
.should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue