forked from unjs/unenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_request.ts
44 lines (37 loc) · 1.23 KB
/
_request.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type http from "node:http";
import { Socket } from "../net/socket";
import { Readable } from "../stream/readable";
import { rawHeaders } from "../../_internal/utils";
// Docs: https://nodejs.org/api/http.html#http_class_http_incomingmessage
// Implementation: https://github.com/nodejs/node/blob/master/lib/_http_incoming.js
export class IncomingMessage extends Readable implements http.IncomingMessage {
public aborted: boolean = false;
public httpVersion: string = "1.1";
public httpVersionMajor: number = 1;
public httpVersionMinor: number = 1;
public complete: boolean = true;
public connection: Socket;
public socket: Socket;
public headers: http.IncomingHttpHeaders = {};
public trailers = {};
public method: string = "GET";
public url: string = "/";
public statusCode: number = 200;
public statusMessage: string = "";
public closed: boolean = false;
public errored: Error | null = null;
readable: boolean = false;
constructor(socket?: Socket) {
super();
this.socket = this.connection = socket || new Socket();
}
get rawHeaders() {
return rawHeaders(this.headers);
}
get rawTrailers() {
return [];
}
setTimeout(_msecs: number, _callback?: () => void) {
return this;
}
}