Skip to content

Commit d39ebf0

Browse files
committed
simplify
1 parent 11143b9 commit d39ebf0

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/llhttp/constants.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,18 @@ export const HEADER_STATE = {
203203
TRANSFER_ENCODING_CHUNKED: 8,
204204
} as const;
205205

206+
export const METHODS_HTTP1_HEAD = {
207+
HEAD: 2,
208+
} as const;
209+
206210
/**
207211
* HTTP methods as defined by RFC-9110 and other specifications.
208212
* @see https://httpwg.org/specs/rfc9110.html#method.definitions
209213
*/
210214
export const METHODS_BASIC_HTTP = {
211215
DELETE: 0,
212216
GET: 1,
213-
HEAD: 2,
217+
...METHODS_HTTP1_HEAD,
214218
POST: 3,
215219
PUT: 4,
216220
CONNECT: 5,
@@ -332,13 +336,6 @@ export const METHODS = {
332336
...METHODS_RTSP,
333337
} as const;
334338

335-
export const H_METHOD_MAP: Simplify<Pick<
336-
typeof METHODS_BASIC_HTTP,
337-
"HEAD">
338-
> = {
339-
HEAD: 2,
340-
} as const;
341-
342339
// ALPHA: https://tools.ietf.org/html/rfc5234#appendix-B.1
343340
export const ALPHA = [
344341
"A", "a", "B", "b", "C", "c", "D", "d",
@@ -522,9 +519,9 @@ export default {
522519
SPECIAL_HEADERS,
523520
METHODS,
524521
METHODS_HTTP,
522+
METHODS_HTTP1_HEAD,
525523
METHODS_HTTP1,
526524
METHODS_HTTP2,
527525
METHODS_ICECAST,
528526
METHODS_RTSP,
529-
H_METHOD_MAP,
530527
}

src/llhttp/http.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import Node = source.node.Node;
66

77
import {
88
type IntDict,
9-
CONNECTION_TOKEN_CHARS, ERROR, FINISH, FLAGS, H_METHOD_MAP, HEADER_CHARS,
9+
CONNECTION_TOKEN_CHARS, ERROR, FINISH, FLAGS, HEADER_CHARS,
1010
HEADER_STATE, HEX_MAP, HTAB_SP_VCHAR_OBS_TEXT,
1111
LENIENT_FLAGS,
1212
MAJOR,
13-
METHODS, METHODS_HTTP, METHODS_ICECAST, METHODS_RTSP,
13+
METHODS, METHODS_HTTP, METHODS_HTTP1_HEAD, METHODS_ICECAST, METHODS_RTSP,
1414
MINOR, NUM_MAP, QDTEXT, SPECIAL_HEADERS,
1515
TOKEN, TYPE,
1616
} from './constants';
@@ -285,7 +285,7 @@ export class HTTP {
285285
.otherwise(this.update('type', TYPE.REQUEST, 'start_req'));
286286

287287
n('req_or_res_method')
288-
.select(H_METHOD_MAP, this.store('method',
288+
.select(METHODS_HTTP1_HEAD, this.store('method',
289289
this.update('type', TYPE.REQUEST, this.span.method.end(
290290
this.invokePausable('on_method_complete', ERROR.CB_METHOD_COMPLETE, n('req_first_space_before_url')),
291291
)),

0 commit comments

Comments
 (0)