Refactor, and log when we have a 'range' header.

This commit is contained in:
Shane Kilkelly 2015-08-28 12:16:41 +01:00
parent 387e96ab67
commit 8a631e70f7

View file

@ -13,19 +13,20 @@ module.exports = FileController =
getFile: (req, res)-> getFile: (req, res)->
{key, bucket} = req {key, bucket} = req
{format, style} = req.query {format, style} = req.query
opts = { options = {
key: key, key: key,
bucket: bucket, bucket: bucket,
format: format, format: format,
style: style, style: style,
} }
metrics.inc "getFile" metrics.inc "getFile"
logger.log key:key, bucket:bucket, format:format, style: style, "reciving request to get file"
if req.headers.range? if req.headers.range?
range = FileController._get_range(req.headers.range) range = FileController._get_range(req.headers.range)
opts.start = range.start options.start = range.start
opts.end = range.end options.end = range.end
logger.log key:key, bucket:bucket, format:format, style:style, "reciving request to get file" logger.log start: range.start, end: range.end, "getting range of bytes from file"
FileHandler.getFile bucket, key, opts, (err, fileStream)-> FileHandler.getFile bucket, key, options, (err, fileStream)->
if err? if err?
logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file" logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file"
if !res.finished and res?.send? if !res.finished and res?.send?