mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix faulty content-length comparison in utils/http-helpers.js.
Since body is a string, body.length is not necessarily the number of bytes in the response body.
This commit is contained in:
committed by
Jesse Rosenberger
parent
3438a3ac94
commit
1a036553c1
@@ -310,12 +310,16 @@ _.extend(exports, {
|
||||
var req = request(options, function (error, response, body) {
|
||||
if (! error && response && body) {
|
||||
const contentLength = Number(response.headers["content-length"]);
|
||||
if (contentLength > 0 && body.length < contentLength) {
|
||||
const actualLength = Buffer.byteLength(body);
|
||||
|
||||
if (contentLength > 0 &&
|
||||
actualLength < contentLength) {
|
||||
error = new Error(
|
||||
"Expected " + contentLength + " bytes in request body " +
|
||||
"but received only " + body.length);
|
||||
"but received only " + actualLength);
|
||||
}
|
||||
}
|
||||
|
||||
return callback.call(this, error, response, body);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user