undici 7.26.0 → 7.27.1

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/lib/global.js CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  // We include a version number for the Dispatcher API. In case of breaking changes,
4
4
  // this version number must be increased to avoid conflicts.
5
- const globalDispatcher = Symbol.for('undici.globalDispatcher.1')
5
+ const globalDispatcher = Symbol.for('undici.globalDispatcher.2')
6
+ const legacyGlobalDispatcher = Symbol.for('undici.globalDispatcher.1')
6
7
  const { InvalidArgumentError } = require('./core/errors')
7
8
  const Agent = require('./dispatcher/agent')
8
9
 
@@ -14,12 +15,20 @@ function setGlobalDispatcher (agent) {
14
15
  if (!agent || typeof agent.dispatch !== 'function') {
15
16
  throw new InvalidArgumentError('Argument agent must implement Agent')
16
17
  }
18
+
17
19
  Object.defineProperty(globalThis, globalDispatcher, {
18
20
  value: agent,
19
21
  writable: true,
20
22
  enumerable: false,
21
23
  configurable: false
22
24
  })
25
+
26
+ Object.defineProperty(globalThis, legacyGlobalDispatcher, {
27
+ value: agent,
28
+ writable: true,
29
+ enumerable: false,
30
+ configurable: false
31
+ })
23
32
  }
24
33
 
25
34
  function getGlobalDispatcher () {
@@ -13,6 +13,9 @@ class UnwrapController {
13
13
 
14
14
  [kResume] = null
15
15
 
16
+ rawHeaders = null
17
+ rawTrailers = null
18
+
16
19
  constructor (abort) {
17
20
  this.#abort = abort
18
21
  }
@@ -72,11 +75,13 @@ module.exports = class UnwrapHandler {
72
75
  }
73
76
 
74
77
  onUpgrade (statusCode, rawHeaders, socket) {
78
+ this.#controller.rawHeaders = rawHeaders
75
79
  this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket)
76
80
  }
77
81
 
78
82
  onHeaders (statusCode, rawHeaders, resume, statusMessage) {
79
83
  this.#controller[kResume] = resume
84
+ this.#controller.rawHeaders = rawHeaders
80
85
  this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage)
81
86
  return !this.#controller.paused
82
87
  }
@@ -87,6 +92,7 @@ module.exports = class UnwrapHandler {
87
92
  }
88
93
 
89
94
  onComplete (rawTrailers) {
95
+ this.#controller.rawTrailers = rawTrailers
90
96
  this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers))
91
97
  }
92
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "7.26.0",
3
+ "version": "7.27.1",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -212,6 +212,8 @@ declare namespace Dispatcher {
212
212
  get aborted(): boolean
213
213
  get paused(): boolean
214
214
  get reason(): Error | null
215
+ rawHeaders?: Buffer[] | string[] | IncomingHttpHeaders | null
216
+ rawTrailers?: Buffer[] | string[] | IncomingHttpHeaders | null
215
217
  abort(reason: Error): void
216
218
  pause(): void
217
219
  resume(): void