Skip to content

Commit 6516196

Browse files
authored
Merge branch 'nodejs:main' into fix_1565
2 parents 32b0ae7 + 76f6627 commit 6516196

40 files changed

+1995
-760
lines changed

.github/workflows/lint-pr.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
post-test-steps: |
1818
- name: Coverage Report
1919
uses: codecov/codecov-action@v2
20+
include: |
21+
- runs-on: ubuntu-latest
22+
node-version: 16.8
23+
exclude: |
24+
- runs-on: windows-latest
25+
node-version: 16
2026
automerge:
2127
if: >
2228
github.event_name == 'pull_request' &&

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Implements [fetch](https://fetch.spec.whatwg.org/#fetch-method).
176176
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
177177
* https://fetch.spec.whatwg.org/#fetch-method
178178

179-
Only supported on Node 16.5+.
179+
Only supported on Node 16.8+.
180180

181181
This is [experimental](https://nodejs.org/api/documentation.html#documentation_stability_index) and is not yet fully compliant with the Fetch Standard.
182182
We plan to ship breaking changes to this feature until it is out of experimental.

deps/llhttp/include/llhttp.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#define LLHTTP_VERSION_MAJOR 6
55
#define LLHTTP_VERSION_MINOR 0
6-
#define LLHTTP_VERSION_PATCH 6
6+
#define LLHTTP_VERSION_PATCH 7
77

88
#ifndef LLHTTP_STRICT_MODE
99
# define LLHTTP_STRICT_MODE 0
@@ -59,6 +59,7 @@ enum llhttp_errno {
5959
HPE_OK = 0,
6060
HPE_INTERNAL = 1,
6161
HPE_STRICT = 2,
62+
HPE_CR_EXPECTED = 25,
6263
HPE_LF_EXPECTED = 3,
6364
HPE_UNEXPECTED_CONTENT_LENGTH = 4,
6465
HPE_CLOSED_CONNECTION = 5,
@@ -100,7 +101,8 @@ typedef enum llhttp_flags llhttp_flags_t;
100101
enum llhttp_lenient_flags {
101102
LENIENT_HEADERS = 0x1,
102103
LENIENT_CHUNKED_LENGTH = 0x2,
103-
LENIENT_KEEP_ALIVE = 0x4
104+
LENIENT_KEEP_ALIVE = 0x4,
105+
LENIENT_TRANSFER_ENCODING = 0x8
104106
};
105107
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
106108

@@ -172,6 +174,7 @@ typedef enum llhttp_method llhttp_method_t;
172174
XX(0, OK, OK) \
173175
XX(1, INTERNAL, INTERNAL) \
174176
XX(2, STRICT, STRICT) \
177+
XX(25, CR_EXPECTED, CR_EXPECTED) \
175178
XX(3, LF_EXPECTED, LF_EXPECTED) \
176179
XX(4, UNEXPECTED_CONTENT_LENGTH, UNEXPECTED_CONTENT_LENGTH) \
177180
XX(5, CLOSED_CONNECTION, CLOSED_CONNECTION) \
@@ -374,8 +377,6 @@ LLHTTP_EXPORT
374377
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
375378
const llhttp_settings_t* settings);
376379

377-
#if defined(__wasm__)
378-
379380
LLHTTP_EXPORT
380381
llhttp_t* llhttp_alloc(llhttp_type_t type);
381382

@@ -400,8 +401,6 @@ int llhttp_get_status_code(llhttp_t* parser);
400401
LLHTTP_EXPORT
401402
uint8_t llhttp_get_upgrade(llhttp_t* parser);
402403

403-
#endif // defined(__wasm__)
404-
405404
/* Reset an already initialized parser back to the start state, preserving the
406405
* existing parser type, callback settings, user data, and lenient flags.
407406
*/
@@ -556,6 +555,19 @@ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
556555
*/
557556
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
558557

558+
/* Enables/disables lenient handling of `Transfer-Encoding` header.
559+
*
560+
* Normally `llhttp` would error when a `Transfer-Encoding` has `chunked` value
561+
* and another value after it (either in a single header or in multiple
562+
* headers whose value are internally joined using `, `).
563+
* This is mandated by the spec to reliably determine request body size and thus
564+
* avoid request smuggling.
565+
* With this flag the extra value will be parsed normally.
566+
*
567+
* **(USE AT YOUR OWN RISK)**
568+
*/
569+
void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled);
570+
559571
#ifdef __cplusplus
560572
} /* extern "C" */
561573
#endif

deps/llhttp/src/api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
253253
}
254254
}
255255

256+
void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled) {
257+
if (enabled) {
258+
parser->lenient_flags |= LENIENT_TRANSFER_ENCODING;
259+
} else {
260+
parser->lenient_flags &= ~LENIENT_TRANSFER_ENCODING;
261+
}
262+
}
263+
256264
/* Callbacks */
257265

258266

deps/llhttp/src/http.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ int llhttp__after_headers_complete(llhttp_t* parser, const char* p,
5252
return 2;
5353
} else if (parser->flags & F_TRANSFER_ENCODING) {
5454
if (parser->type == HTTP_REQUEST &&
55-
(parser->lenient_flags & LENIENT_CHUNKED_LENGTH) == 0) {
55+
(parser->lenient_flags & LENIENT_CHUNKED_LENGTH) == 0 &&
56+
(parser->lenient_flags & LENIENT_TRANSFER_ENCODING) == 0) {
5657
/* RFC 7230 3.3.3 */
5758

5859
/* If a Transfer-Encoding header field

0 commit comments

Comments
 (0)