Skip to content

Commit

Permalink
deps: update llhttp to 6.0.1
Browse files Browse the repository at this point in the history
PR-URL: nodejs#38359
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
  • Loading branch information
indutny authored and Trott committed Apr 25, 2021
1 parent 6891042 commit 8a973fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
6 changes: 4 additions & 2 deletions deps/llhttp/include/llhttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define LLHTTP_VERSION_MAJOR 6
#define LLHTTP_VERSION_MINOR 0
#define LLHTTP_VERSION_PATCH 0
#define LLHTTP_VERSION_PATCH 1

#ifndef LLHTTP_STRICT_MODE
# define LLHTTP_STRICT_MODE 0
Expand Down Expand Up @@ -231,7 +231,6 @@ typedef enum llhttp_method llhttp_method_t;
XX(31, LINK, LINK) \
XX(32, UNLINK, UNLINK) \
XX(33, SOURCE, SOURCE) \
XX(34, PRI, PRI) \


#define RTSP_METHOD_MAP(XX) \
Expand Down Expand Up @@ -328,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;
Expand All @@ -344,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` */
Expand All @@ -356,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;
Expand Down
49 changes: 32 additions & 17 deletions deps/llhttp/src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@

#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; \
if (settings == NULL || settings->NAME == NULL) { \
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,
Expand Down Expand Up @@ -123,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 */
Expand Down Expand Up @@ -237,98 +252,98 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {

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;
}

Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-http-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const methods = [
'OPTIONS',
'PATCH',
'POST',
'PRI',
'PROPFIND',
'PROPPATCH',
'PURGE',
Expand Down

0 comments on commit 8a973fd

Please sign in to comment.