@@ -14824,6 +14824,7 @@ module.exports = {
14824
14824
kHost: Symbol('host'),
14825
14825
kNoRef: Symbol('no ref'),
14826
14826
kBodyUsed: Symbol('used'),
14827
+ kBody: Symbol('abstracted request body'),
14827
14828
kRunning: Symbol('running'),
14828
14829
kBlocking: Symbol('blocking'),
14829
14830
kPending: Symbol('pending'),
@@ -15039,19 +15040,72 @@ module.exports = {
15039
15040
15040
15041
15041
15042
const assert = __nccwpck_require__(8061)
15042
- const { kDestroyed, kBodyUsed, kListeners } = __nccwpck_require__(2785)
15043
+ const { kDestroyed, kBodyUsed, kListeners, kBody } = __nccwpck_require__(2785)
15043
15044
const { IncomingMessage } = __nccwpck_require__(8849)
15044
15045
const stream = __nccwpck_require__(4492)
15045
15046
const net = __nccwpck_require__(7503)
15046
- const { InvalidArgumentError } = __nccwpck_require__(8045)
15047
15047
const { Blob } = __nccwpck_require__(2254)
15048
15048
const nodeUtil = __nccwpck_require__(7261)
15049
15049
const { stringify } = __nccwpck_require__(9630)
15050
+ const { EventEmitter: EE } = __nccwpck_require__(5673)
15051
+ const { InvalidArgumentError } = __nccwpck_require__(8045)
15050
15052
const { headerNameLowerCasedRecord } = __nccwpck_require__(4462)
15051
15053
const { tree } = __nccwpck_require__(7506)
15052
15054
15053
15055
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v))
15054
15056
15057
+ class BodyAsyncIterable {
15058
+ constructor (body) {
15059
+ this[kBody] = body
15060
+ this[kBodyUsed] = false
15061
+ }
15062
+
15063
+ async * [Symbol.asyncIterator] () {
15064
+ assert(!this[kBodyUsed], 'disturbed')
15065
+ this[kBodyUsed] = true
15066
+ yield * this[kBody]
15067
+ }
15068
+ }
15069
+
15070
+ function wrapRequestBody (body) {
15071
+ if (isStream(body)) {
15072
+ // TODO (fix): Provide some way for the user to cache the file to e.g. /tmp
15073
+ // so that it can be dispatched again?
15074
+ // TODO (fix): Do we need 100-expect support to provide a way to do this properly?
15075
+ if (bodyLength(body) === 0) {
15076
+ body
15077
+ .on('data', function () {
15078
+ assert(false)
15079
+ })
15080
+ }
15081
+
15082
+ if (typeof body.readableDidRead !== 'boolean') {
15083
+ body[kBodyUsed] = false
15084
+ EE.prototype.on.call(body, 'data', function () {
15085
+ this[kBodyUsed] = true
15086
+ })
15087
+ }
15088
+
15089
+ return body
15090
+ } else if (body && typeof body.pipeTo === 'function') {
15091
+ // TODO (fix): We can't access ReadableStream internal state
15092
+ // to determine whether or not it has been disturbed. This is just
15093
+ // a workaround.
15094
+ return new BodyAsyncIterable(body)
15095
+ } else if (
15096
+ body &&
15097
+ typeof body !== 'string' &&
15098
+ !ArrayBuffer.isView(body) &&
15099
+ isIterable(body)
15100
+ ) {
15101
+ // TODO: Should we allow re-using iterable if !this.opts.idempotent
15102
+ // or through some other flag?
15103
+ return new BodyAsyncIterable(body)
15104
+ } else {
15105
+ return body
15106
+ }
15107
+ }
15108
+
15055
15109
function nop () {}
15056
15110
15057
15111
function isStream (obj) {
@@ -15672,7 +15726,8 @@ module.exports = {
15672
15726
isHttpOrHttpsPrefixed,
15673
15727
nodeMajor,
15674
15728
nodeMinor,
15675
- safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE']
15729
+ safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'],
15730
+ wrapRequestBody
15676
15731
}
15677
15732
15678
15733
@@ -20185,7 +20240,12 @@ const assert = __nccwpck_require__(8061)
20185
20240
20186
20241
const { kRetryHandlerDefaultRetry } = __nccwpck_require__(2785)
20187
20242
const { RequestRetryError } = __nccwpck_require__(8045)
20188
- const { isDisturbed, parseHeaders, parseRangeHeader } = __nccwpck_require__(3983)
20243
+ const {
20244
+ isDisturbed,
20245
+ parseHeaders,
20246
+ parseRangeHeader,
20247
+ wrapRequestBody
20248
+ } = __nccwpck_require__(3983)
20189
20249
20190
20250
function calculateRetryAfterHeader (retryAfter) {
20191
20251
const current = Date.now()
@@ -20211,7 +20271,7 @@ class RetryHandler {
20211
20271
20212
20272
this.dispatch = handlers.dispatch
20213
20273
this.handler = handlers.handler
20214
- this.opts = dispatchOpts
20274
+ this.opts = { ... dispatchOpts, body: wrapRequestBody(opts.body) }
20215
20275
this.abort = null
20216
20276
this.aborted = false
20217
20277
this.retryOpts = {
@@ -20356,7 +20416,9 @@ class RetryHandler {
20356
20416
this.abort(
20357
20417
new RequestRetryError('Request failed', statusCode, {
20358
20418
headers,
20359
- count: this.retryCount
20419
+ data: {
20420
+ count: this.retryCount
20421
+ }
20360
20422
})
20361
20423
)
20362
20424
return false
@@ -20460,7 +20522,7 @@ class RetryHandler {
20460
20522
20461
20523
const err = new RequestRetryError('Request failed', statusCode, {
20462
20524
headers,
20463
- count: this.retryCount
20525
+ data: { count: this.retryCount }
20464
20526
})
20465
20527
20466
20528
this.abort(err)
@@ -23349,7 +23411,7 @@ module.exports = {
23349
23411
23350
23412
23351
23413
const { parseSetCookie } = __nccwpck_require__(3903)
23352
- const { stringify, getHeadersList } = __nccwpck_require__(4806)
23414
+ const { stringify } = __nccwpck_require__(4806)
23353
23415
const { webidl } = __nccwpck_require__(4890)
23354
23416
const { Headers } = __nccwpck_require__(2991)
23355
23417
@@ -23426,14 +23488,13 @@ function getSetCookies (headers) {
23426
23488
23427
23489
webidl.brandCheck(headers, Headers, { strict: false })
23428
23490
23429
- const cookies = getHeadersList( headers).cookies
23491
+ const cookies = headers.getSetCookie()
23430
23492
23431
23493
if (!cookies) {
23432
23494
return []
23433
23495
}
23434
23496
23435
- // In older versions of undici, cookies is a list of name:value.
23436
- return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
23497
+ return cookies.map((pair) => parseSetCookie(pair))
23437
23498
}
23438
23499
23439
23500
/**
@@ -23861,14 +23922,11 @@ module.exports = {
23861
23922
/***/ }),
23862
23923
23863
23924
/***/ 4806:
23864
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__ ) => {
23925
+ /***/ ((module) => {
23865
23926
23866
23927
"use strict";
23867
23928
23868
23929
23869
- const assert = __nccwpck_require__(8061)
23870
- const { getHeadersList: internalGetHeadersList } = __nccwpck_require__(2991)
23871
-
23872
23930
/**
23873
23931
* @param {string} value
23874
23932
* @returns {boolean}
@@ -24141,37 +24199,13 @@ function stringify (cookie) {
24141
24199
return out.join('; ')
24142
24200
}
24143
24201
24144
- let kHeadersListNode
24145
-
24146
- function getHeadersList (headers) {
24147
- try {
24148
- return internalGetHeadersList(headers)
24149
- } catch {
24150
- // fall-through
24151
- }
24152
-
24153
- if (!kHeadersListNode) {
24154
- kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
24155
- (symbol) => symbol.description === 'headers list'
24156
- )
24157
-
24158
- assert(kHeadersListNode, 'Headers cannot be parsed')
24159
- }
24160
-
24161
- const headersList = headers[kHeadersListNode]
24162
- assert(headersList)
24163
-
24164
- return headersList
24165
- }
24166
-
24167
24202
module.exports = {
24168
24203
isCTLExcludingHtab,
24169
24204
validateCookieName,
24170
24205
validateCookiePath,
24171
24206
validateCookieValue,
24172
24207
toIMFDate,
24173
- stringify,
24174
- getHeadersList
24208
+ stringify
24175
24209
}
24176
24210
24177
24211
@@ -28112,14 +28146,6 @@ Object.defineProperties(Headers.prototype, {
28112
28146
},
28113
28147
[util.inspect.custom]: {
28114
28148
enumerable: false
28115
- },
28116
- // Compatibility for global headers
28117
- [Symbol('headers list')]: {
28118
- configurable: false,
28119
- enumerable: false,
28120
- get: function () {
28121
- return getHeadersList(this)
28122
- }
28123
28149
}
28124
28150
})
28125
28151
0 commit comments