|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +constcommon=require('../common'); |
| 4 | +if(!common.hasCrypto) |
| 5 | +common.skip('missing crypto'); |
| 6 | +constassert=require('assert'); |
| 7 | +consthttp2=require('http2'); |
| 8 | +constbody= |
| 9 | +'<html><head></head><body><h1>this is some data</h2></body></html>'; |
| 10 | + |
| 11 | +constserver=http2.createServer((req,res)=>{ |
| 12 | +res.setHeader('foobar','baz '); |
| 13 | +res.setHeader('X-POWERED-BY','node-test\t'); |
| 14 | +res.setHeader('x-h2-header','\tconnection-test'); |
| 15 | +res.setHeader('x-h2-header-2',' connection-test'); |
| 16 | +res.setHeader('x-h2-header-3','connection-test '); |
| 17 | +res.end(body); |
| 18 | +}); |
| 19 | + |
| 20 | +constserver2=http2.createServer((req,res)=>{ |
| 21 | +res.setHeader('foobar','baz '); |
| 22 | +res.setHeader('X-POWERED-BY','node-test\t'); |
| 23 | +res.setHeader('x-h2-header','\tconnection-test'); |
| 24 | +res.setHeader('x-h2-header-2',' connection-test'); |
| 25 | +res.setHeader('x-h2-header-3','connection-test '); |
| 26 | +res.end(body); |
| 27 | +}); |
| 28 | + |
| 29 | +server.listen(0,common.mustCall(()=>{ |
| 30 | +server2.listen(0,common.mustCall(()=>{ |
| 31 | +constclient=http2.connect(`http://localhost:${server.address().port}`); |
| 32 | +constclient2=http2.connect(`http://localhost:${server2.address().port}`,{strictFieldWhitespaceValidation: false}); |
| 33 | +constheaders={':path': '/'}; |
| 34 | +constreq=client.request(headers); |
| 35 | + |
| 36 | +req.setEncoding('utf8'); |
| 37 | +req.on('response',common.mustCall(function(headers){ |
| 38 | +assert.strictEqual(headers.foobar,undefined); |
| 39 | +assert.strictEqual(headers['x-powered-by'],undefined); |
| 40 | +assert.strictEqual(headers['x-powered-by'],undefined); |
| 41 | +assert.strictEqual(headers['x-h2-header'],undefined); |
| 42 | +assert.strictEqual(headers['x-h2-header-2'],undefined); |
| 43 | +assert.strictEqual(headers['x-h2-header-3'],undefined); |
| 44 | +})); |
| 45 | + |
| 46 | +letdata=''; |
| 47 | +req.on('data',(d)=>data+=d); |
| 48 | +req.on('end',()=>{ |
| 49 | +assert.strictEqual(body,data); |
| 50 | +client.close(); |
| 51 | +client.on('close',common.mustCall(()=>{ |
| 52 | +server.close(); |
| 53 | +})); |
| 54 | + |
| 55 | +constreq2=client2.request(headers); |
| 56 | +letdata2=''; |
| 57 | +req2.setEncoding('utf8'); |
| 58 | +req2.on('response',common.mustCall(function(headers){ |
| 59 | +assert.strictEqual(headers.foobar,'baz '); |
| 60 | +assert.strictEqual(headers['x-powered-by'],'node-test\t'); |
| 61 | +assert.strictEqual(headers['x-h2-header'],'\tconnection-test'); |
| 62 | +assert.strictEqual(headers['x-h2-header-2'],' connection-test'); |
| 63 | +assert.strictEqual(headers['x-h2-header-3'],'connection-test '); |
| 64 | +})); |
| 65 | +req2.on('data',(d)=>data2+=d); |
| 66 | +req2.on('end',()=>{ |
| 67 | +assert.strictEqual(body,data2); |
| 68 | +client2.close(); |
| 69 | +client2.on('close',common.mustCall(()=>{ |
| 70 | +server2.close(); |
| 71 | +})); |
| 72 | +}); |
| 73 | +req2.end(); |
| 74 | +}); |
| 75 | + |
| 76 | +req.end(); |
| 77 | +})); |
| 78 | +})); |
| 79 | + |
| 80 | +server.on('error',common.mustNotCall()); |
0 commit comments