summaryrefslogtreecommitdiff
path: root/typings/internalBinding/http_parser.d.ts
blob: bd9a22e55b12e5c4d867e1183f299e50b4005dd4 (plain)
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
45
declare namespace InternalHttpParserBinding {
  type Buffer = Uint8Array;
  type Stream = object;

  class HTTPParser {
    static REQUEST: 1;
    static RESPONSE: 2;

    static kOnMessageBegin: 0;
    static kOnHeaders: 1;
    static kOnHeadersComplete: 2;
    static kOnBody: 3;
    static kOnMessageComplete: 4;
    static kOnExecute: 5;
    static kOnTimeout: 6;

    static kLenientNone: number;
    static kLenientHeaders: number;
    static kLenientChunkedLength: number;
    static kLenientKeepAlive: number;
    static kLenientAll: number;

    close(): void;
    free(): void;
    execute(buffer: Buffer): Error | Buffer;
    finish(): Error | Buffer;
    initialize(
      type: number,
      resource: object,
      maxHeaderSize?: number,
      lenient?: number,
      headersTimeout?: number,
    ): void;
    pause(): void;
    resume(): void;
    consume(stream: Stream): void;
    unconsume(): void;
    getCurrentBuffer(): Buffer;
  }
}

declare function InternalBinding(binding: 'http_parser'): {
  methods: string[];
  HTTPParser: typeof InternalHttpParserBinding.HTTPParser;
};