Skip to content

Commit e30bbbb

Browse files
authored
build: update distribution (#2947)
1 parent bad19b8 commit e30bbbb

File tree

1 file changed

+74
-48
lines changed

1 file changed

+74
-48
lines changed

dist/index.js

+74-48
Original file line numberDiff line numberDiff line change
@@ -14824,6 +14824,7 @@ module.exports = {
1482414824
kHost: Symbol('host'),
1482514825
kNoRef: Symbol('no ref'),
1482614826
kBodyUsed: Symbol('used'),
14827+
kBody: Symbol('abstracted request body'),
1482714828
kRunning: Symbol('running'),
1482814829
kBlocking: Symbol('blocking'),
1482914830
kPending: Symbol('pending'),
@@ -15039,19 +15040,72 @@ module.exports = {
1503915040

1504015041

1504115042
const assert = __nccwpck_require__(8061)
15042-
const { kDestroyed, kBodyUsed, kListeners } = __nccwpck_require__(2785)
15043+
const { kDestroyed, kBodyUsed, kListeners, kBody } = __nccwpck_require__(2785)
1504315044
const { IncomingMessage } = __nccwpck_require__(8849)
1504415045
const stream = __nccwpck_require__(4492)
1504515046
const net = __nccwpck_require__(7503)
15046-
const { InvalidArgumentError } = __nccwpck_require__(8045)
1504715047
const { Blob } = __nccwpck_require__(2254)
1504815048
const nodeUtil = __nccwpck_require__(7261)
1504915049
const { stringify } = __nccwpck_require__(9630)
15050+
const { EventEmitter: EE } = __nccwpck_require__(5673)
15051+
const { InvalidArgumentError } = __nccwpck_require__(8045)
1505015052
const { headerNameLowerCasedRecord } = __nccwpck_require__(4462)
1505115053
const { tree } = __nccwpck_require__(7506)
1505215054

1505315055
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v))
1505415056

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+
1505515109
function nop () {}
1505615110

1505715111
function isStream (obj) {
@@ -15672,7 +15726,8 @@ module.exports = {
1567215726
isHttpOrHttpsPrefixed,
1567315727
nodeMajor,
1567415728
nodeMinor,
15675-
safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE']
15729+
safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'],
15730+
wrapRequestBody
1567615731
}
1567715732

1567815733

@@ -20185,7 +20240,12 @@ const assert = __nccwpck_require__(8061)
2018520240

2018620241
const { kRetryHandlerDefaultRetry } = __nccwpck_require__(2785)
2018720242
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)
2018920249

2019020250
function calculateRetryAfterHeader (retryAfter) {
2019120251
const current = Date.now()
@@ -20211,7 +20271,7 @@ class RetryHandler {
2021120271

2021220272
this.dispatch = handlers.dispatch
2021320273
this.handler = handlers.handler
20214-
this.opts = dispatchOpts
20274+
this.opts = { ...dispatchOpts, body: wrapRequestBody(opts.body) }
2021520275
this.abort = null
2021620276
this.aborted = false
2021720277
this.retryOpts = {
@@ -20356,7 +20416,9 @@ class RetryHandler {
2035620416
this.abort(
2035720417
new RequestRetryError('Request failed', statusCode, {
2035820418
headers,
20359-
count: this.retryCount
20419+
data: {
20420+
count: this.retryCount
20421+
}
2036020422
})
2036120423
)
2036220424
return false
@@ -20460,7 +20522,7 @@ class RetryHandler {
2046020522

2046120523
const err = new RequestRetryError('Request failed', statusCode, {
2046220524
headers,
20463-
count: this.retryCount
20525+
data: { count: this.retryCount }
2046420526
})
2046520527

2046620528
this.abort(err)
@@ -23349,7 +23411,7 @@ module.exports = {
2334923411

2335023412

2335123413
const { parseSetCookie } = __nccwpck_require__(3903)
23352-
const { stringify, getHeadersList } = __nccwpck_require__(4806)
23414+
const { stringify } = __nccwpck_require__(4806)
2335323415
const { webidl } = __nccwpck_require__(4890)
2335423416
const { Headers } = __nccwpck_require__(2991)
2335523417

@@ -23426,14 +23488,13 @@ function getSetCookies (headers) {
2342623488

2342723489
webidl.brandCheck(headers, Headers, { strict: false })
2342823490

23429-
const cookies = getHeadersList(headers).cookies
23491+
const cookies = headers.getSetCookie()
2343023492

2343123493
if (!cookies) {
2343223494
return []
2343323495
}
2343423496

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))
2343723498
}
2343823499

2343923500
/**
@@ -23861,14 +23922,11 @@ module.exports = {
2386123922
/***/ }),
2386223923

2386323924
/***/ 4806:
23864-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
23925+
/***/ ((module) => {
2386523926

2386623927
"use strict";
2386723928

2386823929

23869-
const assert = __nccwpck_require__(8061)
23870-
const { getHeadersList: internalGetHeadersList } = __nccwpck_require__(2991)
23871-
2387223930
/**
2387323931
* @param {string} value
2387423932
* @returns {boolean}
@@ -24141,37 +24199,13 @@ function stringify (cookie) {
2414124199
return out.join('; ')
2414224200
}
2414324201

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-
2416724202
module.exports = {
2416824203
isCTLExcludingHtab,
2416924204
validateCookieName,
2417024205
validateCookiePath,
2417124206
validateCookieValue,
2417224207
toIMFDate,
24173-
stringify,
24174-
getHeadersList
24208+
stringify
2417524209
}
2417624210

2417724211

@@ -28112,14 +28146,6 @@ Object.defineProperties(Headers.prototype, {
2811228146
},
2811328147
[util.inspect.custom]: {
2811428148
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-
}
2812328149
}
2812428150
})
2812528151

0 commit comments

Comments
 (0)