Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9c2f3ce

Browse filesBrowse files
nodejs-github-botruyadorno
authored andcommitted
deps: update undici to 5.15.0
PR-URL: #46213 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 9757888 commit 9c2f3ce
Copy full SHA for 9c2f3ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

41 files changed

+7322
-5525
lines changed
Open diff view settings
Collapse file
+101Lines changed: 101 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Cookie Handling
2+
3+
## `Cookie` interface
4+
5+
* **name** `string`
6+
* **value** `string`
7+
* **expires** `Date|number` (optional)
8+
* **maxAge** `number` (optional)
9+
* **domain** `string` (optional)
10+
* **path** `string` (optional)
11+
* **secure** `boolean` (optional)
12+
* **httpOnly** `boolean` (optional)
13+
* **sameSite** `'String'|'Lax'|'None'` (optional)
14+
* **unparsed** `string[]` (optional) Left over attributes that weren't parsed.
15+
16+
## `deleteCookie(headers, name[, attributes])`
17+
18+
Sets the expiry time of the cookie to the unix epoch, causing browsers to delete it when received.
19+
20+
```js
21+
import { deleteCookie, Headers } from 'undici'
22+
23+
const headers = new Headers()
24+
deleteCookie(headers, 'name')
25+
26+
console.log(headers.get('set-cookie')) // name=; Expires=Thu, 01 Jan 1970 00:00:00 GMT
27+
```
28+
29+
Arguments:
30+
31+
* **headers** `Headers`
32+
* **name** `string`
33+
* **attributes** `{ path?: string, domain?: string }` (optional)
34+
35+
Returns: `void`
36+
37+
## `getCookies(headers)`
38+
39+
Parses the `Cookie` header and returns a list of attributes and values.
40+
41+
```js
42+
import { getCookies, Headers } from 'undici'
43+
44+
const headers = new Headers({
45+
cookie: 'get=cookies; and=attributes'
46+
})
47+
48+
console.log(getCookies(headers)) // { get: 'cookies', and: 'attributes' }
49+
```
50+
51+
Arguments:
52+
53+
* **headers** `Headers`
54+
55+
Returns: `Record<string, string>`
56+
57+
## `getSetCookies(headers)`
58+
59+
Parses all `Set-Cookie` headers.
60+
61+
```js
62+
import { getSetCookies, Headers } from 'undici'
63+
64+
const headers = new Headers({ 'set-cookie': 'undici=getSetCookies; Secure' })
65+
66+
console.log(getSetCookies(headers))
67+
// [
68+
// {
69+
// name: 'undici',
70+
// value: 'getSetCookies',
71+
// secure: true
72+
// }
73+
// ]
74+
75+
```
76+
77+
Arguments:
78+
79+
* **headers** `Headers`
80+
81+
Returns: `Cookie[]`
82+
83+
## `setCookie(headers, cookie)`
84+
85+
Appends a cookie to the `Set-Cookie` header.
86+
87+
```js
88+
import { setCookie, Headers } from 'undici'
89+
90+
const headers = new Headers()
91+
setCookie(headers, { name: 'undici', value: 'setCookie' })
92+
93+
console.log(headers.get('Set-Cookie')) // undici=setCookie
94+
```
95+
96+
Arguments:
97+
98+
* **headers** `Headers`
99+
* **cookie** `Cookie`
100+
101+
Returns: `void`
Collapse file

‎deps/undici/src/docs/api/DiagnosticsChannel.md‎

