11#ifndef INCLUDE_LLHTTP_H_
22#define INCLUDE_LLHTTP_H_
33
4- #define LLHTTP_VERSION_MAJOR 1
5- #define LLHTTP_VERSION_MINOR 1
6- #define LLHTTP_VERSION_PATCH 4
4+ #define LLHTTP_VERSION_MAJOR 2
5+ #define LLHTTP_VERSION_MINOR 0
6+ #define LLHTTP_VERSION_PATCH 1
77
88#ifndef INCLUDE_LLHTTP_ITSELF_H_
99#define INCLUDE_LLHTTP_ITSELF_H_
@@ -29,7 +29,7 @@ struct llhttp__internal_s {
2929 uint8_t http_major;
3030 uint8_t http_minor;
3131 uint8_t header_state;
32- uint8_t flags;
32+ uint16_t flags;
3333 uint8_t upgrade;
3434 uint16_t status_code;
3535 uint8_t finish;
@@ -85,7 +85,8 @@ enum llhttp_flags {
8585 F_UPGRADE = 0x10,
8686 F_CONTENT_LENGTH = 0x20,
8787 F_SKIPBODY = 0x40,
88- F_TRAILING = 0x80
88+ F_TRAILING = 0x80,
89+ F_LENIENT = 0x100
8990};
9091typedef enum llhttp_flags llhttp_flags_t;
9192
@@ -297,7 +298,7 @@ llhttp_errno_t llhttp_finish(llhttp_t* parser);
297298int llhttp_message_needs_eof(const llhttp_t* parser);
298299
299300/* Returns `1` if there might be any other messages following the last that was
300- * successfuly parsed.
301+ * successfully parsed.
301302 */
302303int llhttp_should_keep_alive(const llhttp_t* parser);
303304
@@ -353,6 +354,18 @@ const char* llhttp_errno_name(llhttp_errno_t err);
353354/* Returns textual name of HTTP method */
354355const char* llhttp_method_name(llhttp_method_t method);
355356
357+
358+ /* Enables/disables lenient header value parsing (disabled by default).
359+ *
360+ * Lenient parsing disables header value token checks, extending llhttp's
361+ * protocol support to highly non-compliant clients/server. No
362+ * `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
363+ * lenient parsing is "on".
364+ *
365+ * **(USE AT YOUR OWN RISK)**
366+ */
367+ void llhttp_set_lenient(llhttp_t* parser, int enabled);
368+
356369#ifdef __cplusplus
357370} /* extern "C" */
358371#endif
0 commit comments