MCPcopy Create free account
hub / github.com/Effect-TS/effect / closesConnection

Function closesConnection

packages/platform/node/src/NodeHttpServer.ts:1169–1179  ·  view source on GitHub ↗
(request: Http.IncomingMessage | undefined, streaming: boolean)

Source from the content-addressed store, hash-verified

1167// Decided when the headers are written, while `Connection: close` can still be sent. A streaming
1168// response may still read the body, so only a pending 100 Continue closes it here.
1169const closesConnection = (request: Http.IncomingMessage | undefined, streaming: boolean): boolean => {
1170 if (request === undefined || request.httpVersionMajor !== 1 || request.complete) {
1171 return false
1172 }
1173 if (pendingContinue.has(request)) {
1174 return true
1175 }
1176 const contentLength = request.headers["content-length"]
1177 return !streaming && contentLength !== undefined &&
1178 Number(contentLength) - (bodyBytesRead.get(request) ?? 0) > maxDrainBytes
1179}
1180
1181// Node internals read by its own `finish` listener, which runs right after `teardownBody`.
1182interface IncomingMessageInternals {

Callers 1

writeHeadFunction · 0.85

Calls 3

hasMethod · 0.65
getMethod · 0.65
NumberFunction · 0.50

Tested by

no test coverage detected