Bump llhttp to 6.0.2
This commit is contained in:
parent
43a47aa08b
commit
d4fd0681ef
|
@ -90,6 +90,7 @@ if (err == HPE_OK) {
|
|||
parser.reason);
|
||||
}
|
||||
```
|
||||
For more information on API usage, please refer to [src/native/api.h](https://github.com/nodejs/llhttp/blob/master/src/native/api.h).
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef INCLUDE_LLHTTP_H_
|
||||
#define INCLUDE_LLHTTP_H_
|
||||
|
||||
#define LLHTTP_VERSION_MAJOR 4
|
||||
#define LLHTTP_VERSION_MAJOR 6
|
||||
#define LLHTTP_VERSION_MINOR 0
|
||||
#define LLHTTP_VERSION_PATCH 0
|
||||
#define LLHTTP_VERSION_PATCH 2
|
||||
|
||||
#ifndef LLHTTP_STRICT_MODE
|
||||
# define LLHTTP_STRICT_MODE 0
|
||||
|
@ -79,7 +79,8 @@ enum llhttp_errno {
|
|||
HPE_CB_CHUNK_COMPLETE = 20,
|
||||
HPE_PAUSED = 21,
|
||||
HPE_PAUSED_UPGRADE = 22,
|
||||
HPE_USER = 23
|
||||
HPE_PAUSED_H2_UPGRADE = 23,
|
||||
HPE_USER = 24
|
||||
};
|
||||
typedef enum llhttp_errno llhttp_errno_t;
|
||||
|
||||
|
@ -98,7 +99,8 @@ typedef enum llhttp_flags llhttp_flags_t;
|
|||
|
||||
enum llhttp_lenient_flags {
|
||||
LENIENT_HEADERS = 0x1,
|
||||
LENIENT_CHUNKED_LENGTH = 0x2
|
||||
LENIENT_CHUNKED_LENGTH = 0x2,
|
||||
LENIENT_KEEP_ALIVE = 0x4
|
||||
};
|
||||
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
|
||||
|
||||
|
@ -190,7 +192,8 @@ typedef enum llhttp_method llhttp_method_t;
|
|||
XX(20, CB_CHUNK_COMPLETE, CB_CHUNK_COMPLETE) \
|
||||
XX(21, PAUSED, PAUSED) \
|
||||
XX(22, PAUSED_UPGRADE, PAUSED_UPGRADE) \
|
||||
XX(23, USER, USER) \
|
||||
XX(23, PAUSED_H2_UPGRADE, PAUSED_H2_UPGRADE) \
|
||||
XX(24, USER, USER) \
|
||||
|
||||
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
|
@ -228,6 +231,60 @@ typedef enum llhttp_method llhttp_method_t;
|
|||
XX(31, LINK, LINK) \
|
||||
XX(32, UNLINK, UNLINK) \
|
||||
XX(33, SOURCE, SOURCE) \
|
||||
|
||||
|
||||
#define RTSP_METHOD_MAP(XX) \
|
||||
XX(1, GET, GET) \
|
||||
XX(3, POST, POST) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(35, DESCRIBE, DESCRIBE) \
|
||||
XX(36, ANNOUNCE, ANNOUNCE) \
|
||||
XX(37, SETUP, SETUP) \
|
||||
XX(38, PLAY, PLAY) \
|
||||
XX(39, PAUSE, PAUSE) \
|
||||
XX(40, TEARDOWN, TEARDOWN) \
|
||||
XX(41, GET_PARAMETER, GET_PARAMETER) \
|
||||
XX(42, SET_PARAMETER, SET_PARAMETER) \
|
||||
XX(43, REDIRECT, REDIRECT) \
|
||||
XX(44, RECORD, RECORD) \
|
||||
XX(45, FLUSH, FLUSH) \
|
||||
|
||||
|
||||
#define HTTP_ALL_METHOD_MAP(XX) \
|
||||
XX(0, DELETE, DELETE) \
|
||||
XX(1, GET, GET) \
|
||||
XX(2, HEAD, HEAD) \
|
||||
XX(3, POST, POST) \
|
||||
XX(4, PUT, PUT) \
|
||||
XX(5, CONNECT, CONNECT) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(7, TRACE, TRACE) \
|
||||
XX(8, COPY, COPY) \
|
||||
XX(9, LOCK, LOCK) \
|
||||
XX(10, MKCOL, MKCOL) \
|
||||
XX(11, MOVE, MOVE) \
|
||||
XX(12, PROPFIND, PROPFIND) \
|
||||
XX(13, PROPPATCH, PROPPATCH) \
|
||||
XX(14, SEARCH, SEARCH) \
|
||||
XX(15, UNLOCK, UNLOCK) \
|
||||
XX(16, BIND, BIND) \
|
||||
XX(17, REBIND, REBIND) \
|
||||
XX(18, UNBIND, UNBIND) \
|
||||
XX(19, ACL, ACL) \
|
||||
XX(20, REPORT, REPORT) \
|
||||
XX(21, MKACTIVITY, MKACTIVITY) \
|
||||
XX(22, CHECKOUT, CHECKOUT) \
|
||||
XX(23, MERGE, MERGE) \
|
||||
XX(24, MSEARCH, M-SEARCH) \
|
||||
XX(25, NOTIFY, NOTIFY) \
|
||||
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
||||
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||
XX(28, PATCH, PATCH) \
|
||||
XX(29, PURGE, PURGE) \
|
||||
XX(30, MKCALENDAR, MKCALENDAR) \
|
||||
XX(31, LINK, LINK) \
|
||||
XX(32, UNLINK, UNLINK) \
|
||||
XX(33, SOURCE, SOURCE) \
|
||||
XX(34, PRI, PRI) \
|
||||
XX(35, DESCRIBE, DESCRIBE) \
|
||||
XX(36, ANNOUNCE, ANNOUNCE) \
|
||||
|
@ -242,7 +299,6 @@ typedef enum llhttp_method llhttp_method_t;
|
|||
XX(45, FLUSH, FLUSH) \
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -255,6 +311,12 @@ extern "C" {
|
|||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__wasm__)
|
||||
#define LLHTTP_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LLHTTP_EXPORT
|
||||
#endif
|
||||
|
||||
typedef llhttp__internal_t llhttp_t;
|
||||
typedef struct llhttp_settings_s llhttp_settings_t;
|
||||
|
||||
|
@ -265,6 +327,7 @@ struct llhttp_settings_s {
|
|||
/* Possible return values 0, -1, `HPE_PAUSED` */
|
||||
llhttp_cb on_message_begin;
|
||||
|
||||
/* Possible return values 0, -1, HPE_USER */
|
||||
llhttp_data_cb on_url;
|
||||
llhttp_data_cb on_status;
|
||||
llhttp_data_cb on_header_field;
|
||||
|
@ -281,6 +344,7 @@ struct llhttp_settings_s {
|
|||
*/
|
||||
llhttp_cb on_headers_complete;
|
||||
|
||||
/* Possible return values 0, -1, HPE_USER */
|
||||
llhttp_data_cb on_body;
|
||||
|
||||
/* Possible return values 0, -1, `HPE_PAUSED` */
|
||||
|
@ -293,6 +357,7 @@ struct llhttp_settings_s {
|
|||
llhttp_cb on_chunk_header;
|
||||
llhttp_cb on_chunk_complete;
|
||||
|
||||
/* Information-only callbacks, return value is ignored */
|
||||
llhttp_cb on_url_complete;
|
||||
llhttp_cb on_status_complete;
|
||||
llhttp_cb on_header_field_complete;
|
||||
|
@ -305,15 +370,46 @@ struct llhttp_settings_s {
|
|||
* the `parser` here. In practice, `settings` has to be either a static
|
||||
* variable or be allocated with `malloc`, `new`, etc.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
||||
const llhttp_settings_t* settings);
|
||||
|
||||
#if defined(__wasm__)
|
||||
|
||||
LLHTTP_EXPORT
|
||||
llhttp_t* llhttp_alloc(llhttp_type_t type);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_free(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_type(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_major(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_minor(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_method(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_get_status_code(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_upgrade(llhttp_t* parser);
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
|
||||
/* Reset an already initialized parser back to the start state, preserving the
|
||||
* existing parser type, callback settings, user data, and lenient flags.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_reset(llhttp_t* parser);
|
||||
|
||||
/* Initialize the settings object */
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_settings_init(llhttp_settings_t* settings);
|
||||
|
||||
/* Parse full or partial request/response, invoking user callbacks along the
|
||||
|
@ -332,6 +428,7 @@ void llhttp_settings_init(llhttp_settings_t* settings);
|
|||
* to return the same error upon each successive call up until `llhttp_init()`
|
||||
* is called.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
||||
|
||||
/* This method should be called when the other side has no further bytes to
|
||||
|
@ -342,16 +439,19 @@ llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
|||
* connection. This method will invoke `on_message_complete()` callback if the
|
||||
* request was terminated safely. Otherwise a error code would be returned.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_finish(llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if the incoming message is parsed until the last byte, and has
|
||||
* to be completed by calling `llhttp_finish()` on EOF
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_message_needs_eof(const llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if there might be any other messages following the last that was
|
||||
* successfully parsed.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_should_keep_alive(const llhttp_t* parser);
|
||||
|
||||
/* Make further calls of `llhttp_execute()` return `HPE_PAUSED` and set
|
||||
|
@ -360,6 +460,7 @@ int llhttp_should_keep_alive(const llhttp_t* parser);
|
|||
* Important: do not call this from user callbacks! User callbacks must return
|
||||
* `HPE_PAUSED` if pausing is required.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_pause(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
|
@ -367,6 +468,7 @@ void llhttp_pause(llhttp_t* parser);
|
|||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED`.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
|
@ -374,9 +476,11 @@ void llhttp_resume(llhttp_t* parser);
|
|||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED_UPGRADE`
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume_after_upgrade(llhttp_t* parser);
|
||||
|
||||
/* Returns the latest return error */
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
||||
|
||||
/* Returns the verbal explanation of the latest returned error.
|
||||
|
@ -384,6 +488,7 @@ llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
|||
* Note: User callback should set error reason when returning the error. See
|
||||
* `llhttp_set_error_reason()` for details.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_reason(const llhttp_t* parser);
|
||||
|
||||
/* Assign verbal description to the returned error. Must be called in user
|
||||
|
@ -391,6 +496,7 @@ const char* llhttp_get_error_reason(const llhttp_t* parser);
|
|||
*
|
||||
* Note: `HPE_USER` error code might be useful in user callbacks.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
||||
|
||||
/* Returns the pointer to the last parsed byte before the returned error. The
|
||||
|
@ -398,12 +504,15 @@ void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
|||
*
|
||||
* Note: this method might be useful for counting the number of parsed bytes.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_pos(const llhttp_t* parser);
|
||||
|
||||
/* Returns textual name of error code */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_errno_name(llhttp_errno_t err);
|
||||
|
||||
/* Returns textual name of HTTP method */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_method_name(llhttp_method_t method);
|
||||
|
||||
|
||||
|
@ -416,6 +525,7 @@ const char* llhttp_method_name(llhttp_method_t method);
|
|||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
|
@ -429,8 +539,23 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
|||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
/* Enables/disables lenient handling of `Connection: close` and HTTP/1.0
|
||||
* requests responses.
|
||||
*
|
||||
* Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
|
||||
* the HTTP request/response after the request/response with `Connection: close`
|
||||
* and `Content-Length`. This is important to prevent cache poisoning attacks,
|
||||
* but might interact badly with outdated and insecure clients. With this flag
|
||||
* the extra request/response will be parsed normally.
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "llhttp.h"
|
||||
|
||||
#define CALLBACK_MAYBE(PARSER, NAME, ...) \
|
||||
#define CALLBACK_MAYBE(PARSER, NAME) \
|
||||
do { \
|
||||
const llhttp_settings_t* settings; \
|
||||
settings = (const llhttp_settings_t*) (PARSER)->settings; \
|
||||
|
@ -12,7 +12,22 @@
|
|||
err = 0; \
|
||||
break; \
|
||||
} \
|
||||
err = settings->NAME(__VA_ARGS__); \
|
||||
err = settings->NAME((PARSER)); \
|
||||
} while (0)
|
||||
|
||||
#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \
|
||||
do { \
|
||||
const llhttp_settings_t* settings; \
|
||||
settings = (const llhttp_settings_t*) (PARSER)->settings; \
|
||||
if (settings == NULL || settings->NAME == NULL) { \
|
||||
err = 0; \
|
||||
break; \
|
||||
} \
|
||||
err = settings->NAME((PARSER), (START), (LEN)); \
|
||||
if (err == -1) { \
|
||||
err = HPE_USER; \
|
||||
llhttp_set_error_reason((PARSER), "Span callback error in " #NAME); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
||||
|
@ -24,6 +39,70 @@ void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
|||
}
|
||||
|
||||
|
||||
#if defined(__wasm__)
|
||||
|
||||
extern int wasm_on_message_begin(llhttp_t * p);
|
||||
extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_header_value(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_headers_complete(llhttp_t * p);
|
||||
extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_message_complete(llhttp_t * p);
|
||||
|
||||
const llhttp_settings_t wasm_settings = {
|
||||
wasm_on_message_begin,
|
||||
wasm_on_url,
|
||||
wasm_on_status,
|
||||
wasm_on_header_field,
|
||||
wasm_on_header_value,
|
||||
wasm_on_headers_complete,
|
||||
wasm_on_body,
|
||||
wasm_on_message_complete,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
llhttp_t* llhttp_alloc(llhttp_type_t type) {
|
||||
llhttp_t* parser = malloc(sizeof(llhttp_t));
|
||||
llhttp_init(parser, type, &wasm_settings);
|
||||
return parser;
|
||||
}
|
||||
|
||||
void llhttp_free(llhttp_t* parser) {
|
||||
free(parser);
|
||||
}
|
||||
|
||||
/* Some getters required to get stuff from the parser */
|
||||
|
||||
uint8_t llhttp_get_type(llhttp_t* parser) {
|
||||
return parser->type;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_http_major(llhttp_t* parser) {
|
||||
return parser->http_major;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_http_minor(llhttp_t* parser) {
|
||||
return parser->http_minor;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_method(llhttp_t* parser) {
|
||||
return parser->method;
|
||||
}
|
||||
|
||||
int llhttp_get_status_code(llhttp_t* parser) {
|
||||
return parser->status_code;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_upgrade(llhttp_t* parser) {
|
||||
return parser->upgrade;
|
||||
}
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
|
||||
|
||||
void llhttp_reset(llhttp_t* parser) {
|
||||
llhttp_type_t type = parser->type;
|
||||
const llhttp_settings_t* settings = parser->settings;
|
||||
|
@ -59,7 +138,7 @@ llhttp_errno_t llhttp_finish(llhttp_t* parser) {
|
|||
|
||||
switch (parser->finish) {
|
||||
case HTTP_FINISH_SAFE_WITH_CB:
|
||||
CALLBACK_MAYBE(parser, on_message_complete, parser);
|
||||
CALLBACK_MAYBE(parser, on_message_complete);
|
||||
if (err != HPE_OK) return err;
|
||||
|
||||
/* FALLTHROUGH */
|
||||
|
@ -135,7 +214,7 @@ const char* llhttp_errno_name(llhttp_errno_t err) {
|
|||
const char* llhttp_method_name(llhttp_method_t method) {
|
||||
#define HTTP_METHOD_GEN(NUM, NAME, STRING) case HTTP_##NAME: return #STRING;
|
||||
switch (method) {
|
||||
HTTP_METHOD_MAP(HTTP_METHOD_GEN)
|
||||
HTTP_ALL_METHOD_MAP(HTTP_METHOD_GEN)
|
||||
default: abort();
|
||||
}
|
||||
#undef HTTP_METHOD_GEN
|
||||
|
@ -150,6 +229,7 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled) {
|
||||
if (enabled) {
|
||||
parser->lenient_flags |= LENIENT_CHUNKED_LENGTH;
|
||||
|
@ -159,103 +239,111 @@ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled) {
|
|||
}
|
||||
|
||||
|
||||
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
|
||||
if (enabled) {
|
||||
parser->lenient_flags |= LENIENT_KEEP_ALIVE;
|
||||
} else {
|
||||
parser->lenient_flags &= ~LENIENT_KEEP_ALIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Callbacks */
|
||||
|
||||
|
||||
int llhttp__on_message_begin(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_message_begin, s);
|
||||
CALLBACK_MAYBE(s, on_message_begin);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_url(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_url, s, p, endp - p);
|
||||
SPAN_CALLBACK_MAYBE(s, on_url, p, endp - p);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_url_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_url_complete, s);
|
||||
CALLBACK_MAYBE(s, on_url_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_status(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_status, s, p, endp - p);
|
||||
SPAN_CALLBACK_MAYBE(s, on_status, p, endp - p);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_status_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_status_complete, s);
|
||||
CALLBACK_MAYBE(s, on_status_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_header_field(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_header_field, s, p, endp - p);
|
||||
SPAN_CALLBACK_MAYBE(s, on_header_field, p, endp - p);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_header_field_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_header_field_complete, s);
|
||||
CALLBACK_MAYBE(s, on_header_field_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_header_value(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_header_value, s, p, endp - p);
|
||||
SPAN_CALLBACK_MAYBE(s, on_header_value, p, endp - p);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_header_value_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_header_value_complete, s);
|
||||
CALLBACK_MAYBE(s, on_header_value_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_headers_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_headers_complete, s);
|
||||
CALLBACK_MAYBE(s, on_headers_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_message_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_message_complete, s);
|
||||
CALLBACK_MAYBE(s, on_message_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_body(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_body, s, p, endp - p);
|
||||
SPAN_CALLBACK_MAYBE(s, on_body, p, endp - p);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_chunk_header(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_chunk_header, s);
|
||||
CALLBACK_MAYBE(s, on_chunk_header);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
||||
int err;
|
||||
CALLBACK_MAYBE(s, on_chunk_complete, s);
|
||||
CALLBACK_MAYBE(s, on_chunk_complete);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -627,6 +627,13 @@ int llhttp__internal__c_update_finish_1(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
return (state->lenient_flags & 4) == 4;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
|
@ -634,7 +641,7 @@ int llhttp__internal__c_test_flags_1(
|
|||
return (state->flags & 544) == 544;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
|
@ -802,7 +809,7 @@ int llhttp__internal__c_update_header_state_2(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
int llhttp__internal__c_test_lenient_flags_2(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
|
@ -1661,7 +1668,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2;
|
||||
}
|
||||
default: {
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_2;
|
||||
}
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
|
@ -5733,10 +5740,20 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
|
@ -6098,8 +6115,8 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
case 0:
|
||||
goto s_n_llhttp__internal__n_error_15;
|
||||
default:
|
||||
|
@ -6111,7 +6128,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
s_n_llhttp__internal__n_invoke_test_flags_1: {
|
||||
switch (llhttp__internal__c_test_flags_1(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete;
|
||||
}
|
||||
|
@ -6365,8 +6382,8 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_2: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_2(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_header_value_lenient;
|
||||
default:
|
||||
|
@ -6727,7 +6744,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_error_29: {
|
||||
state->error = 0x16;
|
||||
state->error = 0x17;
|
||||
state->reason = "Pause on PRI/Upgrade";
|
||||
state->error_pos = (const char*) p;
|
||||
state->_current = (void*) (intptr_t) s_error;
|
||||
|
@ -7906,6 +7923,7 @@ reset:
|
|||
|
||||
enum llparse_state_e {
|
||||
s_error,
|
||||
s_n_llhttp__internal__n_closed,
|
||||
s_n_llhttp__internal__n_invoke_llhttp__after_message_complete,
|
||||
s_n_llhttp__internal__n_pause_1,
|
||||
s_n_llhttp__internal__n_invoke_is_equal_upgrade,
|
||||
|
@ -8199,6 +8217,13 @@ int llhttp__internal__c_update_finish_1(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
return (state->lenient_flags & 4) == 4;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
|
@ -8206,7 +8231,7 @@ int llhttp__internal__c_test_flags_1(
|
|||
return (state->flags & 544) == 544;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
|
@ -8278,7 +8303,7 @@ int llhttp__internal__c_or_flags(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_update_finish_2(
|
||||
int llhttp__internal__c_update_finish_3(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
|
@ -8374,7 +8399,7 @@ int llhttp__internal__c_update_header_state_2(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
int llhttp__internal__c_test_lenient_flags_2(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
|
@ -8574,9 +8599,21 @@ static llparse_state_t llhttp__internal__run(
|
|||
const unsigned char* endp) {
|
||||
int match;
|
||||
switch ((llparse_state_t) (intptr_t) state->_current) {
|
||||
case s_n_llhttp__internal__n_closed:
|
||||
s_n_llhttp__internal__n_closed: {
|
||||
if (p == endp) {
|
||||
return s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
p++;
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
case s_n_llhttp__internal__n_invoke_llhttp__after_message_complete:
|
||||
s_n_llhttp__internal__n_invoke_llhttp__after_message_complete: {
|
||||
switch (llhttp__after_message_complete(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_1;
|
||||
}
|
||||
|
@ -9045,7 +9082,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
case 3:
|
||||
goto s_n_llhttp__internal__n_span_start_llhttp__on_body_1;
|
||||
case 4:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_3;
|
||||
case 5:
|
||||
goto s_n_llhttp__internal__n_error_10;
|
||||
default:
|
||||
|
@ -9184,7 +9221,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2;
|
||||
}
|
||||
default: {
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_2;
|
||||
}
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
|
@ -13077,7 +13114,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
s_n_llhttp__internal__n_invoke_update_finish_2: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_start;
|
||||
|
@ -13085,6 +13122,24 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_pause_5: {
|
||||
state->error = 0x15;
|
||||
state->reason = "on_message_complete pause";
|
||||
|
@ -13311,8 +13366,8 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_2: {
|
||||
switch (llhttp__internal__c_update_finish_2(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_update_finish_3: {
|
||||
switch (llhttp__internal__c_update_finish_3(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_span_start_llhttp__on_body_2;
|
||||
}
|
||||
|
@ -13424,8 +13479,8 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
case 0:
|
||||
goto s_n_llhttp__internal__n_error_11;
|
||||
default:
|
||||
|
@ -13437,7 +13492,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
s_n_llhttp__internal__n_invoke_test_flags_1: {
|
||||
switch (llhttp__internal__c_test_flags_1(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete;
|
||||
}
|
||||
|
@ -13673,8 +13728,8 @@ static llparse_state_t llhttp__internal__run(
|
|||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_2: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_2(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_header_value_lenient;
|
||||
default:
|
||||
|
@ -14035,7 +14090,7 @@ static llparse_state_t llhttp__internal__run(
|
|||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_error_23: {
|
||||
state->error = 0x16;
|
||||
state->error = 0x17;
|
||||
state->reason = "Pause on PRI/Upgrade";
|
||||
state->error_pos = (const char*) p;
|
||||
state->_current = (void*) (intptr_t) s_error;
|
||||
|
|
Loading…
Reference in New Issue