This repository has been archived by the owner on Jul 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: doc fix & test for http2.connect() optional arguments
- Loading branch information
1 parent
36cfaf9
commit 1eec6da
Showing
2 changed files
with
30 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Flags: --expose-http2 | ||
'use strict'; | ||
|
||
const { mustCall } = require('../common'); | ||
const { doesNotThrow } = require('assert'); | ||
const { createServer, connect } = require('http2'); | ||
|
||
const server = createServer(); | ||
server.listen(0, mustCall(() => { | ||
const authority = `http://localhost:${server.address().port}`; | ||
const options = {}; | ||
const listener = () => mustCall(); | ||
|
||
const clients = new Set(); | ||
doesNotThrow(() => clients.add(connect(authority))); | ||
doesNotThrow(() => clients.add(connect(authority, options))); | ||
doesNotThrow(() => clients.add(connect(authority, options, listener()))); | ||
doesNotThrow(() => clients.add(connect(authority, listener()))); | ||
|
||
for (const client of clients) { | ||
client.once('connect', mustCall((headers) => { | ||
client.destroy(); | ||
clients.delete(client); | ||
if (clients.size === 0) { | ||
server.close(); | ||
} | ||
})); | ||
} | ||
})); |