Joachim Van Herwegen 953458231b fix: Prevent HttpRequest from being closed
In case a stream the request is being piped into closes,
we don't want to close the request since it shares a socket
with the response.
2021-04-09 09:04:25 +02:00

15 lines
432 B
TypeScript

import type { IncomingMessage } from 'http';
import type { Guarded } from '../util/GuardedStream';
/**
* An incoming HTTP request;
*/
export type HttpRequest = Guarded<IncomingMessage>;
/**
* Checks if the given stream is an HttpRequest.
*/
export function isHttpRequest(stream: any): stream is HttpRequest {
return typeof stream.socket === 'object' && typeof stream.url === 'string' && typeof stream.method === 'string';
}