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 5.28.0 to 5.28.1

31

lib/client.js

@@ -920,7 +920,5 @@ // @ts-check

let pause
try {
pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
} catch (err) {
util.destroy(socket, err)
const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
if (request.aborted) {
return -1

@@ -972,9 +970,4 @@ }

try {
if (request.onData(buf) === false) {
return constants.ERROR.PAUSED
}
} catch (err) {
util.destroy(socket, err)
return -1
if (request.onData(buf) === false) {
return constants.ERROR.PAUSED
}

@@ -1020,7 +1013,3 @@ }

try {
request.onComplete(headers)
} catch (err) {
errorRequest(client, request, err)
}
request.onComplete(headers)

@@ -1811,3 +1800,5 @@ client[kQueue][client[kRunningIdx]++] = null

stream.on('data', (chunk) => {
if (request.onData(chunk) === false) stream.pause()
if (request.onData(chunk) === false) {
stream.pause()
}
})

@@ -1818,3 +1809,5 @@

// TODO(HTTP/2): unref only if current streams count is 0
if (h2State.openStreams === 0) session.unref()
if (h2State.openStreams === 0) {
session.unref()
}
})

@@ -1821,0 +1814,0 @@

@@ -232,3 +232,7 @@ 'use strict'

if (this[kHandler].onBodySent) {
return this[kHandler].onBodySent(chunk)
try {
return this[kHandler].onBodySent(chunk)
} catch (err) {
this.abort(err)
}
}

@@ -243,3 +247,7 @@ }

if (this[kHandler].onRequestSent) {
return this[kHandler].onRequestSent()
try {
return this[kHandler].onRequestSent()
} catch (err) {
this.abort(err)
}
}

@@ -268,3 +276,7 @@ }

return this[kHandler].onHeaders(statusCode, headers, resume, statusText)
try {
return this[kHandler].onHeaders(statusCode, headers, resume, statusText)
} catch (err) {
this.abort(err)
}
}

@@ -276,3 +288,8 @@

return this[kHandler].onData(chunk)
try {
return this[kHandler].onData(chunk)
} catch (err) {
this.abort(err)
return false
}
}

@@ -296,3 +313,9 @@

}
return this[kHandler].onComplete(trailers)
try {
return this[kHandler].onComplete(trailers)
} catch (err) {
// TODO (fix): This might be a bad idea?
this.onError(err)
}
}

@@ -311,2 +334,3 @@

this.aborted = true
return this[kHandler].onError(error)

@@ -313,0 +337,0 @@ }

@@ -13,3 +13,4 @@ /* globals AbortController */

normalizeMethod,
makePolicyContainer
makePolicyContainer,
normalizeMethodRecord
} = require('./util')

@@ -187,4 +188,6 @@ const {

const initHasKey = Object.keys(init).length !== 0
// 13. If init is not empty, then:
if (Object.keys(init).length > 0) {
if (initHasKey) {
// 1. If request’s mode is "navigate", then set it to "same-origin".

@@ -320,12 +323,12 @@ if (request.mode === 'navigate') {

// throw a TypeError.
if (!isValidHTTPToken(init.method)) {
throw new TypeError(`'${init.method}' is not a valid HTTP method.`)
if (!isValidHTTPToken(method)) {
throw new TypeError(`'${method}' is not a valid HTTP method.`)
}
if (forbiddenMethodsSet.has(method.toUpperCase())) {
throw new TypeError(`'${init.method}' HTTP method is unsupported.`)
throw new TypeError(`'${method}' HTTP method is unsupported.`)
}
// 3. Normalize method.
method = normalizeMethod(init.method)
method = normalizeMethodRecord[method] ?? normalizeMethod(method)

@@ -421,21 +424,21 @@ // 4. Set request’s method to method.

// 32. If init is not empty, then:
if (Object.keys(init).length !== 0) {
if (initHasKey) {
/** @type {HeadersList} */
const headersList = this[kHeaders][kHeadersList]
// 1. Let headers be a copy of this’s headers and its associated header
// list.
let headers = new Headers(this[kHeaders])
// 2. If init["headers"] exists, then set headers to init["headers"].
if (init.headers !== undefined) {
headers = init.headers
}
const headers = init.headers !== undefined ? init.headers : new HeadersList(headersList)
// 3. Empty this’s headers’s header list.
this[kHeaders][kHeadersList].clear()
headersList.clear()
// 4. If headers is a Headers object, then for each header in its header
// list, append header’s name/header’s value to this’s headers.
if (headers.constructor.name === 'Headers') {
if (headers instanceof HeadersList) {
for (const [key, val] of headers) {
this[kHeaders].append(key, val)
headersList.append(key, val)
}
// Note: Copy the `set-cookie` meta-data.
headersList.cookies = headers.cookies
} else {

@@ -442,0 +445,0 @@ // 5. Otherwise, fill this’s headers with headers.

@@ -701,7 +701,26 @@ 'use strict'

// https://fetch.spec.whatwg.org/#concept-method-normalize
const normalizeMethodRecord = {
delete: 'DELETE',
DELETE: 'DELETE',
get: 'GET',
GET: 'GET',
head: 'HEAD',
HEAD: 'HEAD',
options: 'OPTIONS',
OPTIONS: 'OPTIONS',
post: 'POST',
POST: 'POST',
put: 'PUT',
PUT: 'PUT'
}
// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
Object.setPrototypeOf(normalizeMethodRecord, null)
/**
* @see https://fetch.spec.whatwg.org/#concept-method-normalize
* @param {string} method
*/
function normalizeMethod (method) {
return /^(DELETE|GET|HEAD|OPTIONS|POST|PUT)$/i.test(method)
? method.toUpperCase()
: method
return normalizeMethodRecord[method.toLowerCase()] ?? method
}

@@ -1051,3 +1070,4 @@

urlIsHttpHttpsScheme,
readAllBytes
readAllBytes,
normalizeMethodRecord
}
{
"name": "undici",
"version": "5.28.0",
"version": "5.28.1",
"description": "An HTTP/1.1 client, written from scratch for Node.js",

@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org",

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