-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: export diagnostics channel for http
- Loading branch information
Showing
5 changed files
with
145 additions
and
5 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,51 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
http.diagnosticsChannel.onClientRequestStart.subscribe(common.mustCall(({ request }) => { | ||
assert.strictEqual(typeof request, 'object'); | ||
})); | ||
|
||
http.diagnosticsChannel.onClientResponseFinish.subscribe(common.mustCall(({ request, response }) => { | ||
assert.strictEqual(typeof request, 'object'); | ||
assert.strictEqual(typeof response, 'object'); | ||
})); | ||
|
||
http.diagnosticsChannel.onHTTPRequestStart.subscribe(common.mustCall(({ | ||
request, | ||
response, | ||
socket, | ||
server, | ||
}) => { | ||
assert.strictEqual(typeof request, 'object'); | ||
assert.strictEqual(typeof response, 'object'); | ||
assert.strictEqual(typeof socket, 'object'); | ||
assert.strictEqual(typeof server, 'object'); | ||
})); | ||
|
||
http.diagnosticsChannel.onHTTPResponseFinish.subscribe(common.mustCall(({ | ||
request, | ||
response, | ||
socket, | ||
server, | ||
}) => { | ||
assert.strictEqual(typeof request, 'object'); | ||
assert.strictEqual(typeof response, 'object'); | ||
assert.strictEqual(typeof socket, 'object'); | ||
assert.strictEqual(typeof server, 'object'); | ||
})); | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.end('done'); | ||
})); | ||
|
||
server.listen(() => { | ||
const { port } = server.address(); | ||
http.get(`http://localhost:${port}`, (res) => { | ||
res.resume(); | ||
res.on('end', () => { | ||
server.close(); | ||
}); | ||
}); | ||
}); |