Skip to content

Commit 8f2bbf5

Browse files
committed
release: 8.1.2
1 parent 610a87d commit 8f2bbf5

File tree

6 files changed

+10095
-1806
lines changed

6 files changed

+10095
-1806
lines changed

CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.5.1)
22
cmake_policy(SET CMP0069 NEW)
33

4-
project(llhttp VERSION 9.2.1)
4+
project(llhttp VERSION 8.1.2)
55
include(GNUInstallDirs)
66

77
set(CMAKE_C_STANDARD 99)
@@ -47,9 +47,8 @@ configure_file(
4747
function(config_library target)
4848
target_sources(${target} PRIVATE ${LLHTTP_SOURCES} ${LLHTTP_HEADERS})
4949

50-
target_include_directories(${target} PUBLIC
51-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
52-
$<INSTALL_INTERFACE:include>
50+
target_include_directories(${target} PRIVATE
51+
${CMAKE_CURRENT_SOURCE_DIR}/include
5352
)
5453

5554
set_target_properties(${target} PROPERTIES
@@ -73,10 +72,9 @@ function(config_library target)
7372

7473
# This is required to work with FetchContent
7574
install(EXPORT llhttp
76-
FILE llhttp-config.cmake
77-
NAMESPACE llhttp::
78-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llhttp
79-
)
75+
FILE llhttp-config.cmake
76+
NAMESPACE llhttp::
77+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/llhttp)
8078
endfunction(config_library target)
8179

8280
if(BUILD_SHARED_LIBS)

README.md

Lines changed: 29 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,33 @@ checks could be performed to get even stricter verification of the llhttp.
6161
## Usage
6262

6363
```C
64-
#include "stdio.h"
6564
#include "llhttp.h"
66-
#include "string.h"
6765

68-
int handle_on_message_complete(llhttp_t* parser) {
69-
fprintf(stdout, "Message completed!\n");
70-
return 0;
71-
}
72-
73-
int main() {
74-
llhttp_t parser;
75-
llhttp_settings_t settings;
66+
llhttp_t parser;
67+
llhttp_settings_t settings;
7668

77-
/*Initialize user callbacks and settings */
78-
llhttp_settings_init(&settings);
69+
/* Initialize user callbacks and settings */
70+
llhttp_settings_init(&settings);
7971

80-
/*Set user callback */
81-
settings.on_message_complete = handle_on_message_complete;
72+
/* Set user callback */
73+
settings.on_message_complete = handle_on_message_complete;
8274

83-
/*Initialize the parser in HTTP_BOTH mode, meaning that it will select between
84-
*HTTP_REQUEST and HTTP_RESPONSE parsing automatically while reading the first
85-
*input.
86-
*/
87-
llhttp_init(&parser, HTTP_BOTH, &settings);
75+
/* Initialize the parser in HTTP_BOTH mode, meaning that it will select between
76+
* HTTP_REQUEST and HTTP_RESPONSE parsing automatically while reading the first
77+
* input.
78+
*/
79+
llhttp_init(&parser, HTTP_BOTH, &settings);
8880

89-
/*Parse request! */
90-
const char* request = "GET / HTTP/1.1\r\n\r\n";
91-
int request_len = strlen(request);
81+
/* Parse request! */
82+
const char* request = "GET / HTTP/1.1\r\n\r\n";
83+
int request_len = strlen(request);
9284

93-
enum llhttp_errno err = llhttp_execute(&parser, request, request_len);
94-
if (err == HPE_OK) {
95-
fprintf(stdout, "Successfully parsed!\n");
96-
} else {
97-
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason);
98-
}
85+
enum llhttp_errno err = llhttp_execute(&parser, request, request_len);
86+
if (err == HPE_OK) {
87+
/* Successfully parsed! */
88+
} else {
89+
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err),
90+
parser.reason);
9991
}
10092
```
10193
For more information on API usage, please refer to [src/native/api.h](https://github.com/nodejs/llhttp/blob/main/src/native/api.h).
@@ -287,7 +279,7 @@ protocol support to highly non-compliant clients/server.
287279
No `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
288280
lenient parsing is "on".
289281
290-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
282+
**USE AT YOUR OWN RISK!**
291283
292284
### `void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled)`
293285
@@ -300,22 +292,23 @@ conjunction with `Content-Length`.
300292
This error is important to prevent HTTP request smuggling, but may be less desirable
301293
for small number of cases involving legacy servers.
302294
303-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
295+
**USE AT YOUR OWN RISK!**
304296
305297
### `void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled)`
306298
307299
Enables/disables lenient handling of `Connection: close` and HTTP/1.0
308300
requests responses.
309301
310-
Normally `llhttp` would error the HTTP request/response
311-
after the request/response with `Connection: close` and `Content-Length`.
302+
Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
303+
the HTTP request/response after the request/response with `Connection: close`
304+
and `Content-Length`.
312305
313306
This is important to prevent cache poisoning attacks,
314307
but might interact badly with outdated and insecure clients.
315308
316309
With this flag the extra request/response will be parsed normally.
317310
318-
**Enabling this flag can pose a security issue since you will be exposed to poisoning attacks. USE WITH CAUTION!**
311+
**USE AT YOUR OWN RISK!**
319312
320313
### `void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled)`
321314
@@ -330,74 +323,14 @@ avoid request smuggling.
330323
331324
With this flag the extra value will be parsed normally.
332325
333-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
334-
335-
### `void llhttp_set_lenient_version(llhttp_t* parser, int enabled)`
336-
337-
Enables/disables lenient handling of HTTP version.
338-
339-
Normally `llhttp` would error when the HTTP version in the request or status line
340-
is not `0.9`, `1.0`, `1.1` or `2.0`.
341-
With this flag the extra value will be parsed normally.
342-
343-
**Enabling this flag can pose a security issue since you will allow unsupported HTTP versions. USE WITH CAUTION!**
344-
345-
### `void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled)`
346-
347-
Enables/disables lenient handling of additional data received after a message ends
348-
and keep-alive is disabled.
349-
350-
Normally `llhttp` would error when additional unexpected data is received if the message
351-
contains the `Connection` header with `close` value.
352-
With this flag the extra data will discarded without throwing an error.
353-
354-
**Enabling this flag can pose a security issue since you will be exposed to poisoning attacks. USE WITH CAUTION!**
355-
356-
### `void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled)`
357-
358-
Enables/disables lenient handling of incomplete CRLF sequences.
359-
360-
Normally `llhttp` would error when a CR is not followed by LF when terminating the
361-
request line, the status line, the headers or a chunk header.
362-
With this flag only a CR is required to terminate such sections.
363-
364-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
365-
366-
### `void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)`
367-
368-
Enables/disables lenient handling of line separators.
369-
370-
Normally `llhttp` would error when a LF is not preceded by CR when terminating the
371-
request line, the status line, the headers, a chunk header or a chunk data.
372-
With this flag only a LF is required to terminate such sections.
373-
374-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
375-
376-
### `void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled)`
377-
378-
Enables/disables lenient handling of chunks not separated via CRLF.
379-
380-
Normally `llhttp` would error when after a chunk data a CRLF is missing before
381-
starting a new chunk.
382-
With this flag the new chunk can start immediately after the previous one.
383-
384-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
385-
386-
### `void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)`
387-
388-
Enables/disables lenient handling of spaces after chunk size.
389-
390-
Normally `llhttp` would error when after a chunk size is followed by one or more spaces are present instead of a CRLF or `;`.
391-
With this flag this check is disabled.
392-
393-
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
326+
**USE AT YOUR OWN RISK!**
394327
395328
## Build Instructions
396329
397330
Make sure you have [Node.js](https://nodejs.org/), npm and npx installed. Then under project directory run:
398331
399332
```sh
400-
npm ci
333+
npm install
401334
make
402335
```
403336

@@ -451,7 +384,7 @@ _Note that using the git repo directly (e.g., via a git repo url and tag) will n
451384

452385
1. Ensure that `Clang` and `make` are in your system path.
453386
2. Using Git Bash, clone the repo to your preferred location.
454-
3. Cd into the cloned directory and run `npm ci`
387+
3. Cd into the cloned directory and run `npm install`
455388
5. Run `make`
456389
6. Your `repo/build` directory should now have `libllhttp.a` and `libllhttp.so` static and dynamic libraries.
457390
7. When building your executable, you can link to these libraries. Make sure to set the build folder as an include path when building so you can reference the declarations in `repo/build/llhttp.h`.

0 commit comments

Comments
 (0)