MCPcopy Index your code
hub / github.com/nodejs/node / onServerStream

Function onServerStream

lib/internal/http2/compat.js:964–999  ·  view source on GitHub ↗
(ServerRequest, ServerResponse,
                        stream, headers, flags, rawHeaders)

Source from the content-addressed store, hash-verified

962}
963
964function onServerStream(ServerRequest, ServerResponse,
965 stream, headers, flags, rawHeaders) {
966 const server = this;
967 const request = new ServerRequest(stream, headers, undefined, rawHeaders);
968 const response = new ServerResponse(stream);
969
970 // Check for the CONNECT method
971 const method = headers[HTTP2_HEADER_METHOD];
972 if (method === 'CONNECT') {
973 if (!server.emit('connect', request, response)) {
974 response.statusCode = HTTP_STATUS_METHOD_NOT_ALLOWED;
975 response.end();
976 }
977 return;
978 }
979
980 // Check for Expectations
981 if (headers.expect !== undefined) {
982 if (headers.expect === '100-continue') {
983 if (server.listenerCount('checkContinue')) {
984 server.emit('checkContinue', request, response);
985 } else {
986 response.writeContinue();
987 server.emit('request', request, response);
988 }
989 } else if (server.listenerCount('checkExpectation')) {
990 server.emit('checkExpectation', request, response);
991 } else {
992 response.statusCode = HTTP_STATUS_EXPECTATION_FAILED;
993 response.end();
994 }
995 return;
996 }
997
998 server.emit('request', request, response);
999}
1000
1001module.exports = {
1002 onServerStream,

Callers

nothing calls this directly

Calls 4

listenerCountMethod · 0.80
writeContinueMethod · 0.80
emitMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…