Copy file name to clipboardExpand all lines: deps/undici/src/docs/api/DiagnosticsChannel.md
+67Lines changed: 67 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,70 @@ diagnosticsChannel.channel('undici:client:connectError').subscribe(({ error, soc
135135
// connector is a function that creates the socket
136136
console.log(`Connect failed with ${error.message}`)
137137
})
138+
```
139+
140+
## `undici:websocket:open`
141+
142+
This message is published after the client has successfully connected to a server.
143+
144+
```js
145+
import diagnosticsChannel from 'diagnostics_channel'
146+
147+
diagnosticsChannel.channel('undici:websocket:open').subscribe(({ address, protocol, extensions }) => {
148+
console.log(address) // address, family, and port
149+
console.log(protocol) // negotiated subprotocols
150+
console.log(extensions) // negotiated extensions
151+
})
152+
```
153+
154+
## `undici:websocket:close`
155+
156+
This message is published after the connection has closed.
157+
158+
```js
159+
import diagnosticsChannel from 'diagnostics_channel'
160+
161+
diagnosticsChannel.channel('undici:websocket:close').subscribe(({ websocket, code, reason }) => {
162+
console.log(websocket) // the WebSocket object
163+
console.log(code) // the closing status code
164+
console.log(reason) // the closing reason
165+
})
166+
```
167+
168+
## `undici:websocket:socket_error`
169+
170+
This message is published if the socket experiences an error.
171+
172+
```js
173+
import diagnosticsChannel from 'diagnostics_channel'
174+
175+
diagnosticsChannel.channel('undici:websocket:socket_error').subscribe((error) => {
176+
console.log(error)
177+
})
178+
```
179+
180+
## `undici:websocket:ping`
181+
182+
This message is published after the client receives a ping frame, if the connection is not closing.
183+
184+
```js
185+
import diagnosticsChannel from 'diagnostics_channel'
186+
187+
diagnosticsChannel.channel('undici:websocket:ping').subscribe(({ payload }) => {
188+
// a Buffer or undefined, containing the optional application data of the frame
189+
console.log(payload)
190+
})
191+
```
192+
193+
## `undici:websocket:pong`
194+
195+
This message is published after the client receives a pong frame.
196+
197+
```js
198+
import diagnosticsChannel from 'diagnostics_channel'
199+
200+
diagnosticsChannel.channel('undici:websocket:pong').subscribe(({ payload }) => {
201+
// a Buffer or undefined, containing the optional application data of the frame
202+
console.log(payload)
203+
})
204+
```
Collapse file

‎deps/undici/src/docs/api/Dispatcher.md‎

Copy file name to clipboardExpand all lines: deps/undici/src/docs/api/Dispatcher.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo
192192
* **origin** `string | URL`
193193
* **path** `string`
194194
* **method** `string`
195+
* **reset** `boolean` (optional) - Default: `false` - If `false`, the request will attempt to create a long-living connection by sending the `connection: keep-alive` header,otherwise will attempt to close it immediately after response by sending `connection: close` within the request and closing the socket afterwards.
195196
* **body** `string | Buffer | Uint8Array | stream.Readable | Iterable | AsyncIterable | null` (optional) - Default: `null`
196197
* **headers** `UndiciHeaders | string[]` (optional) - Default: `null`.
197198
* **query** `Record<string, any> | null` (optional) - Default: `null` - Query string params to be embedded in the request URL. Note that both keys and values of query are encoded using `encodeURIComponent`. If for some reason you need to send them unencoded, embed query params into path directly instead.
Collapse file

‎deps/undici/src/docs/api/Fetch.md‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Fetch
2+
3+
Undici exposes a fetch() method starts the process of fetching a resource from the network.
4+
5+
Documentation and examples can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
6+
7+
## File
8+
9+
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/File)
10+
11+
## FormData
12+
13+
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
14+
15+
## Response
16+
17+
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Response)
18+
19+
## Request
20+
21+
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Request)
22+
23+
## Header
24+
25+
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
Collapse file
+20Lines changed: 20 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Class: WebSocket
2+
3+
> ⚠️ Warning: the WebSocket API is experimental and has known bugs.
4+
5+
Extends: [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
6+
7+
The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).
8+
9+
## `new WebSocket(url[, protocol])`
10+
11+
Arguments:
12+
13+
* **url** `URL | string` - The url's protocol *must* be `ws` or `wss`.
14+
* **protocol** `string | string[]` (optional) - Subprotocol(s) to request the server use.
15+
16+
## Read More
17+
18+
- [MDN - WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
19+
- [The WebSocket Specification](https://www.rfc-editor.org/rfc/rfc6455)
20+
- [The WHATWG WebSocket Specification](https://websockets.spec.whatwg.org/)
Collapse file

‎deps/undici/src/index.d.ts‎

Copy file name to clipboardExpand all lines: deps/undici/src/index.d.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import mockErrors from'./types/mock-errors'
1616
import ProxyAgent from'./types/proxy-agent'
1717
import { request, pipeline, stream, connect, upgrade } from './types/api'
1818

19+
export * from './types/cookies'
1920
export * from './types/fetch'
2021
export * from './types/file'
2122
export * from './types/filereader'
2223
export * from './types/formdata'
2324
export * from './types/diagnostics-channel'
25+
export * from './types/websocket'
2426
export { Interceptable } from './types/mock-interceptor'
2527

2628
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
Collapse file

‎deps/undici/src/index.js‎

Copy file name to clipboardExpand all lines: deps/undici/src/index.js
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ const nodeVersion = process.versions.node.split('.')
2424
const nodeMajor = Number(nodeVersion[0])
2525
const nodeMinor = Number(nodeVersion[1])
2626

27+
let hasCrypto
28+
try {
29+
require('crypto')
30+
hasCrypto = true
31+
} catch {
32+
hasCrypto = false
33+
}
34+
2735
Object.assign(Dispatcher.prototype, api)
2836

2937
module.exports.Dispatcher = Dispatcher
@@ -119,6 +127,21 @@ if (nodeMajor > 16 || (nodeMajor === 16 && nodeMinor >= 8)) {
119127
module.exports.getGlobalOrigin = getGlobalOrigin
120128
}
121129

130+
if (nodeMajor >= 16) {
131+
const { deleteCookie, getCookies, getSetCookies, setCookie } = require('./lib/cookies')
132+
133+
module.exports.deleteCookie = deleteCookie
134+
module.exports.getCookies = getCookies
135+
module.exports.getSetCookies = getSetCookies
136+
module.exports.setCookie = setCookie
137+
}
138+
139+
if (nodeMajor >= 18 && hasCrypto) {
140+
const { WebSocket } = require('./lib/websocket/websocket')
141+
142+
module.exports.WebSocket = WebSocket
143+
}
144+
122145
module.exports.request = makeDispatcher(api.request)
123146
module.exports.stream = makeDispatcher(api.stream)
124147
module.exports.pipeline = makeDispatcher(api.pipeline)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.