bdy 1.25.42-stage → 1.25.43-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distTs/package.json +1 -1
- package/distTs/src/tunnel/http.js +19 -0
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -150,6 +150,23 @@ class TunnelHttp extends events_1.default {
|
|
|
150
150
|
return this.req.headers[':authority'];
|
|
151
151
|
return 'localhost';
|
|
152
152
|
}
|
|
153
|
+
// Framing for the request body on an h1 request to the target. getClearedHeaders strips
|
|
154
|
+
// transfer-encoding (hop-by-hop), and node re-adds chunked framing only where
|
|
155
|
+
// useChunkedEncodingByDefault is true, which _http_client.js sets FALSE for GET, HEAD, DELETE,
|
|
156
|
+
// OPTIONS, TRACE and CONNECT. So a DELETE with a body and no content-length went to the target with
|
|
157
|
+
// no framing header at all and the body bytes after it: the target read a bodyless DELETE and parsed
|
|
158
|
+
// the body as the next request (HPE_INVALID_METHOD). Same bug the worker fixed on its pooled h1
|
|
159
|
+
// channel (PIPE_HTTP1_HOP_HEADERS). An h2 request never carries transfer-encoding, so there the body
|
|
160
|
+
// is known from the stream: endAfterHeaders is true only when HEADERS came with END_STREAM.
|
|
161
|
+
getBodyFramingHeaders() {
|
|
162
|
+
const headers = this.req.headers || {};
|
|
163
|
+
if (headers['content-length'] !== undefined)
|
|
164
|
+
return {};
|
|
165
|
+
const hasBody = this.req.stream
|
|
166
|
+
? !this.req.stream.endAfterHeaders
|
|
167
|
+
: headers['transfer-encoding'] !== undefined;
|
|
168
|
+
return hasBody ? { 'transfer-encoding': 'chunked' } : {};
|
|
169
|
+
}
|
|
153
170
|
getRequestHeaders(http2) {
|
|
154
171
|
const h = {};
|
|
155
172
|
const ip = (0, ip_1.requestIp)(this.req);
|
|
@@ -246,6 +263,7 @@ class TunnelHttp extends events_1.default {
|
|
|
246
263
|
...this.getClearedHeaders(reqHeaders, null, true),
|
|
247
264
|
...this.headers,
|
|
248
265
|
...this.getRequestHeaders(false),
|
|
266
|
+
...this.getBodyFramingHeaders(),
|
|
249
267
|
};
|
|
250
268
|
const r = http_1.default.request({
|
|
251
269
|
agent: agent_1.default.getHttp1(),
|
|
@@ -291,6 +309,7 @@ class TunnelHttp extends events_1.default {
|
|
|
291
309
|
...this.getClearedHeaders(reqHeaders, null, true),
|
|
292
310
|
...this.headers,
|
|
293
311
|
...this.getRequestHeaders(false),
|
|
312
|
+
...this.getBodyFramingHeaders(),
|
|
294
313
|
};
|
|
295
314
|
const path = this.getPath();
|
|
296
315
|
const r = https_1.default.request({
|