Skip to content

Commit

Permalink
fix: #540
Browse files Browse the repository at this point in the history
  • Loading branch information
avwo committed Feb 19, 2021
1 parent c84f9b0 commit 089a770
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/handlers/file-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function parseRes(str, rawHeaderNames, fromValue) {
};
}

function addLength(reader, length) {
reader.headers['content-length'] = length;
}

function getRawResByValue(body) {
var headers;
if (HEADERS_SEP_RE.test(body)) {
Expand All @@ -66,6 +70,7 @@ function getRawResByValue(body) {
var reader = parseRes(headers, rawHeaderNames, true);
reader.rawHeaderNames = rawHeaderNames;
reader.body = body;
addLength(reader, body ? Buffer.byteLength(body) : 0);
return reader;
}

Expand Down Expand Up @@ -142,9 +147,6 @@ module.exports = function(req, res, next) {
}
var defaultType = mime.lookup(req.fullUrl.replace(/[?#].*$/, ''), 'text/html');
var rule = req.rules.rule;
var addLength = function(reader, length) {
reader.headers['content-length'] = length;
};
if (rule.value) {
var body = util.removeProtocol(rule.value, true);
var isRawFile = isRawFileProtocol(protocol);
Expand All @@ -170,8 +172,6 @@ module.exports = function(req, res, next) {
} else {
addLength(reader, size);
}
} else {
addLength(reader, Buffer.byteLength(body));
}
reader = util.wrapResponse(reader);
reader.realUrl = rule.matcher;
Expand Down

0 comments on commit 089a770

Please sign in to comment.