| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 04c8f59 commit d49fd29
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | - cmake_minimum_required(VERSION 3.5.1) | ||
| 1 | + cmake_minimum_required(VERSION 3.25.0) | ||
| 2 | 2 | cmake_policy(SET CMP0069 NEW) | |
| 3 | 3 | ||
| 4 | - project(llhttp VERSION 9.2.1) | ||
| 4 | + project(llhttp VERSION 9.3.0) | ||
| 5 | 5 | include(GNUInstallDirs) | |
| 6 | 6 | ||
| 7 | 7 | set(CMAKE_C_STANDARD 99) | |
@@ -49,7 +49,7 @@ function(config_library target) | |||
| 49 | 49 | ||
| 50 | 50 | target_include_directories(${target} PUBLIC | |
| 51 | 51 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | |
| 52 | - $<INSTALL_INTERFACE:include> | ||
| 52 | + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| 53 | 53 | ) | |
| 54 | 54 | ||
| 55 | 55 | set_target_properties(${target} PROPERTIES | |
@@ -61,6 +61,7 @@ function(config_library target) | |||
| 61 | 61 | ||
| 62 | 62 | install(TARGETS ${target} | |
| 63 | 63 | EXPORT llhttp | |
| 64 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| 64 | 65 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | |
| 65 | 66 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | |
| 66 | 67 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + This software is licensed under the MIT License. | ||
| 2 | + | ||
| 3 | + Copyright Fedor Indutny, 2018. | ||
| 4 | + | ||
| 5 | + Permission is hereby granted, free of charge, to any person obtaining a | ||
| 6 | + copy of this software and associated documentation files (the | ||
| 7 | + "Software"), to deal in the Software without restriction, including | ||
| 8 | + without limitation the rights to use, copy, modify, merge, publish, | ||
| 9 | + distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 10 | + persons to whom the Software is furnished to do so, subject to the | ||
| 11 | + following conditions: | ||
| 12 | + | ||
| 13 | + The above copyright notice and this permission notice shall be included | ||
| 14 | + in all copies or substantial portions of the Software. | ||
| 15 | + | ||
| 16 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| 17 | + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 18 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 19 | + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 20 | + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 21 | + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 22 | + USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,7 +94,7 @@ int main() { | |||
| 94 | 94 | if (err == HPE_OK) { | |
| 95 | 95 | fprintf(stdout, "Successfully parsed!\n"); | |
| 96 | 96 | } else { | |
| 97 | - fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason); | ||
| 97 | + fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), llhttp_get_error_reason(&parser)); | ||
| 98 | 98 | } | |
| 99 | 99 | } | |
| 100 | 100 | ``` | |
@@ -112,6 +112,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_ | |||
| 112 | 112 | * `on_message_complete`: Invoked when a request/response has been completedly parsed. | |
| 113 | 113 | * `on_url_complete`: Invoked after the URL has been parsed. | |
| 114 | 114 | * `on_method_complete`: Invoked after the HTTP method has been parsed. | |
| 115 | + * `on_protocol_complete`: Invoked after the HTTP version has been parsed. | ||
| 115 | 116 | * `on_version_complete`: Invoked after the HTTP version has been parsed. | |
| 116 | 117 | * `on_status_complete`: Invoked after the status code has been parsed. | |
| 117 | 118 | * `on_header_field_complete`: Invoked after a header name has been parsed. | |
@@ -130,6 +131,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_ | |||
| 130 | 131 | * `on_method`: Invoked when another character of the method is received. | |
| 131 | 132 | When parser is created with `HTTP_BOTH` and the input is a response, this also invoked for the sequence `HTTP/` | |
| 132 | 133 | of the first message. | |
| 134 | + * `on_protocol`: Invoked when another character of the protocol is received. | ||
| 133 | 135 | * `on_version`: Invoked when another character of the version is received. | |
| 134 | 136 | * `on_header_field`: Invoked when another character of a header name is received. | |
| 135 | 137 | * `on_header_value`: Invoked when another character of a header value is received. | |
@@ -187,7 +189,8 @@ Parse full or partial request/response, invoking user callbacks along the way. | |||
| 187 | 189 | ||
| 188 | 190 | If any of `llhttp_data_cb` returns errno not equal to `HPE_OK` - the parsing interrupts, | |
| 189 | 191 | and such errno is returned from `llhttp_execute()`. If `HPE_PAUSED` was used as a errno, | |
| 190 | - the execution can be resumed with `llhttp_resume()` call. | ||
| 192 | + the execution can be resumed with `llhttp_resume()` call. In that case the input should be advanced | ||
| 193 | + to the last processed byte from the parser, which can be obtained via `llhttp_get_error_pos()`. | ||
| 191 | 194 | ||
| 192 | 195 | In a special case of CONNECT/Upgrade request/response `HPE_PAUSED_UPGRADE` is returned | |
| 193 | 196 | after fully parsing the request/response. If the user wishes to continue parsing, | |
@@ -196,6 +199,8 @@ they need to invoke `llhttp_resume_after_upgrade()`. | |||
| 196 | 199 | **if this function ever returns a non-pause type error, it will continue to return | |
| 197 | 200 | the same error upon each successive call up until `llhttp_init()` is called.** | |
| 198 | 201 | ||
| 202 | + If this function returns `HPE_OK`, it means all the input has been consumed and parsed. | ||
| 203 | + | ||
| 199 | 204 | ### `llhttp_errno_t llhttp_finish(llhttp_t* parser)` | |
| 200 | 205 | ||
| 201 | 206 | This method should be called when the other side has no further bytes to | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,8 @@ | |||
| 3 | 3 | #define INCLUDE_LLHTTP_H_ | |
| 4 | 4 | ||
| 5 | 5 | #define LLHTTP_VERSION_MAJOR 9 | |
| 6 | - #define LLHTTP_VERSION_MINOR 2 | ||
| 7 | - #define LLHTTP_VERSION_PATCH 1 | ||
| 6 | + #define LLHTTP_VERSION_MINOR 3 | ||
| 7 | + #define LLHTTP_VERSION_PATCH 0 | ||
| 8 | 8 | ||
| 9 | 9 | #ifndef INCLUDE_LLHTTP_ITSELF_H_ | |
| 10 | 10 | #define INCLUDE_LLHTTP_ITSELF_H_ | |
@@ -90,7 +90,8 @@ enum llhttp_errno { | |||
| 90 | 90 | HPE_CB_HEADER_VALUE_COMPLETE = 29, | |
| 91 | 91 | HPE_CB_CHUNK_EXTENSION_NAME_COMPLETE = 34, | |
| 92 | 92 | HPE_CB_CHUNK_EXTENSION_VALUE_COMPLETE = 35, | |
| 93 | - HPE_CB_RESET = 31 | ||
| 93 | + HPE_CB_RESET = 31, | ||
| 94 | + HPE_CB_PROTOCOL_COMPLETE = 38 | ||
| 94 | 95 | }; | |
| 95 | 96 | typedef enum llhttp_errno llhttp_errno_t; | |
| 96 | 97 | ||
@@ -326,6 +327,7 @@ typedef enum llhttp_status llhttp_status_t; | |||
| 326 | 327 | XX(34, CB_CHUNK_EXTENSION_NAME_COMPLETE, CB_CHUNK_EXTENSION_NAME_COMPLETE) \ | |
| 327 | 328 | XX(35, CB_CHUNK_EXTENSION_VALUE_COMPLETE, CB_CHUNK_EXTENSION_VALUE_COMPLETE) \ | |
| 328 | 329 | XX(31, CB_RESET, CB_RESET) \ | |
| 330 | + XX(38, CB_PROTOCOL_COMPLETE, CB_PROTOCOL_COMPLETE) \ | ||
| 329 | 331 | ||
| 330 | 332 | ||
| 331 | 333 | #define HTTP_METHOD_MAP(XX) \ | |
@@ -567,6 +569,7 @@ struct llhttp_settings_s { | |||
| 567 | 569 | llhttp_cb on_message_begin; | |
| 568 | 570 | ||
| 569 | 571 | /* Possible return values 0, -1, HPE_USER */ | |
| 572 | + llhttp_data_cb on_protocol; | ||
| 570 | 573 | llhttp_data_cb on_url; | |
| 571 | 574 | llhttp_data_cb on_status; | |
| 572 | 575 | llhttp_data_cb on_method; | |
@@ -592,6 +595,7 @@ struct llhttp_settings_s { | |||
| 592 | 595 | ||
| 593 | 596 | /* Possible return values 0, -1, `HPE_PAUSED` */ | |
| 594 | 597 | llhttp_cb on_message_complete; | |
| 598 | + llhttp_cb on_protocol_complete; | ||
| 595 | 599 | llhttp_cb on_url_complete; | |
| 596 | 600 | llhttp_cb on_status_complete; | |
| 597 | 601 | llhttp_cb on_method_complete; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,10 @@ | |||
| 1 | 1 | prefix=@CMAKE_INSTALL_PREFIX@ | |
| 2 | - exec_prefix=@CMAKE_INSTALL_PREFIX@ | ||
| 3 | - libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ | ||
| 4 | - includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@ | ||
| 2 | + exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ | ||
| 3 | + libdir=@CMAKE_INSTALL_FULL_LIBDIR@ | ||
| 4 | + includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ | ||
| 5 | 5 | ||
| 6 | 6 | Name: libllhttp | |
| 7 | 7 | Description: Node.js llhttp Library | |
| 8 | 8 | Version: @PROJECT_VERSION@ | |
| 9 | 9 | Libs: -L${libdir} -lllhttp | |
| 10 | - Cflags: -I${includedir} | ||
| 10 | + Cflags: -I${includedir} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,29 +57,14 @@ static int wasm_on_headers_complete_wrap(llhttp_t* p) { | |||
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | 59 | const llhttp_settings_t wasm_settings = { | |
| 60 | - wasm_on_message_begin, | ||
| 61 | - wasm_on_url, | ||
| 62 | - wasm_on_status, | ||
| 63 | - NULL, | ||
| 64 | - NULL, | ||
| 65 | - wasm_on_header_field, | ||
| 66 | - wasm_on_header_value, | ||
| 67 | - NULL, | ||
| 68 | - NULL, | ||
| 69 | - wasm_on_headers_complete_wrap, | ||
| 70 | - wasm_on_body, | ||
| 71 | - wasm_on_message_complete, | ||
| 72 | - NULL, | ||
| 73 | - NULL, | ||
| 74 | - NULL, | ||
| 75 | - NULL, | ||
| 76 | - NULL, | ||
| 77 | - NULL, | ||
| 78 | - NULL, | ||
| 79 | - NULL, | ||
| 80 | - NULL, | ||
| 81 | - NULL, | ||
| 82 | - NULL, | ||
| 60 | + .on_message_begin = wasm_on_message_begin, | ||
| 61 | + .on_url = wasm_on_url, | ||
| 62 | + .on_status = wasm_on_status, | ||
| 63 | + .on_header_field = wasm_on_header_field, | ||
| 64 | + .on_header_value = wasm_on_header_value, | ||
| 65 | + .on_headers_complete = wasm_on_headers_complete_wrap, | ||
| 66 | + .on_body = wasm_on_body, | ||
| 67 | + .on_message_complete = wasm_on_message_complete, | ||
| 83 | 68 | }; | |
| 84 | 69 | ||
| 85 | 70 | ||
@@ -341,6 +326,20 @@ int llhttp__on_message_begin(llhttp_t* s, const char* p, const char* endp) { | |||
| 341 | 326 | } | |
| 342 | 327 | ||
| 343 | 328 | ||
| 329 | + int llhttp__on_protocol(llhttp_t* s, const char* p, const char* endp) { | ||
| 330 | + int err; | ||
| 331 | + SPAN_CALLBACK_MAYBE(s, on_protocol, p, endp - p); | ||
| 332 | + return err; | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + | ||
| 336 | + int llhttp__on_protocol_complete(llhttp_t* s, const char* p, const char* endp) { | ||
| 337 | + int err; | ||
| 338 | + CALLBACK_MAYBE(s, on_protocol_complete); | ||
| 339 | + return err; | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + | ||
| 344 | 343 | int llhttp__on_url(llhttp_t* s, const char* p, const char* endp) { | |
| 345 | 344 | int err; | |
| 346 | 345 | SPAN_CALLBACK_MAYBE(s, on_url, p, endp - p); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments