hyperion-rb 1.0.0.rc17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,907 @@
1
+
2
+ #ifndef INCLUDE_LLHTTP_H_
3
+ #define INCLUDE_LLHTTP_H_
4
+
5
+ #define LLHTTP_VERSION_MAJOR 9
6
+ #define LLHTTP_VERSION_MINOR 3
7
+ #define LLHTTP_VERSION_PATCH 1
8
+
9
+ #ifndef INCLUDE_LLHTTP_ITSELF_H_
10
+ #define INCLUDE_LLHTTP_ITSELF_H_
11
+ #ifdef __cplusplus
12
+ extern "C" {
13
+ #endif
14
+
15
+ #include <stdint.h>
16
+
17
+ typedef struct llhttp__internal_s llhttp__internal_t;
18
+ struct llhttp__internal_s {
19
+ int32_t _index;
20
+ void* _span_pos0;
21
+ void* _span_cb0;
22
+ int32_t error;
23
+ const char* reason;
24
+ const char* error_pos;
25
+ void* data;
26
+ void* _current;
27
+ uint64_t content_length;
28
+ uint8_t type;
29
+ uint8_t method;
30
+ uint8_t http_major;
31
+ uint8_t http_minor;
32
+ uint8_t header_state;
33
+ uint16_t lenient_flags;
34
+ uint8_t upgrade;
35
+ uint8_t finish;
36
+ uint16_t flags;
37
+ uint16_t status_code;
38
+ uint8_t initial_message_completed;
39
+ void* settings;
40
+ };
41
+
42
+ int llhttp__internal_init(llhttp__internal_t* s);
43
+ int llhttp__internal_execute(llhttp__internal_t* s, const char* p, const char* endp);
44
+
45
+ #ifdef __cplusplus
46
+ } /* extern "C" */
47
+ #endif
48
+ #endif /* INCLUDE_LLHTTP_ITSELF_H_ */
49
+
50
+
51
+ #ifndef LLLLHTTP_C_HEADERS_
52
+ #define LLLLHTTP_C_HEADERS_
53
+ #ifdef __cplusplus
54
+ extern "C" {
55
+ #endif
56
+
57
+ enum llhttp_errno {
58
+ HPE_OK = 0,
59
+ HPE_INTERNAL = 1,
60
+ HPE_STRICT = 2,
61
+ HPE_LF_EXPECTED = 3,
62
+ HPE_UNEXPECTED_CONTENT_LENGTH = 4,
63
+ HPE_CLOSED_CONNECTION = 5,
64
+ HPE_INVALID_METHOD = 6,
65
+ HPE_INVALID_URL = 7,
66
+ HPE_INVALID_CONSTANT = 8,
67
+ HPE_INVALID_VERSION = 9,
68
+ HPE_INVALID_HEADER_TOKEN = 10,
69
+ HPE_INVALID_CONTENT_LENGTH = 11,
70
+ HPE_INVALID_CHUNK_SIZE = 12,
71
+ HPE_INVALID_STATUS = 13,
72
+ HPE_INVALID_EOF_STATE = 14,
73
+ HPE_INVALID_TRANSFER_ENCODING = 15,
74
+ HPE_CB_MESSAGE_BEGIN = 16,
75
+ HPE_CB_HEADERS_COMPLETE = 17,
76
+ HPE_CB_MESSAGE_COMPLETE = 18,
77
+ HPE_CB_CHUNK_HEADER = 19,
78
+ HPE_CB_CHUNK_COMPLETE = 20,
79
+ HPE_PAUSED = 21,
80
+ HPE_PAUSED_UPGRADE = 22,
81
+ HPE_PAUSED_H2_UPGRADE = 23,
82
+ HPE_USER = 24,
83
+ HPE_CR_EXPECTED = 25,
84
+ HPE_CB_URL_COMPLETE = 26,
85
+ HPE_CB_STATUS_COMPLETE = 27,
86
+ HPE_CB_HEADER_FIELD_COMPLETE = 28,
87
+ HPE_CB_HEADER_VALUE_COMPLETE = 29,
88
+ HPE_UNEXPECTED_SPACE = 30,
89
+ HPE_CB_RESET = 31,
90
+ HPE_CB_METHOD_COMPLETE = 32,
91
+ HPE_CB_VERSION_COMPLETE = 33,
92
+ HPE_CB_CHUNK_EXTENSION_NAME_COMPLETE = 34,
93
+ HPE_CB_CHUNK_EXTENSION_VALUE_COMPLETE = 35,
94
+ HPE_CB_PROTOCOL_COMPLETE = 38
95
+ };
96
+ typedef enum llhttp_errno llhttp_errno_t;
97
+
98
+ enum llhttp_flags {
99
+ F_CONNECTION_KEEP_ALIVE = 0x1,
100
+ F_CONNECTION_CLOSE = 0x2,
101
+ F_CONNECTION_UPGRADE = 0x4,
102
+ F_CHUNKED = 0x8,
103
+ F_UPGRADE = 0x10,
104
+ F_CONTENT_LENGTH = 0x20,
105
+ F_SKIPBODY = 0x40,
106
+ F_TRAILING = 0x80,
107
+ F_TRANSFER_ENCODING = 0x200
108
+ };
109
+ typedef enum llhttp_flags llhttp_flags_t;
110
+
111
+ enum llhttp_lenient_flags {
112
+ LENIENT_HEADERS = 0x1,
113
+ LENIENT_CHUNKED_LENGTH = 0x2,
114
+ LENIENT_KEEP_ALIVE = 0x4,
115
+ LENIENT_TRANSFER_ENCODING = 0x8,
116
+ LENIENT_VERSION = 0x10,
117
+ LENIENT_DATA_AFTER_CLOSE = 0x20,
118
+ LENIENT_OPTIONAL_LF_AFTER_CR = 0x40,
119
+ LENIENT_OPTIONAL_CRLF_AFTER_CHUNK = 0x80,
120
+ LENIENT_OPTIONAL_CR_BEFORE_LF = 0x100,
121
+ LENIENT_SPACES_AFTER_CHUNK_SIZE = 0x200
122
+ };
123
+ typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
124
+
125
+ enum llhttp_type {
126
+ HTTP_BOTH = 0,
127
+ HTTP_REQUEST = 1,
128
+ HTTP_RESPONSE = 2
129
+ };
130
+ typedef enum llhttp_type llhttp_type_t;
131
+
132
+ enum llhttp_finish {
133
+ HTTP_FINISH_SAFE = 0,
134
+ HTTP_FINISH_SAFE_WITH_CB = 1,
135
+ HTTP_FINISH_UNSAFE = 2
136
+ };
137
+ typedef enum llhttp_finish llhttp_finish_t;
138
+
139
+ enum llhttp_method {
140
+ HTTP_DELETE = 0,
141
+ HTTP_GET = 1,
142
+ HTTP_HEAD = 2,
143
+ HTTP_POST = 3,
144
+ HTTP_PUT = 4,
145
+ HTTP_CONNECT = 5,
146
+ HTTP_OPTIONS = 6,
147
+ HTTP_TRACE = 7,
148
+ HTTP_COPY = 8,
149
+ HTTP_LOCK = 9,
150
+ HTTP_MKCOL = 10,
151
+ HTTP_MOVE = 11,
152
+ HTTP_PROPFIND = 12,
153
+ HTTP_PROPPATCH = 13,
154
+ HTTP_SEARCH = 14,
155
+ HTTP_UNLOCK = 15,
156
+ HTTP_BIND = 16,
157
+ HTTP_REBIND = 17,
158
+ HTTP_UNBIND = 18,
159
+ HTTP_ACL = 19,
160
+ HTTP_REPORT = 20,
161
+ HTTP_MKACTIVITY = 21,
162
+ HTTP_CHECKOUT = 22,
163
+ HTTP_MERGE = 23,
164
+ HTTP_MSEARCH = 24,
165
+ HTTP_NOTIFY = 25,
166
+ HTTP_SUBSCRIBE = 26,
167
+ HTTP_UNSUBSCRIBE = 27,
168
+ HTTP_PATCH = 28,
169
+ HTTP_PURGE = 29,
170
+ HTTP_MKCALENDAR = 30,
171
+ HTTP_LINK = 31,
172
+ HTTP_UNLINK = 32,
173
+ HTTP_SOURCE = 33,
174
+ HTTP_PRI = 34,
175
+ HTTP_DESCRIBE = 35,
176
+ HTTP_ANNOUNCE = 36,
177
+ HTTP_SETUP = 37,
178
+ HTTP_PLAY = 38,
179
+ HTTP_PAUSE = 39,
180
+ HTTP_TEARDOWN = 40,
181
+ HTTP_GET_PARAMETER = 41,
182
+ HTTP_SET_PARAMETER = 42,
183
+ HTTP_REDIRECT = 43,
184
+ HTTP_RECORD = 44,
185
+ HTTP_FLUSH = 45,
186
+ HTTP_QUERY = 46
187
+ };
188
+ typedef enum llhttp_method llhttp_method_t;
189
+
190
+ enum llhttp_status {
191
+ HTTP_STATUS_CONTINUE = 100,
192
+ HTTP_STATUS_SWITCHING_PROTOCOLS = 101,
193
+ HTTP_STATUS_PROCESSING = 102,
194
+ HTTP_STATUS_EARLY_HINTS = 103,
195
+ HTTP_STATUS_RESPONSE_IS_STALE = 110,
196
+ HTTP_STATUS_REVALIDATION_FAILED = 111,
197
+ HTTP_STATUS_DISCONNECTED_OPERATION = 112,
198
+ HTTP_STATUS_HEURISTIC_EXPIRATION = 113,
199
+ HTTP_STATUS_MISCELLANEOUS_WARNING = 199,
200
+ HTTP_STATUS_OK = 200,
201
+ HTTP_STATUS_CREATED = 201,
202
+ HTTP_STATUS_ACCEPTED = 202,
203
+ HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203,
204
+ HTTP_STATUS_NO_CONTENT = 204,
205
+ HTTP_STATUS_RESET_CONTENT = 205,
206
+ HTTP_STATUS_PARTIAL_CONTENT = 206,
207
+ HTTP_STATUS_MULTI_STATUS = 207,
208
+ HTTP_STATUS_ALREADY_REPORTED = 208,
209
+ HTTP_STATUS_TRANSFORMATION_APPLIED = 214,
210
+ HTTP_STATUS_IM_USED = 226,
211
+ HTTP_STATUS_MISCELLANEOUS_PERSISTENT_WARNING = 299,
212
+ HTTP_STATUS_MULTIPLE_CHOICES = 300,
213
+ HTTP_STATUS_MOVED_PERMANENTLY = 301,
214
+ HTTP_STATUS_FOUND = 302,
215
+ HTTP_STATUS_SEE_OTHER = 303,
216
+ HTTP_STATUS_NOT_MODIFIED = 304,
217
+ HTTP_STATUS_USE_PROXY = 305,
218
+ HTTP_STATUS_SWITCH_PROXY = 306,
219
+ HTTP_STATUS_TEMPORARY_REDIRECT = 307,
220
+ HTTP_STATUS_PERMANENT_REDIRECT = 308,
221
+ HTTP_STATUS_BAD_REQUEST = 400,
222
+ HTTP_STATUS_UNAUTHORIZED = 401,
223
+ HTTP_STATUS_PAYMENT_REQUIRED = 402,
224
+ HTTP_STATUS_FORBIDDEN = 403,
225
+ HTTP_STATUS_NOT_FOUND = 404,
226
+ HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
227
+ HTTP_STATUS_NOT_ACCEPTABLE = 406,
228
+ HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,
229
+ HTTP_STATUS_REQUEST_TIMEOUT = 408,
230
+ HTTP_STATUS_CONFLICT = 409,
231
+ HTTP_STATUS_GONE = 410,
232
+ HTTP_STATUS_LENGTH_REQUIRED = 411,
233
+ HTTP_STATUS_PRECONDITION_FAILED = 412,
234
+ HTTP_STATUS_PAYLOAD_TOO_LARGE = 413,
235
+ HTTP_STATUS_URI_TOO_LONG = 414,
236
+ HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
237
+ HTTP_STATUS_RANGE_NOT_SATISFIABLE = 416,
238
+ HTTP_STATUS_EXPECTATION_FAILED = 417,
239
+ HTTP_STATUS_IM_A_TEAPOT = 418,
240
+ HTTP_STATUS_PAGE_EXPIRED = 419,
241
+ HTTP_STATUS_ENHANCE_YOUR_CALM = 420,
242
+ HTTP_STATUS_MISDIRECTED_REQUEST = 421,
243
+ HTTP_STATUS_UNPROCESSABLE_ENTITY = 422,
244
+ HTTP_STATUS_LOCKED = 423,
245
+ HTTP_STATUS_FAILED_DEPENDENCY = 424,
246
+ HTTP_STATUS_TOO_EARLY = 425,
247
+ HTTP_STATUS_UPGRADE_REQUIRED = 426,
248
+ HTTP_STATUS_PRECONDITION_REQUIRED = 428,
249
+ HTTP_STATUS_TOO_MANY_REQUESTS = 429,
250
+ HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL = 430,
251
+ HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
252
+ HTTP_STATUS_LOGIN_TIMEOUT = 440,
253
+ HTTP_STATUS_NO_RESPONSE = 444,
254
+ HTTP_STATUS_RETRY_WITH = 449,
255
+ HTTP_STATUS_BLOCKED_BY_PARENTAL_CONTROL = 450,
256
+ HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
257
+ HTTP_STATUS_CLIENT_CLOSED_LOAD_BALANCED_REQUEST = 460,
258
+ HTTP_STATUS_INVALID_X_FORWARDED_FOR = 463,
259
+ HTTP_STATUS_REQUEST_HEADER_TOO_LARGE = 494,
260
+ HTTP_STATUS_SSL_CERTIFICATE_ERROR = 495,
261
+ HTTP_STATUS_SSL_CERTIFICATE_REQUIRED = 496,
262
+ HTTP_STATUS_HTTP_REQUEST_SENT_TO_HTTPS_PORT = 497,
263
+ HTTP_STATUS_INVALID_TOKEN = 498,
264
+ HTTP_STATUS_CLIENT_CLOSED_REQUEST = 499,
265
+ HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,
266
+ HTTP_STATUS_NOT_IMPLEMENTED = 501,
267
+ HTTP_STATUS_BAD_GATEWAY = 502,
268
+ HTTP_STATUS_SERVICE_UNAVAILABLE = 503,
269
+ HTTP_STATUS_GATEWAY_TIMEOUT = 504,
270
+ HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505,
271
+ HTTP_STATUS_VARIANT_ALSO_NEGOTIATES = 506,
272
+ HTTP_STATUS_INSUFFICIENT_STORAGE = 507,
273
+ HTTP_STATUS_LOOP_DETECTED = 508,
274
+ HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED = 509,
275
+ HTTP_STATUS_NOT_EXTENDED = 510,
276
+ HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511,
277
+ HTTP_STATUS_WEB_SERVER_UNKNOWN_ERROR = 520,
278
+ HTTP_STATUS_WEB_SERVER_IS_DOWN = 521,
279
+ HTTP_STATUS_CONNECTION_TIMEOUT = 522,
280
+ HTTP_STATUS_ORIGIN_IS_UNREACHABLE = 523,
281
+ HTTP_STATUS_TIMEOUT_OCCURED = 524,
282
+ HTTP_STATUS_SSL_HANDSHAKE_FAILED = 525,
283
+ HTTP_STATUS_INVALID_SSL_CERTIFICATE = 526,
284
+ HTTP_STATUS_RAILGUN_ERROR = 527,
285
+ HTTP_STATUS_SITE_IS_OVERLOADED = 529,
286
+ HTTP_STATUS_SITE_IS_FROZEN = 530,
287
+ HTTP_STATUS_IDENTITY_PROVIDER_AUTHENTICATION_ERROR = 561,
288
+ HTTP_STATUS_NETWORK_READ_TIMEOUT = 598,
289
+ HTTP_STATUS_NETWORK_CONNECT_TIMEOUT = 599
290
+ };
291
+ typedef enum llhttp_status llhttp_status_t;
292
+
293
+ #define HTTP_ERRNO_MAP(XX) \
294
+ XX(0, OK, OK) \
295
+ XX(1, INTERNAL, INTERNAL) \
296
+ XX(2, STRICT, STRICT) \
297
+ XX(3, LF_EXPECTED, LF_EXPECTED) \
298
+ XX(4, UNEXPECTED_CONTENT_LENGTH, UNEXPECTED_CONTENT_LENGTH) \
299
+ XX(5, CLOSED_CONNECTION, CLOSED_CONNECTION) \
300
+ XX(6, INVALID_METHOD, INVALID_METHOD) \
301
+ XX(7, INVALID_URL, INVALID_URL) \
302
+ XX(8, INVALID_CONSTANT, INVALID_CONSTANT) \
303
+ XX(9, INVALID_VERSION, INVALID_VERSION) \
304
+ XX(10, INVALID_HEADER_TOKEN, INVALID_HEADER_TOKEN) \
305
+ XX(11, INVALID_CONTENT_LENGTH, INVALID_CONTENT_LENGTH) \
306
+ XX(12, INVALID_CHUNK_SIZE, INVALID_CHUNK_SIZE) \
307
+ XX(13, INVALID_STATUS, INVALID_STATUS) \
308
+ XX(14, INVALID_EOF_STATE, INVALID_EOF_STATE) \
309
+ XX(15, INVALID_TRANSFER_ENCODING, INVALID_TRANSFER_ENCODING) \
310
+ XX(16, CB_MESSAGE_BEGIN, CB_MESSAGE_BEGIN) \
311
+ XX(17, CB_HEADERS_COMPLETE, CB_HEADERS_COMPLETE) \
312
+ XX(18, CB_MESSAGE_COMPLETE, CB_MESSAGE_COMPLETE) \
313
+ XX(19, CB_CHUNK_HEADER, CB_CHUNK_HEADER) \
314
+ XX(20, CB_CHUNK_COMPLETE, CB_CHUNK_COMPLETE) \
315
+ XX(21, PAUSED, PAUSED) \
316
+ XX(22, PAUSED_UPGRADE, PAUSED_UPGRADE) \
317
+ XX(23, PAUSED_H2_UPGRADE, PAUSED_H2_UPGRADE) \
318
+ XX(24, USER, USER) \
319
+ XX(25, CR_EXPECTED, CR_EXPECTED) \
320
+ XX(26, CB_URL_COMPLETE, CB_URL_COMPLETE) \
321
+ XX(27, CB_STATUS_COMPLETE, CB_STATUS_COMPLETE) \
322
+ XX(28, CB_HEADER_FIELD_COMPLETE, CB_HEADER_FIELD_COMPLETE) \
323
+ XX(29, CB_HEADER_VALUE_COMPLETE, CB_HEADER_VALUE_COMPLETE) \
324
+ XX(30, UNEXPECTED_SPACE, UNEXPECTED_SPACE) \
325
+ XX(31, CB_RESET, CB_RESET) \
326
+ XX(32, CB_METHOD_COMPLETE, CB_METHOD_COMPLETE) \
327
+ XX(33, CB_VERSION_COMPLETE, CB_VERSION_COMPLETE) \
328
+ XX(34, CB_CHUNK_EXTENSION_NAME_COMPLETE, CB_CHUNK_EXTENSION_NAME_COMPLETE) \
329
+ XX(35, CB_CHUNK_EXTENSION_VALUE_COMPLETE, CB_CHUNK_EXTENSION_VALUE_COMPLETE) \
330
+ XX(38, CB_PROTOCOL_COMPLETE, CB_PROTOCOL_COMPLETE) \
331
+
332
+
333
+ #define HTTP_METHOD_MAP(XX) \
334
+ XX(0, DELETE, DELETE) \
335
+ XX(1, GET, GET) \
336
+ XX(2, HEAD, HEAD) \
337
+ XX(3, POST, POST) \
338
+ XX(4, PUT, PUT) \
339
+ XX(5, CONNECT, CONNECT) \
340
+ XX(6, OPTIONS, OPTIONS) \
341
+ XX(7, TRACE, TRACE) \
342
+ XX(8, COPY, COPY) \
343
+ XX(9, LOCK, LOCK) \
344
+ XX(10, MKCOL, MKCOL) \
345
+ XX(11, MOVE, MOVE) \
346
+ XX(12, PROPFIND, PROPFIND) \
347
+ XX(13, PROPPATCH, PROPPATCH) \
348
+ XX(14, SEARCH, SEARCH) \
349
+ XX(15, UNLOCK, UNLOCK) \
350
+ XX(16, BIND, BIND) \
351
+ XX(17, REBIND, REBIND) \
352
+ XX(18, UNBIND, UNBIND) \
353
+ XX(19, ACL, ACL) \
354
+ XX(20, REPORT, REPORT) \
355
+ XX(21, MKACTIVITY, MKACTIVITY) \
356
+ XX(22, CHECKOUT, CHECKOUT) \
357
+ XX(23, MERGE, MERGE) \
358
+ XX(24, MSEARCH, M-SEARCH) \
359
+ XX(25, NOTIFY, NOTIFY) \
360
+ XX(26, SUBSCRIBE, SUBSCRIBE) \
361
+ XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
362
+ XX(28, PATCH, PATCH) \
363
+ XX(29, PURGE, PURGE) \
364
+ XX(30, MKCALENDAR, MKCALENDAR) \
365
+ XX(31, LINK, LINK) \
366
+ XX(32, UNLINK, UNLINK) \
367
+ XX(33, SOURCE, SOURCE) \
368
+ XX(46, QUERY, QUERY) \
369
+
370
+
371
+ #define RTSP_METHOD_MAP(XX) \
372
+ XX(1, GET, GET) \
373
+ XX(3, POST, POST) \
374
+ XX(6, OPTIONS, OPTIONS) \
375
+ XX(35, DESCRIBE, DESCRIBE) \
376
+ XX(36, ANNOUNCE, ANNOUNCE) \
377
+ XX(37, SETUP, SETUP) \
378
+ XX(38, PLAY, PLAY) \
379
+ XX(39, PAUSE, PAUSE) \
380
+ XX(40, TEARDOWN, TEARDOWN) \
381
+ XX(41, GET_PARAMETER, GET_PARAMETER) \
382
+ XX(42, SET_PARAMETER, SET_PARAMETER) \
383
+ XX(43, REDIRECT, REDIRECT) \
384
+ XX(44, RECORD, RECORD) \
385
+ XX(45, FLUSH, FLUSH) \
386
+
387
+
388
+ #define HTTP_ALL_METHOD_MAP(XX) \
389
+ XX(0, DELETE, DELETE) \
390
+ XX(1, GET, GET) \
391
+ XX(2, HEAD, HEAD) \
392
+ XX(3, POST, POST) \
393
+ XX(4, PUT, PUT) \
394
+ XX(5, CONNECT, CONNECT) \
395
+ XX(6, OPTIONS, OPTIONS) \
396
+ XX(7, TRACE, TRACE) \
397
+ XX(8, COPY, COPY) \
398
+ XX(9, LOCK, LOCK) \
399
+ XX(10, MKCOL, MKCOL) \
400
+ XX(11, MOVE, MOVE) \
401
+ XX(12, PROPFIND, PROPFIND) \
402
+ XX(13, PROPPATCH, PROPPATCH) \
403
+ XX(14, SEARCH, SEARCH) \
404
+ XX(15, UNLOCK, UNLOCK) \
405
+ XX(16, BIND, BIND) \
406
+ XX(17, REBIND, REBIND) \
407
+ XX(18, UNBIND, UNBIND) \
408
+ XX(19, ACL, ACL) \
409
+ XX(20, REPORT, REPORT) \
410
+ XX(21, MKACTIVITY, MKACTIVITY) \
411
+ XX(22, CHECKOUT, CHECKOUT) \
412
+ XX(23, MERGE, MERGE) \
413
+ XX(24, MSEARCH, M-SEARCH) \
414
+ XX(25, NOTIFY, NOTIFY) \
415
+ XX(26, SUBSCRIBE, SUBSCRIBE) \
416
+ XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
417
+ XX(28, PATCH, PATCH) \
418
+ XX(29, PURGE, PURGE) \
419
+ XX(30, MKCALENDAR, MKCALENDAR) \
420
+ XX(31, LINK, LINK) \
421
+ XX(32, UNLINK, UNLINK) \
422
+ XX(33, SOURCE, SOURCE) \
423
+ XX(34, PRI, PRI) \
424
+ XX(35, DESCRIBE, DESCRIBE) \
425
+ XX(36, ANNOUNCE, ANNOUNCE) \
426
+ XX(37, SETUP, SETUP) \
427
+ XX(38, PLAY, PLAY) \
428
+ XX(39, PAUSE, PAUSE) \
429
+ XX(40, TEARDOWN, TEARDOWN) \
430
+ XX(41, GET_PARAMETER, GET_PARAMETER) \
431
+ XX(42, SET_PARAMETER, SET_PARAMETER) \
432
+ XX(43, REDIRECT, REDIRECT) \
433
+ XX(44, RECORD, RECORD) \
434
+ XX(45, FLUSH, FLUSH) \
435
+ XX(46, QUERY, QUERY) \
436
+
437
+
438
+ #define HTTP_STATUS_MAP(XX) \
439
+ XX(100, CONTINUE, CONTINUE) \
440
+ XX(101, SWITCHING_PROTOCOLS, SWITCHING_PROTOCOLS) \
441
+ XX(102, PROCESSING, PROCESSING) \
442
+ XX(103, EARLY_HINTS, EARLY_HINTS) \
443
+ XX(110, RESPONSE_IS_STALE, RESPONSE_IS_STALE) \
444
+ XX(111, REVALIDATION_FAILED, REVALIDATION_FAILED) \
445
+ XX(112, DISCONNECTED_OPERATION, DISCONNECTED_OPERATION) \
446
+ XX(113, HEURISTIC_EXPIRATION, HEURISTIC_EXPIRATION) \
447
+ XX(199, MISCELLANEOUS_WARNING, MISCELLANEOUS_WARNING) \
448
+ XX(200, OK, OK) \
449
+ XX(201, CREATED, CREATED) \
450
+ XX(202, ACCEPTED, ACCEPTED) \
451
+ XX(203, NON_AUTHORITATIVE_INFORMATION, NON_AUTHORITATIVE_INFORMATION) \
452
+ XX(204, NO_CONTENT, NO_CONTENT) \
453
+ XX(205, RESET_CONTENT, RESET_CONTENT) \
454
+ XX(206, PARTIAL_CONTENT, PARTIAL_CONTENT) \
455
+ XX(207, MULTI_STATUS, MULTI_STATUS) \
456
+ XX(208, ALREADY_REPORTED, ALREADY_REPORTED) \
457
+ XX(214, TRANSFORMATION_APPLIED, TRANSFORMATION_APPLIED) \
458
+ XX(226, IM_USED, IM_USED) \
459
+ XX(299, MISCELLANEOUS_PERSISTENT_WARNING, MISCELLANEOUS_PERSISTENT_WARNING) \
460
+ XX(300, MULTIPLE_CHOICES, MULTIPLE_CHOICES) \
461
+ XX(301, MOVED_PERMANENTLY, MOVED_PERMANENTLY) \
462
+ XX(302, FOUND, FOUND) \
463
+ XX(303, SEE_OTHER, SEE_OTHER) \
464
+ XX(304, NOT_MODIFIED, NOT_MODIFIED) \
465
+ XX(305, USE_PROXY, USE_PROXY) \
466
+ XX(306, SWITCH_PROXY, SWITCH_PROXY) \
467
+ XX(307, TEMPORARY_REDIRECT, TEMPORARY_REDIRECT) \
468
+ XX(308, PERMANENT_REDIRECT, PERMANENT_REDIRECT) \
469
+ XX(400, BAD_REQUEST, BAD_REQUEST) \
470
+ XX(401, UNAUTHORIZED, UNAUTHORIZED) \
471
+ XX(402, PAYMENT_REQUIRED, PAYMENT_REQUIRED) \
472
+ XX(403, FORBIDDEN, FORBIDDEN) \
473
+ XX(404, NOT_FOUND, NOT_FOUND) \
474
+ XX(405, METHOD_NOT_ALLOWED, METHOD_NOT_ALLOWED) \
475
+ XX(406, NOT_ACCEPTABLE, NOT_ACCEPTABLE) \
476
+ XX(407, PROXY_AUTHENTICATION_REQUIRED, PROXY_AUTHENTICATION_REQUIRED) \
477
+ XX(408, REQUEST_TIMEOUT, REQUEST_TIMEOUT) \
478
+ XX(409, CONFLICT, CONFLICT) \
479
+ XX(410, GONE, GONE) \
480
+ XX(411, LENGTH_REQUIRED, LENGTH_REQUIRED) \
481
+ XX(412, PRECONDITION_FAILED, PRECONDITION_FAILED) \
482
+ XX(413, PAYLOAD_TOO_LARGE, PAYLOAD_TOO_LARGE) \
483
+ XX(414, URI_TOO_LONG, URI_TOO_LONG) \
484
+ XX(415, UNSUPPORTED_MEDIA_TYPE, UNSUPPORTED_MEDIA_TYPE) \
485
+ XX(416, RANGE_NOT_SATISFIABLE, RANGE_NOT_SATISFIABLE) \
486
+ XX(417, EXPECTATION_FAILED, EXPECTATION_FAILED) \
487
+ XX(418, IM_A_TEAPOT, IM_A_TEAPOT) \
488
+ XX(419, PAGE_EXPIRED, PAGE_EXPIRED) \
489
+ XX(420, ENHANCE_YOUR_CALM, ENHANCE_YOUR_CALM) \
490
+ XX(421, MISDIRECTED_REQUEST, MISDIRECTED_REQUEST) \
491
+ XX(422, UNPROCESSABLE_ENTITY, UNPROCESSABLE_ENTITY) \
492
+ XX(423, LOCKED, LOCKED) \
493
+ XX(424, FAILED_DEPENDENCY, FAILED_DEPENDENCY) \
494
+ XX(425, TOO_EARLY, TOO_EARLY) \
495
+ XX(426, UPGRADE_REQUIRED, UPGRADE_REQUIRED) \
496
+ XX(428, PRECONDITION_REQUIRED, PRECONDITION_REQUIRED) \
497
+ XX(429, TOO_MANY_REQUESTS, TOO_MANY_REQUESTS) \
498
+ XX(430, REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL, REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL) \
499
+ XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_HEADER_FIELDS_TOO_LARGE) \
500
+ XX(440, LOGIN_TIMEOUT, LOGIN_TIMEOUT) \
501
+ XX(444, NO_RESPONSE, NO_RESPONSE) \
502
+ XX(449, RETRY_WITH, RETRY_WITH) \
503
+ XX(450, BLOCKED_BY_PARENTAL_CONTROL, BLOCKED_BY_PARENTAL_CONTROL) \
504
+ XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, UNAVAILABLE_FOR_LEGAL_REASONS) \
505
+ XX(460, CLIENT_CLOSED_LOAD_BALANCED_REQUEST, CLIENT_CLOSED_LOAD_BALANCED_REQUEST) \
506
+ XX(463, INVALID_X_FORWARDED_FOR, INVALID_X_FORWARDED_FOR) \
507
+ XX(494, REQUEST_HEADER_TOO_LARGE, REQUEST_HEADER_TOO_LARGE) \
508
+ XX(495, SSL_CERTIFICATE_ERROR, SSL_CERTIFICATE_ERROR) \
509
+ XX(496, SSL_CERTIFICATE_REQUIRED, SSL_CERTIFICATE_REQUIRED) \
510
+ XX(497, HTTP_REQUEST_SENT_TO_HTTPS_PORT, HTTP_REQUEST_SENT_TO_HTTPS_PORT) \
511
+ XX(498, INVALID_TOKEN, INVALID_TOKEN) \
512
+ XX(499, CLIENT_CLOSED_REQUEST, CLIENT_CLOSED_REQUEST) \
513
+ XX(500, INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR) \
514
+ XX(501, NOT_IMPLEMENTED, NOT_IMPLEMENTED) \
515
+ XX(502, BAD_GATEWAY, BAD_GATEWAY) \
516
+ XX(503, SERVICE_UNAVAILABLE, SERVICE_UNAVAILABLE) \
517
+ XX(504, GATEWAY_TIMEOUT, GATEWAY_TIMEOUT) \
518
+ XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP_VERSION_NOT_SUPPORTED) \
519
+ XX(506, VARIANT_ALSO_NEGOTIATES, VARIANT_ALSO_NEGOTIATES) \
520
+ XX(507, INSUFFICIENT_STORAGE, INSUFFICIENT_STORAGE) \
521
+ XX(508, LOOP_DETECTED, LOOP_DETECTED) \
522
+ XX(509, BANDWIDTH_LIMIT_EXCEEDED, BANDWIDTH_LIMIT_EXCEEDED) \
523
+ XX(510, NOT_EXTENDED, NOT_EXTENDED) \
524
+ XX(511, NETWORK_AUTHENTICATION_REQUIRED, NETWORK_AUTHENTICATION_REQUIRED) \
525
+ XX(520, WEB_SERVER_UNKNOWN_ERROR, WEB_SERVER_UNKNOWN_ERROR) \
526
+ XX(521, WEB_SERVER_IS_DOWN, WEB_SERVER_IS_DOWN) \
527
+ XX(522, CONNECTION_TIMEOUT, CONNECTION_TIMEOUT) \
528
+ XX(523, ORIGIN_IS_UNREACHABLE, ORIGIN_IS_UNREACHABLE) \
529
+ XX(524, TIMEOUT_OCCURED, TIMEOUT_OCCURED) \
530
+ XX(525, SSL_HANDSHAKE_FAILED, SSL_HANDSHAKE_FAILED) \
531
+ XX(526, INVALID_SSL_CERTIFICATE, INVALID_SSL_CERTIFICATE) \
532
+ XX(527, RAILGUN_ERROR, RAILGUN_ERROR) \
533
+ XX(529, SITE_IS_OVERLOADED, SITE_IS_OVERLOADED) \
534
+ XX(530, SITE_IS_FROZEN, SITE_IS_FROZEN) \
535
+ XX(561, IDENTITY_PROVIDER_AUTHENTICATION_ERROR, IDENTITY_PROVIDER_AUTHENTICATION_ERROR) \
536
+ XX(598, NETWORK_READ_TIMEOUT, NETWORK_READ_TIMEOUT) \
537
+ XX(599, NETWORK_CONNECT_TIMEOUT, NETWORK_CONNECT_TIMEOUT) \
538
+
539
+
540
+ #ifdef __cplusplus
541
+ } /* extern "C" */
542
+ #endif
543
+ #endif /* LLLLHTTP_C_HEADERS_ */
544
+
545
+
546
+ #ifndef INCLUDE_LLHTTP_API_H_
547
+ #define INCLUDE_LLHTTP_API_H_
548
+ #ifdef __cplusplus
549
+ extern "C" {
550
+ #endif
551
+ #include <stddef.h>
552
+
553
+ #if defined(__wasm__)
554
+ #define LLHTTP_EXPORT __attribute__((visibility("default")))
555
+ #elif defined(_WIN32)
556
+ #define LLHTTP_EXPORT __declspec(dllexport)
557
+ #else
558
+ #define LLHTTP_EXPORT
559
+ #endif
560
+
561
+ typedef llhttp__internal_t llhttp_t;
562
+ typedef struct llhttp_settings_s llhttp_settings_t;
563
+
564
+ typedef int (*llhttp_data_cb)(llhttp_t*, const char *at, size_t length);
565
+ typedef int (*llhttp_cb)(llhttp_t*);
566
+
567
+ struct llhttp_settings_s {
568
+ /* Possible return values 0, -1, `HPE_PAUSED` */
569
+ llhttp_cb on_message_begin;
570
+
571
+ /* Possible return values 0, -1, HPE_USER */
572
+ llhttp_data_cb on_protocol;
573
+ llhttp_data_cb on_url;
574
+ llhttp_data_cb on_status;
575
+ llhttp_data_cb on_method;
576
+ llhttp_data_cb on_version;
577
+ llhttp_data_cb on_header_field;
578
+ llhttp_data_cb on_header_value;
579
+ llhttp_data_cb on_chunk_extension_name;
580
+ llhttp_data_cb on_chunk_extension_value;
581
+
582
+ /* Possible return values:
583
+ * 0 - Proceed normally
584
+ * 1 - Assume that request/response has no body, and proceed to parsing the
585
+ * next message
586
+ * 2 - Assume absence of body (as above) and make `llhttp_execute()` return
587
+ * `HPE_PAUSED_UPGRADE`
588
+ * -1 - Error
589
+ * `HPE_PAUSED`
590
+ */
591
+ llhttp_cb on_headers_complete;
592
+
593
+ /* Possible return values 0, -1, HPE_USER */
594
+ llhttp_data_cb on_body;
595
+
596
+ /* Possible return values 0, -1, `HPE_PAUSED` */
597
+ llhttp_cb on_message_complete;
598
+ llhttp_cb on_protocol_complete;
599
+ llhttp_cb on_url_complete;
600
+ llhttp_cb on_status_complete;
601
+ llhttp_cb on_method_complete;
602
+ llhttp_cb on_version_complete;
603
+ llhttp_cb on_header_field_complete;
604
+ llhttp_cb on_header_value_complete;
605
+ llhttp_cb on_chunk_extension_name_complete;
606
+ llhttp_cb on_chunk_extension_value_complete;
607
+
608
+ /* When on_chunk_header is called, the current chunk length is stored
609
+ * in parser->content_length.
610
+ * Possible return values 0, -1, `HPE_PAUSED`
611
+ */
612
+ llhttp_cb on_chunk_header;
613
+ llhttp_cb on_chunk_complete;
614
+ llhttp_cb on_reset;
615
+ };
616
+
617
+ /* Initialize the parser with specific type and user settings.
618
+ *
619
+ * NOTE: lifetime of `settings` has to be at least the same as the lifetime of
620
+ * the `parser` here. In practice, `settings` has to be either a static
621
+ * variable or be allocated with `malloc`, `new`, etc.
622
+ */
623
+ LLHTTP_EXPORT
624
+ void llhttp_init(llhttp_t* parser, llhttp_type_t type,
625
+ const llhttp_settings_t* settings);
626
+
627
+ LLHTTP_EXPORT
628
+ llhttp_t* llhttp_alloc(llhttp_type_t type);
629
+
630
+ LLHTTP_EXPORT
631
+ void llhttp_free(llhttp_t* parser);
632
+
633
+ LLHTTP_EXPORT
634
+ uint8_t llhttp_get_type(llhttp_t* parser);
635
+
636
+ LLHTTP_EXPORT
637
+ uint8_t llhttp_get_http_major(llhttp_t* parser);
638
+
639
+ LLHTTP_EXPORT
640
+ uint8_t llhttp_get_http_minor(llhttp_t* parser);
641
+
642
+ LLHTTP_EXPORT
643
+ uint8_t llhttp_get_method(llhttp_t* parser);
644
+
645
+ LLHTTP_EXPORT
646
+ int llhttp_get_status_code(llhttp_t* parser);
647
+
648
+ LLHTTP_EXPORT
649
+ uint8_t llhttp_get_upgrade(llhttp_t* parser);
650
+
651
+ /* Reset an already initialized parser back to the start state, preserving the
652
+ * existing parser type, callback settings, user data, and lenient flags.
653
+ */
654
+ LLHTTP_EXPORT
655
+ void llhttp_reset(llhttp_t* parser);
656
+
657
+ /* Initialize the settings object */
658
+ LLHTTP_EXPORT
659
+ void llhttp_settings_init(llhttp_settings_t* settings);
660
+
661
+ /* Parse full or partial request/response, invoking user callbacks along the
662
+ * way.
663
+ *
664
+ * If any of `llhttp_data_cb` returns errno not equal to `HPE_OK` - the parsing
665
+ * interrupts, and such errno is returned from `llhttp_execute()`. If
666
+ * `HPE_PAUSED` was used as a errno, the execution can be resumed with
667
+ * `llhttp_resume()` call.
668
+ *
669
+ * In a special case of CONNECT/Upgrade request/response `HPE_PAUSED_UPGRADE`
670
+ * is returned after fully parsing the request/response. If the user wishes to
671
+ * continue parsing, they need to invoke `llhttp_resume_after_upgrade()`.
672
+ *
673
+ * NOTE: if this function ever returns a non-pause type error, it will continue
674
+ * to return the same error upon each successive call up until `llhttp_init()`
675
+ * is called.
676
+ */
677
+ LLHTTP_EXPORT
678
+ llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
679
+
680
+ /* This method should be called when the other side has no further bytes to
681
+ * send (e.g. shutdown of readable side of the TCP connection.)
682
+ *
683
+ * Requests without `Content-Length` and other messages might require treating
684
+ * all incoming bytes as the part of the body, up to the last byte of the
685
+ * connection. This method will invoke `on_message_complete()` callback if the
686
+ * request was terminated safely. Otherwise a error code would be returned.
687
+ */
688
+ LLHTTP_EXPORT
689
+ llhttp_errno_t llhttp_finish(llhttp_t* parser);
690
+
691
+ /* Returns `1` if the incoming message is parsed until the last byte, and has
692
+ * to be completed by calling `llhttp_finish()` on EOF
693
+ */
694
+ LLHTTP_EXPORT
695
+ int llhttp_message_needs_eof(const llhttp_t* parser);
696
+
697
+ /* Returns `1` if there might be any other messages following the last that was
698
+ * successfully parsed.
699
+ */
700
+ LLHTTP_EXPORT
701
+ int llhttp_should_keep_alive(const llhttp_t* parser);
702
+
703
+ /* Make further calls of `llhttp_execute()` return `HPE_PAUSED` and set
704
+ * appropriate error reason.
705
+ *
706
+ * Important: do not call this from user callbacks! User callbacks must return
707
+ * `HPE_PAUSED` if pausing is required.
708
+ */
709
+ LLHTTP_EXPORT
710
+ void llhttp_pause(llhttp_t* parser);
711
+
712
+ /* Might be called to resume the execution after the pause in user's callback.
713
+ * See `llhttp_execute()` above for details.
714
+ *
715
+ * Call this only if `llhttp_execute()` returns `HPE_PAUSED`.
716
+ */
717
+ LLHTTP_EXPORT
718
+ void llhttp_resume(llhttp_t* parser);
719
+
720
+ /* Might be called to resume the execution after the pause in user's callback.
721
+ * See `llhttp_execute()` above for details.
722
+ *
723
+ * Call this only if `llhttp_execute()` returns `HPE_PAUSED_UPGRADE`
724
+ */
725
+ LLHTTP_EXPORT
726
+ void llhttp_resume_after_upgrade(llhttp_t* parser);
727
+
728
+ /* Returns the latest return error */
729
+ LLHTTP_EXPORT
730
+ llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
731
+
732
+ /* Returns the verbal explanation of the latest returned error.
733
+ *
734
+ * Note: User callback should set error reason when returning the error. See
735
+ * `llhttp_set_error_reason()` for details.
736
+ */
737
+ LLHTTP_EXPORT
738
+ const char* llhttp_get_error_reason(const llhttp_t* parser);
739
+
740
+ /* Assign verbal description to the returned error. Must be called in user
741
+ * callbacks right before returning the errno.
742
+ *
743
+ * Note: `HPE_USER` error code might be useful in user callbacks.
744
+ */
745
+ LLHTTP_EXPORT
746
+ void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
747
+
748
+ /* Returns the pointer to the last parsed byte before the returned error. The
749
+ * pointer is relative to the `data` argument of `llhttp_execute()`.
750
+ *
751
+ * Note: this method might be useful for counting the number of parsed bytes.
752
+ */
753
+ LLHTTP_EXPORT
754
+ const char* llhttp_get_error_pos(const llhttp_t* parser);
755
+
756
+ /* Returns textual name of error code */
757
+ LLHTTP_EXPORT
758
+ const char* llhttp_errno_name(llhttp_errno_t err);
759
+
760
+ /* Returns textual name of HTTP method */
761
+ LLHTTP_EXPORT
762
+ const char* llhttp_method_name(llhttp_method_t method);
763
+
764
+ /* Returns textual name of HTTP status */
765
+ LLHTTP_EXPORT
766
+ const char* llhttp_status_name(llhttp_status_t status);
767
+
768
+ /* Enables/disables lenient header value parsing (disabled by default).
769
+ *
770
+ * Lenient parsing disables header value token checks, extending llhttp's
771
+ * protocol support to highly non-compliant clients/server. No
772
+ * `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
773
+ * lenient parsing is "on".
774
+ *
775
+ * **Enabling this flag can pose a security issue since you will be exposed to
776
+ * request smuggling attacks. USE WITH CAUTION!**
777
+ */
778
+ LLHTTP_EXPORT
779
+ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
780
+
781
+
782
+ /* Enables/disables lenient handling of conflicting `Transfer-Encoding` and
783
+ * `Content-Length` headers (disabled by default).
784
+ *
785
+ * Normally `llhttp` would error when `Transfer-Encoding` is present in
786
+ * conjunction with `Content-Length`. This error is important to prevent HTTP
787
+ * request smuggling, but may be less desirable for small number of cases
788
+ * involving legacy servers.
789
+ *
790
+ * **Enabling this flag can pose a security issue since you will be exposed to
791
+ * request smuggling attacks. USE WITH CAUTION!**
792
+ */
793
+ LLHTTP_EXPORT
794
+ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
795
+
796
+
797
+ /* Enables/disables lenient handling of `Connection: close` and HTTP/1.0
798
+ * requests responses.
799
+ *
800
+ * Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
801
+ * the HTTP request/response after the request/response with `Connection: close`
802
+ * and `Content-Length`. This is important to prevent cache poisoning attacks,
803
+ * but might interact badly with outdated and insecure clients. With this flag
804
+ * the extra request/response will be parsed normally.
805
+ *
806
+ * **Enabling this flag can pose a security issue since you will be exposed to
807
+ * poisoning attacks. USE WITH CAUTION!**
808
+ */
809
+ LLHTTP_EXPORT
810
+ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
811
+
812
+ /* Enables/disables lenient handling of `Transfer-Encoding` header.
813
+ *
814
+ * Normally `llhttp` would error when a `Transfer-Encoding` has `chunked` value
815
+ * and another value after it (either in a single header or in multiple
816
+ * headers whose value are internally joined using `, `).
817
+ * This is mandated by the spec to reliably determine request body size and thus
818
+ * avoid request smuggling.
819
+ * With this flag the extra value will be parsed normally.
820
+ *
821
+ * **Enabling this flag can pose a security issue since you will be exposed to
822
+ * request smuggling attacks. USE WITH CAUTION!**
823
+ */
824
+ LLHTTP_EXPORT
825
+ void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled);
826
+
827
+ /* Enables/disables lenient handling of HTTP version.
828
+ *
829
+ * Normally `llhttp` would error when the HTTP version in the request or status line
830
+ * is not `0.9`, `1.0`, `1.1` or `2.0`.
831
+ * With this flag the invalid value will be parsed normally.
832
+ *
833
+ * **Enabling this flag can pose a security issue since you will allow unsupported
834
+ * HTTP versions. USE WITH CAUTION!**
835
+ */
836
+ LLHTTP_EXPORT
837
+ void llhttp_set_lenient_version(llhttp_t* parser, int enabled);
838
+
839
+ /* Enables/disables lenient handling of additional data received after a message ends
840
+ * and keep-alive is disabled.
841
+ *
842
+ * Normally `llhttp` would error when additional unexpected data is received if the message
843
+ * contains the `Connection` header with `close` value.
844
+ * With this flag the extra data will discarded without throwing an error.
845
+ *
846
+ * **Enabling this flag can pose a security issue since you will be exposed to
847
+ * poisoning attacks. USE WITH CAUTION!**
848
+ */
849
+ LLHTTP_EXPORT
850
+ void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled);
851
+
852
+ /* Enables/disables lenient handling of incomplete CRLF sequences.
853
+ *
854
+ * Normally `llhttp` would error when a CR is not followed by LF when terminating the
855
+ * request line, the status line, the headers or a chunk header.
856
+ * With this flag only a CR is required to terminate such sections.
857
+ *
858
+ * **Enabling this flag can pose a security issue since you will be exposed to
859
+ * request smuggling attacks. USE WITH CAUTION!**
860
+ */
861
+ LLHTTP_EXPORT
862
+ void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled);
863
+
864
+ /*
865
+ * Enables/disables lenient handling of line separators.
866
+ *
867
+ * Normally `llhttp` would error when a LF is not preceded by CR when terminating the
868
+ * request line, the status line, the headers, a chunk header or a chunk data.
869
+ * With this flag only a LF is required to terminate such sections.
870
+ *
871
+ * **Enabling this flag can pose a security issue since you will be exposed to
872
+ * request smuggling attacks. USE WITH CAUTION!**
873
+ */
874
+ LLHTTP_EXPORT
875
+ void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled);
876
+
877
+ /* Enables/disables lenient handling of chunks not separated via CRLF.
878
+ *
879
+ * Normally `llhttp` would error when after a chunk data a CRLF is missing before
880
+ * starting a new chunk.
881
+ * With this flag the new chunk can start immediately after the previous one.
882
+ *
883
+ * **Enabling this flag can pose a security issue since you will be exposed to
884
+ * request smuggling attacks. USE WITH CAUTION!**
885
+ */
886
+ LLHTTP_EXPORT
887
+ void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled);
888
+
889
+ /* Enables/disables lenient handling of spaces after chunk size.
890
+ *
891
+ * Normally `llhttp` would error when after a chunk size is followed by one or more
892
+ * spaces are present instead of a CRLF or `;`.
893
+ * With this flag this check is disabled.
894
+ *
895
+ * **Enabling this flag can pose a security issue since you will be exposed to
896
+ * request smuggling attacks. USE WITH CAUTION!**
897
+ */
898
+ LLHTTP_EXPORT
899
+ void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled);
900
+
901
+ #ifdef __cplusplus
902
+ } /* extern "C" */
903
+ #endif
904
+ #endif /* INCLUDE_LLHTTP_API_H_ */
905
+
906
+
907
+ #endif /* INCLUDE_LLHTTP_H_ */