Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
diagnostics_channel: add storage channel#44894
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -90,6 +90,7 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => { | ||
| }); | ||
| const dc = require('diagnostics_channel'); | ||
| const storageChannel = dc.storageChannel('http.server'); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you document somewhere that there is an | ||
| const onRequestStartChannel = dc.channel('http.server.request.start'); | ||
| const onResponseFinishChannel = dc.channel('http.server.response.finish'); | ||
| @@ -1009,62 +1010,77 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { | ||
| }); | ||
| } | ||
| if (socket._httpMessage) { | ||
| // There are already pending outgoing res, append. | ||
| state.outgoing.push(res); | ||
| } else { | ||
| res.assignSocket(socket); | ||
| } | ||
| // When we're finished writing the response, check if this is the last | ||
| // response, if so destroy the socket. | ||
| res.on('finish', | ||
| resOnFinish.bind(undefined, | ||
| req, res, socket, state, server)); | ||
| try { | ||
| if (storageChannel.hasSubscribers) { | ||
| storageChannel._enter({ | ||
| request: req, | ||
| response: res, | ||
| socket, | ||
| server | ||
| }); | ||
| } | ||
| let handled = false; | ||
| if (socket._httpMessage) { | ||
| // There are already pending outgoing res, append. | ||
| state.outgoing.push(res); | ||
| } else { | ||
| res.assignSocket(socket); | ||
| } | ||
| if (req.httpVersionMajor === 1 && req.httpVersionMinor === 1) { | ||
| const isRequestsLimitSet = ( | ||
| typeof server.maxRequestsPerSocket === 'number' && | ||
| server.maxRequestsPerSocket > 0 | ||
| ); | ||
| // When we're finished writing the response, check if this is the last | ||
| // response, if so destroy the socket. | ||
| res.on('finish', | ||
| resOnFinish.bind(undefined, | ||
| req, res, socket, state, server)); | ||
| if (isRequestsLimitSet) { | ||
| state.requestsCount++; | ||
| res.maxRequestsOnConnectionReached = ( | ||
| server.maxRequestsPerSocket <= state.requestsCount); | ||
| } | ||
| let handled = false; | ||
| if (isRequestsLimitSet && | ||
| (server.maxRequestsPerSocket < state.requestsCount)) { | ||
| handled = true; | ||
| server.emit('dropRequest', req, socket); | ||
| res.writeHead(503); | ||
| res.end(); | ||
| } else if (req.headers.expect !== undefined) { | ||
| handled = true; | ||
| if (req.httpVersionMajor === 1 && req.httpVersionMinor === 1) { | ||
| const isRequestsLimitSet = ( | ||
| typeof server.maxRequestsPerSocket === 'number' && | ||
| server.maxRequestsPerSocket > 0 | ||
| ); | ||
| if (RegExpPrototypeExec(continueExpression, req.headers.expect) !== null) { | ||
| res._expect_continue = true; | ||
| if (isRequestsLimitSet) { | ||
| state.requestsCount++; | ||
| res.maxRequestsOnConnectionReached = ( | ||
| server.maxRequestsPerSocket <= state.requestsCount); | ||
| } | ||
| if (server.listenerCount('checkContinue') > 0) { | ||
| server.emit('checkContinue', req, res); | ||
| if (isRequestsLimitSet && | ||
| (server.maxRequestsPerSocket < state.requestsCount)) { | ||
| handled = true; | ||
| server.emit('dropRequest', req, socket); | ||
| res.writeHead(503); | ||
| res.end(); | ||
| } else if (req.headers.expect !== undefined) { | ||
| handled = true; | ||
| if (RegExpPrototypeExec(continueExpression, req.headers.expect) !== null) { | ||
| res._expect_continue = true; | ||
| if (server.listenerCount('checkContinue') > 0) { | ||
| server.emit('checkContinue', req, res); | ||
| } else { | ||
| res.writeContinue(); | ||
| server.emit('request', req, res); | ||
| } | ||
| } else if (server.listenerCount('checkExpectation') > 0) { | ||
| server.emit('checkExpectation', req, res); | ||
| } else { | ||
| res.writeContinue(); | ||
| server.emit('request', req, res); | ||
| res.writeHead(417); | ||
| res.end(); | ||
| } | ||
| } else if (server.listenerCount('checkExpectation') > 0) { | ||
| server.emit('checkExpectation', req, res); | ||
| } else { | ||
| res.writeHead(417); | ||
| res.end(); | ||
| } | ||
| } | ||
| } | ||
| if (!handled) { | ||
| server.emit('request', req, res); | ||
| if (!handled) { | ||
| server.emit('request', req, res); | ||
| } | ||
| } finally { | ||
| if (storageChannel.hasSubscribers) { | ||
| storageChannel._exit(); | ||
| } | ||
| } | ||
| return 0; // No special treatment. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.