@@ -13999,6 +13999,7 @@ module.exports = {
13999
13999
14000
14000
const assert = __nccwpck_require__(9491)
14001
14001
const net = __nccwpck_require__(1808)
14002
+ const http = __nccwpck_require__(3685)
14002
14003
const { pipeline } = __nccwpck_require__(2781)
14003
14004
const util = __nccwpck_require__(3983)
14004
14005
const timers = __nccwpck_require__(9459)
@@ -14086,6 +14087,7 @@ const {
14086
14087
HTTP2_HEADER_AUTHORITY,
14087
14088
HTTP2_HEADER_METHOD,
14088
14089
HTTP2_HEADER_PATH,
14090
+ HTTP2_HEADER_SCHEME,
14089
14091
HTTP2_HEADER_CONTENT_LENGTH,
14090
14092
HTTP2_HEADER_EXPECT,
14091
14093
HTTP2_HEADER_STATUS
@@ -14262,7 +14264,7 @@ class Client extends DispatcherBase {
14262
14264
this[kConnector] = connect
14263
14265
this[kSocket] = null
14264
14266
this[kPipelining] = pipelining != null ? pipelining : 1
14265
- this[kMaxHeadersSize] = maxHeaderSize || 16384
14267
+ this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize
14266
14268
this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout
14267
14269
this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 600e3 : keepAliveMaxTimeout
14268
14270
this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 1e3 : keepAliveTimeoutThreshold
@@ -15682,7 +15684,7 @@ function writeH2 (client, session, request) {
15682
15684
const h2State = client[kHTTP2SessionState]
15683
15685
15684
15686
headers[HTTP2_HEADER_AUTHORITY] = host || client[kHost]
15685
- headers[HTTP2_HEADER_PATH ] = path
15687
+ headers[HTTP2_HEADER_METHOD ] = method
15686
15688
15687
15689
if (method === 'CONNECT') {
15688
15690
session.ref()
@@ -15709,10 +15711,14 @@ function writeH2 (client, session, request) {
15709
15711
})
15710
15712
15711
15713
return true
15712
- } else {
15713
- headers[HTTP2_HEADER_METHOD] = method
15714
15714
}
15715
15715
15716
+ // https://tools.ietf.org/html/rfc7540#section-8.3
15717
+ // :path and :scheme headers must be omited when sending CONNECT
15718
+
15719
+ headers[HTTP2_HEADER_PATH] = path
15720
+ headers[HTTP2_HEADER_SCHEME] = 'https'
15721
+
15716
15722
// https://tools.ietf.org/html/rfc7231#section-4.3.1
15717
15723
// https://tools.ietf.org/html/rfc7231#section-4.3.2
15718
15724
// https://tools.ietf.org/html/rfc7231#section-4.3.5
@@ -15849,6 +15855,7 @@ function writeH2 (client, session, request) {
15849
15855
stream.cork()
15850
15856
stream.write(body)
15851
15857
stream.uncork()
15858
+ stream.end()
15852
15859
request.onBodySent(body)
15853
15860
request.onRequestSent()
15854
15861
} else if (util.isBlobLike(body)) {
@@ -16083,13 +16090,17 @@ async function writeIterable ({ h2stream, body, client, request, socket, content
16083
16090
throw socket[kError]
16084
16091
}
16085
16092
16086
- if (!h2stream.write(chunk)) {
16093
+ const res = h2stream.write(chunk)
16094
+ request.onBodySent(chunk)
16095
+ if (!res) {
16087
16096
await waitForDrain()
16088
16097
}
16089
16098
}
16090
16099
} catch (err) {
16091
16100
h2stream.destroy(err)
16092
16101
} finally {
16102
+ request.onRequestSent()
16103
+ h2stream.end()
16093
16104
h2stream
16094
16105
.off('close', onDrain)
16095
16106
.off('drain', onDrain)
@@ -16302,11 +16313,13 @@ class CompatFinalizer {
16302
16313
}
16303
16314
16304
16315
register (dispatcher, key) {
16305
- dispatcher.on('disconnect', () => {
16306
- if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) {
16307
- this.finalizer(key)
16308
- }
16309
- })
16316
+ if (dispatcher.on) {
16317
+ dispatcher.on('disconnect', () => {
16318
+ if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) {
16319
+ this.finalizer(key)
16320
+ }
16321
+ })
16322
+ }
16310
16323
}
16311
16324
}
16312
16325
@@ -17972,7 +17985,8 @@ function processHeader (request, key, val, skipAppend = false) {
17972
17985
key.toLowerCase() === 'content-type'
17973
17986
) {
17974
17987
request.contentType = val
17975
- request.headers += processHeaderValue(key, val)
17988
+ if (skipAppend) request.headers[key] = processHeaderValue(key, val, skipAppend)
17989
+ else request.headers += processHeaderValue(key, val)
17976
17990
} else if (
17977
17991
key.length === 17 &&
17978
17992
key.toLowerCase() === 'transfer-encoding'
@@ -22662,6 +22676,10 @@ async function httpRedirectFetch (fetchParams, response) {
22662
22676
if (!sameOrigin(requestCurrentURL(request), locationURL)) {
22663
22677
// https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name
22664
22678
request.headersList.delete('authorization')
22679
+
22680
+ // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement.
22681
+ request.headersList.delete('cookie')
22682
+ request.headersList.delete('host')
22665
22683
}
22666
22684
22667
22685
// 14. If request’s body is non-null, then set request’s body to the first return
@@ -22806,7 +22824,7 @@ async function httpNetworkOrCacheFetch (
22806
22824
// user agents should append `User-Agent`/default `User-Agent` value to
22807
22825
// httpRequest’s header list.
22808
22826
if (!httpRequest.headersList.contains('user-agent')) {
22809
- httpRequest.headersList.append('user-agent', ' undici')
22827
+ httpRequest.headersList.append('user-agent', typeof esbuildDetection === 'undefined' ? ' undici' : 'node ')
22810
22828
}
22811
22829
22812
22830
// 15. If httpRequest’s cache mode is "default" and httpRequest’s header
@@ -22868,6 +22886,8 @@ async function httpNetworkOrCacheFetch (
22868
22886
}
22869
22887
}
22870
22888
22889
+ httpRequest.headersList.delete('host')
22890
+
22871
22891
// 20. If includeCredentials is true, then:
22872
22892
if (includeCredentials) {
22873
22893
// 1. If the user agent is not configured to block cookies for httpRequest
0 commit comments