Skip to content

Commit

Permalink
fix: update broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sidwebworks committed Aug 26, 2022
1 parent 5e1a5e3 commit b132d35
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,11 @@ function _writeRaw(data, encoding, callback) {
}

if (conn && conn.writable && !this._removedContLen && this._hasBody) {
const shouldContinue = conn._httpMessage.statusCode !== 304 && !this.getHeader('transfer-encoding');
const skip = conn._httpMessage.statusCode === 304 || (this.hasHeader('transfer-encoding') || this.chunkedEncoding);

if (typeof this._contentLength === 'number' && shouldContinue) {
if (typeof this._contentLength === 'number' && !skip) {
const size = _getMessageBodySize(data, conn._httpMessage._header, encoding);

console.log({data,size, _contentLength: this._contentLength, written: this[kBytesWritten]});
console.log("\n*********************************\n");

if ((size + this[kBytesWritten]) > this._contentLength) {
throw new ERR_HTTP_CONTENT_LENGTH_MISMATCH(size + this[kBytesWritten], this._contentLength);
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-content-length-mismatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function shouldThrowOnMoreBytes() {
assert.strictEqual(res.statusCode, 200);
server.close();
}));
req.end()
req.end();
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-outgoing-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const OutgoingMessage = http.OutgoingMessage;
msg._implicitHeader = function() {};
assert.strictEqual(msg.writableLength, 0);
msg.write('asd');
assert.strictEqual(msg.writableLength, 7);
assert.strictEqual(msg.writableLength, 3);
}

{
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-response-multi-content-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function test(server) {
{
const server = http.createServer((req, res) => {
res.setHeader('content-length', [2, 1]);
res.end('ok');
res.end('k');
});

test(server);
Expand Down

0 comments on commit b132d35

Please sign in to comment.