| 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. |
| 1169 | const 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`. |
| 1182 | interface IncomingMessageInternals { |