-
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.
PR-URL: #51172 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
5 changed files
with
85 additions
and
7 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
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,48 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
const stream = require('stream'); | ||
const makeDuplexPair = require('../common/duplexpair'); | ||
|
||
// Basic test | ||
{ | ||
const { clientSide, serverSide } = makeDuplexPair(); | ||
|
||
const client = http2.connect('http://example.com', { | ||
createConnection: () => clientSide, | ||
}); | ||
|
||
const session = http2.performServerHandshake(serverSide); | ||
|
||
session.on('stream', common.mustCall((stream, headers) => { | ||
assert.strictEqual(headers[':path'], '/test'); | ||
stream.respond({ | ||
':status': 200, | ||
}); | ||
stream.end('hi!'); | ||
})); | ||
|
||
const req = client.request({ ':path': '/test' }); | ||
req.on('response', common.mustCall()); | ||
req.end(); | ||
} | ||
|
||
// Double bind should fail | ||
{ | ||
const socket = new stream.Duplex({ | ||
read() {}, | ||
write() {}, | ||
}); | ||
|
||
http2.performServerHandshake(socket); | ||
|
||
assert.throws(() => { | ||
http2.performServerHandshake(socket); | ||
}, { code: 'ERR_HTTP2_SOCKET_BOUND' }); | ||
} |