Socket
Socket
Sign inDemoInstall

undici

Package Overview
Dependencies
Maintainers
3
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undici - npm Package Compare versions

Comparing version 6.10.2 to 6.11.0

2

docs/docs/api/DiagnosticsChannel.md

@@ -23,4 +23,2 @@ # Diagnostics Channel Support

console.log('headers') // array of strings, e.g: ['foo', 'bar']
request.addHeader('hello', 'world')
console.log('headers', request.headers) // e.g. ['foo', 'bar', 'hello', 'world']
})

@@ -27,0 +25,0 @@ ```

39

lib/core/request.js

@@ -94,2 +94,4 @@ 'use strict'

this.publicInterface = null
if (body == null) {

@@ -191,6 +193,28 @@ this.body = null

if (channels.create.hasSubscribers) {
channels.create.publish({ request: this })
channels.create.publish({ request: this.getPublicInterface() })
}
}
getPublicInterface () {
const self = this
this.publicInterface ??= {
get origin () {
return self.origin
},
get method () {
return self.method
},
get path () {
return self.path
},
get headers () {
return self.headers
},
get completed () {
return self.completed
}
}
return this.publicInterface
}
onBodySent (chunk) {

@@ -208,3 +232,3 @@ if (this[kHandler].onBodySent) {

if (channels.bodySent.hasSubscribers) {
channels.bodySent.publish({ request: this })
channels.bodySent.publish({ request: this.getPublicInterface() })
}

@@ -242,3 +266,3 @@

if (channels.headers.hasSubscribers) {
channels.headers.publish({ request: this, response: { statusCode, headers, statusText } })
channels.headers.publish({ request: this.getPublicInterface(), response: { statusCode, headers, statusText } })
}

@@ -279,3 +303,3 @@

if (channels.trailers.hasSubscribers) {
channels.trailers.publish({ request: this, trailers })
channels.trailers.publish({ request: this.getPublicInterface(), trailers })
}

@@ -295,3 +319,3 @@

if (channels.error.hasSubscribers) {
channels.error.publish({ request: this, error })
channels.error.publish({ request: this.getPublicInterface(), error })
}

@@ -318,7 +342,2 @@

}
addHeader (key, value) {
processHeader(this, key, value)
return this
}
}

@@ -325,0 +344,0 @@

@@ -249,5 +249,2 @@ 'use strict'

function parseHeaders (headers, obj) {
// For H2 support
if (!Array.isArray(headers)) return headers
if (obj === undefined) obj = {}

@@ -254,0 +251,0 @@ for (let i = 0; i < headers.length; i += 2) {

@@ -996,3 +996,3 @@ 'use strict'

if (channels.sendHeaders.hasSubscribers) {
channels.sendHeaders.publish({ request, headers: header, socket })
channels.sendHeaders.publish({ request: request.getPublicInterface(), headers: header, socket })
}

@@ -999,0 +999,0 @@

@@ -57,2 +57,16 @@ 'use strict'

function parseH2Headers (headers) {
// set-cookie is always an array. Duplicates are added to the array.
// For duplicate cookie headers, the values are joined together with '; '.
headers = Object.entries(headers).flat(2)
const result = []
for (const header of headers) {
result.push(Buffer.from(header))
}
return result
}
async function connectH2 (client, socket) {

@@ -395,3 +409,15 @@ client[kSocket] = socket

if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) {
// Due to the stream nature, it is possible we face a race condition
// where the stream has been assigned, but the request has been aborted
// the request remains in-flight and headers hasn't been received yet
// for those scenarios, best effort is to destroy the stream immediately
// as there's no value to keep it open.
if (request.aborted || request.completed) {
const err = new RequestAbortedError()
errorRequest(client, request, err)
util.destroy(stream, err)
return
}
if (request.onHeaders(Number(statusCode), parseH2Headers(realHeaders), stream.resume.bind(stream), '') === false) {
stream.pause()

@@ -398,0 +424,0 @@ }

@@ -6,2 +6,5 @@ 'use strict'

const PERSISTENT = process.versions.icu ? '✅' : 'Y '
const NOT_PERSISTENT = process.versions.icu ? '❌' : 'N '
/**

@@ -33,3 +36,3 @@ * Gets the output of `console.table(…)` as a string.

'Status code': statusCode,
Persistent: persist ? '✅' : '❌',
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
Invocations: timesInvoked,

@@ -36,0 +39,0 @@ Remaining: persist ? Infinity : times - timesInvoked

@@ -11,3 +11,3 @@ 'use strict'

const HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-Za-z0-9]+$/
const HTTP_WHITESPACE_REGEX = /[\u000A|\u000D|\u0009|\u0020]/ // eslint-disable-line
const HTTP_WHITESPACE_REGEX = /[\u000A\u000D\u0009\u0020]/ // eslint-disable-line
const ASCII_WHITESPACE_REPLACE_REGEX = /[\u0009\u000A\u000C\u000D\u0020]/g // eslint-disable-line

@@ -17,3 +17,3 @@ /**

*/
const HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/ // eslint-disable-line
const HTTP_QUOTED_STRING_TOKENS = /[\u0009\u0020-\u007E\u0080-\u00FF]/ // eslint-disable-line

@@ -20,0 +20,0 @@ // https://fetch.spec.whatwg.org/#data-url-processor

@@ -15,3 +15,3 @@ // https://github.com/Ethan-Arrowood/undici-fetch

const assert = require('node:assert')
const util = require('util')
const util = require('node:util')

@@ -18,0 +18,0 @@ const kHeadersMap = Symbol('headers map')

{
"name": "undici",
"version": "6.10.2",
"version": "6.11.0",
"description": "An HTTP/1.1 client, written from scratch for Node.js",

@@ -72,6 +72,9 @@ "homepage": "https://undici.nodejs.org",

"test:javascript": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:jest",
"test:javascript:withoutintl": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch:nobuild && npm run test:cookies && npm run test:eventsource:nobuild && npm run test:wpt:withoutintl && npm run test:node-test",
"test:cookies": "borp -p \"test/cookie/*.js\"",
"test:node-fetch": "borp -p \"test/node-fetch/**/*.js\"",
"test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"",
"test:fetch": "npm run build:node && borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\" && borp -p \"test/busboy/*.js\"",
"test:eventsource": "npm run build:node && npm run test:eventsource:nobuild",
"test:eventsource:nobuild": "borp --expose-gc -p \"test/eventsource/*.js\"",
"test:fetch": "npm run build:node && npm run test:fetch:nobuild",
"test:fetch:nobuild": "borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\" && borp -p \"test/busboy/*.js\"",
"test:jest": "cross-env NODE_V8_COVERAGE= jest",

@@ -85,2 +88,3 @@ "test:unit": "borp --expose-gc -p \"test/*.js\"",

"test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
"test:wpt:withoutintl": "node test/wpt/start-fetch.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
"coverage": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report",

@@ -101,3 +105,3 @@ "coverage:ci": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report:ci",

"abort-controller": "^3.0.0",
"borp": "^0.9.1",
"borp": "^0.10.0",
"c8": "^9.1.0",

@@ -118,3 +122,3 @@ "cross-env": "^7.0.3",

"standard": "^17.0.0",
"tsd": "^0.30.1",
"tsd": "^0.31.0",
"typescript": "^5.0.2",

@@ -121,0 +125,0 @@ "ws": "^8.11.0"

@@ -10,4 +10,8 @@ # undici

## How to get involved
Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
Looking to contribute? Start by reading the [contributing guide](./CONTRIBUTING.md)
## Install

@@ -14,0 +18,0 @@

@@ -12,4 +12,3 @@ import { Socket } from "net";

path: string;
headers: string;
addHeader(key: string, value: string): Request;
headers: any;
}

@@ -16,0 +15,0 @@ interface Response {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc