-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the library-provided reason in the Error’s `message`. Fixes: #28468 PR-URL: #28487 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
- Loading branch information
Showing
8 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
|
||
const response = Buffer.from('HTTP/1.1 200 OK\r\n' + | ||
'Content-Length: 6\r\n' + | ||
'Transfer-Encoding: Chunked\r\n' + | ||
'\r\n' + | ||
'6\r\nfoobar' + | ||
'0\r\n'); | ||
|
||
const server = net.createServer(common.mustCall((conn) => { | ||
conn.write(response); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const req = http.get(`http://localhost:${server.address().port}/`); | ||
req.end(); | ||
req.on('error', common.mustCall((err) => { | ||
const reason = 'Content-Length can\'t be present with chunked encoding'; | ||
assert.strictEqual(err.message, `Parse Error: ${reason}`); | ||
assert(err.bytesParsed < response.length); | ||
assert(err.bytesParsed >= response.indexOf('Transfer-Encoding')); | ||
assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); | ||
assert.strictEqual(err.reason, reason); | ||
assert.deepStrictEqual(err.rawPacket, response); | ||
|
||
server.close(); | ||
})); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters