-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
http2: add lenient flag for RFC-9113 #58116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1f3f58a
1b7f283
6f187b0
96415de
3e9a3f2
66cfc88
2c4db31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use strict'; | ||
Check failure on line 1 in test/parallel/test-http2-server-rfc-9113-client.js
|
||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
const body = | ||
'<html><head></head><body><h1>this is some data</h2></body></html>'; | ||
|
||
const server = http2.createServer((req, res) => { | ||
res.setHeader('foobar', 'baz '); | ||
res.setHeader('X-POWERED-BY', 'node-test\t'); | ||
res.setHeader('x-h2-header', '\tconnection-test'); | ||
res.setHeader('x-h2-header-2', ' connection-test'); | ||
res.setHeader('x-h2-header-3', 'connection-test '); | ||
res.end(body); | ||
}); | ||
|
||
const server2 = http2.createServer((req, res) => { | ||
res.setHeader('foobar', 'baz '); | ||
res.setHeader('X-POWERED-BY', 'node-test\t'); | ||
res.setHeader('x-h2-header', '\tconnection-test'); | ||
res.setHeader('x-h2-header-2', ' connection-test'); | ||
res.setHeader('x-h2-header-3', 'connection-test '); | ||
res.end(body); | ||
}); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
server2.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
const client2 = http2.connect(`http://localhost:${server2.address().port}`, { strictHttpFieldValidation: false }); | ||
const headers = { ':path': '/' }; | ||
const req = client.request(headers); | ||
|
||
req.setEncoding('utf8'); | ||
|
||
req.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers.foobar, undefined); | ||
assert.strictEqual(headers['x-powered-by'], undefined); | ||
assert.strictEqual(headers['x-powered-by'], undefined); | ||
assert.strictEqual(headers['x-h2-header'], undefined); | ||
assert.strictEqual(headers['x-h2-header-2'], undefined); | ||
assert.strictEqual(headers['x-h2-header-3'], undefined); | ||
})); | ||
|
||
let data = ''; | ||
req.on('data', (d) => data += d); | ||
|
||
req.on('end', () => { | ||
assert.strictEqual(body, data); | ||
client.close(); | ||
|
||
const req2 = client2.request(headers); | ||
let data2 = ''; | ||
req2.setEncoding('utf8'); | ||
req2.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers.foobar, 'baz '); | ||
assert.strictEqual(headers['x-powered-by'], 'node-test\t'); | ||
assert.strictEqual(headers['x-h2-header'], '\tconnection-test'); | ||
assert.strictEqual(headers['x-h2-header-2'], ' connection-test'); | ||
assert.strictEqual(headers['x-h2-header-3'], 'connection-test '); | ||
})); | ||
req2.on('data', (d) => data2 += d); | ||
req2.on('end', () => { | ||
assert.strictEqual(body, data2); | ||
client2.close(); | ||
server.close(); | ||
}); | ||
req2.end(); | ||
}); | ||
|
||
req.end(); | ||
})); | ||
})); | ||
|
||
server.on('error', common.mustNotCall()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use strict'; | ||
Check failure on line 1 in test/parallel/test-http2-server-rfc-9113-server.js
|
||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
const body = | ||
'<html><head></head><body><h1>this is some data</h2></body></html>'; | ||
|
||
const server = http2.createServer((req, res) => { | ||
assert.strictEqual(req.headers['x-powered-by'], undefined); | ||
assert.strictEqual(req.headers.foobar, undefined); | ||
assert.strictEqual(req.headers['x-h2-header'], undefined); | ||
assert.strictEqual(req.headers['x-h2-header-2'], undefined); | ||
assert.strictEqual(req.headers['x-h2-header-3'], undefined); | ||
assert.strictEqual(req.headers['x-h2-header-4'], undefined); | ||
res.writeHead(200); | ||
res.end(body); | ||
}); | ||
|
||
const server2 = http2.createServer({ strictHttpFieldValidation: false },(req, res) => { | ||
assert.strictEqual(req.headers.foobar, 'baz '); | ||
assert.strictEqual(req.headers['x-powered-by'], 'node-test\t'); | ||
assert.strictEqual(req.headers['x-h2-header'], '\tconnection-test'); | ||
assert.strictEqual(req.headers['x-h2-header-2'], ' connection-test'); | ||
assert.strictEqual(req.headers['x-h2-header-3'], 'connection-test '); | ||
assert.strictEqual(req.headers['x-h2-header-4'], 'connection-test\t'); | ||
res.writeHead(200); | ||
res.end(body); | ||
}); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
server2.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
const client2 = http2.connect(`http://localhost:${server2.address().port}`); | ||
const headers = { | ||
':path': '/', | ||
foobar: 'baz ', | ||
'x-powered-by': 'node-test\t', | ||
'x-h2-header': '\tconnection-test', | ||
'x-h2-header-2': ' connection-test', | ||
'x-h2-header-3': 'connection-test ', | ||
'x-h2-header-4': 'connection-test\t' | ||
}; | ||
const req = client.request(headers); | ||
|
||
req.setEncoding('utf8'); | ||
|
||
req.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers[':status'], 200); | ||
})); | ||
|
||
let data = ''; | ||
req.on('data', (d) => data += d); | ||
|
||
req.on('end', () => { | ||
assert.strictEqual(body, data); | ||
client.close(); | ||
|
||
const req2 = client2.request(headers); | ||
let data2 = ''; | ||
req2.setEncoding('utf8'); | ||
req2.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers[':status'], 200); | ||
})); | ||
req2.on('data', (d) => data2 += d); | ||
req2.on('end', () => { | ||
assert.strictEqual(body, data2); | ||
client2.close(); | ||
server.close(); | ||
}); | ||
req2.end(); | ||
}); | ||
|
||
req.end(); | ||
})); | ||
})); | ||
|
||
server.on('error', common.mustNotCall()); |
Uh oh!
There was an error while loading. Please reload this page.