-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: update http-parser to version 2.6.1
includes parsing improvements to ensure closer HTTP spec conformance PR-URL: nodejs-private/node-private#26 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
Showing
12 changed files
with
409 additions
and
18 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
28 changes: 28 additions & 0 deletions
28
test/parallel/test-http-client-reject-chunked-with-content-length.js
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,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
const assert = require('assert'); | ||
|
||
const reqstr = 'HTTP/1.1 200 OK\r\n' + | ||
'Content-Length: 1\r\n' + | ||
'Transfer-Encoding: chunked\r\n\r\n'; | ||
|
||
const server = net.createServer((socket) => { | ||
socket.write(reqstr); | ||
}); | ||
|
||
server.listen(common.PORT, () => { | ||
// The callback should not be called because the server is sending | ||
// both a Content-Length header and a Transfer-Encoding: chunked | ||
// header, which is a violation of the HTTP spec. | ||
const req = http.get({port:common.PORT}, (res) => { | ||
assert.fail(null, null, 'callback should not be called'); | ||
}); | ||
req.on('error', common.mustCall((err) => { | ||
assert(/^Parse Error/.test(err.message)); | ||
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const net = require('net'); | ||
const assert = require('assert'); | ||
|
||
const reqstr = 'HTTP/1.1 200 OK\r\n' + | ||
'Foo: Bar\r' + | ||
'Content-Length: 1\r\n\r\n'; | ||
|
||
const server = net.createServer((socket) => { | ||
socket.write(reqstr); | ||
}); | ||
|
||
server.listen(common.PORT, () => { | ||
// The callback should not be called because the server is sending a | ||
// header field that ends only in \r with no following \n | ||
const req = http.get({port:common.PORT}, (res) => { | ||
assert.fail(null, null, 'callback should not be called'); | ||
}); | ||
req.on('error', common.mustCall((err) => { | ||
assert(/^Parse Error/.test(err.message)); | ||
assert.equal(err.code, 'HPE_LF_EXPECTED'); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
// The callback should never be invoked because the server | ||
// should respond with a 400 Client Error when a double | ||
// Content-Length header is received. | ||
const server = http.createServer((req, res) => { | ||
assert(false, 'callback should not have been invoked'); | ||
res.end(); | ||
}); | ||
server.on('clientError', common.mustCall((err, socket) => { | ||
assert(/^Parse Error/.test(err.message)); | ||
assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); | ||
socket.destroy(); | ||
})); | ||
|
||
server.listen(common.PORT, () => { | ||
const req = http.get({ | ||
port: common.PORT, | ||
// Send two content-length header values. | ||
headers: {'Content-Length': [1, 2]}}, | ||
(res) => { | ||
assert.fail(null, null, 'an error should have occurred'); | ||
server.close(); | ||
} | ||
); | ||
req.on('error', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
}); |
Oops, something went wrong.