Socket
Socket
Sign inDemoInstall

undici

Package Overview
Dependencies
1
Maintainers
3
Versions
205
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.27.0 to 5.27.1

37

lib/client.js

@@ -1465,19 +1465,3 @@ // @ts-check

if (util.isStream(request.body) && util.bodyLength(request.body) === 0) {
request.body
.on('data', /* istanbul ignore next */ function () {
/* istanbul ignore next */
assert(false)
})
.on('error', function (err) {
errorRequest(client, request, err)
})
.on('end', function () {
util.destroy(this)
})
request.body = null
}
if (client[kRunning] > 0 &&
if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
(util.isStream(request.body) || util.isAsyncIterable(request.body))) {

@@ -1503,2 +1487,7 @@ // Request with stream or iterator body can error while other requests

// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
function shouldSendContentLength (method) {
return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
}
function write (client, request) {

@@ -1532,4 +1521,6 @@ if (client[kHTTPConnVersion] === 'h2') {

let contentLength = util.bodyLength(body)
const bodyLength = util.bodyLength(body)
let contentLength = bodyLength
if (contentLength === null) {

@@ -1548,3 +1539,5 @@ contentLength = request.contentLength

if (request.contentLength !== null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {

@@ -1630,3 +1623,3 @@ errorRequest(client, request, new RequestContentLengthMismatchError())

/* istanbul ignore else: assertion */
if (!body) {
if (!body || bodyLength === 0) {
if (contentLength === 0) {

@@ -1771,3 +1764,5 @@ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')

if (request.contentLength != null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {

@@ -1774,0 +1769,0 @@ errorRequest(client, request, new RequestContentLengthMismatchError())

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

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

@@ -120,2 +122,18 @@ this.body = null

this.body = body
if (!this.body._readableState?.autoDestroy) {
this.endHandler = function autoDestroy () {
util.destroy(this)
}
this.body.on('end', this.endHandler)
}
this.errorHandler = err => {
if (this.abort) {
this.abort(err)
} else {
this.error = err
}
}
this.body.on('error', this.errorHandler)
} else if (util.isBuffer(body)) {

@@ -241,3 +259,8 @@ this.body = body.byteLength ? body : null

return this[kHandler].onConnect(abort)
if (this.error) {
abort(this.error)
} else {
this.abort = abort
return this[kHandler].onConnect(abort)
}
}

@@ -271,2 +294,4 @@

onComplete (trailers) {
this.onFinally()
assert(!this.aborted)

@@ -282,2 +307,4 @@

onError (error) {
this.onFinally()
if (channels.error.hasSubscribers) {

@@ -294,2 +321,14 @@ channels.error.publish({ request: this, error })

onFinally () {
if (this.errorHandler) {
this.body.off('error', this.errorHandler)
this.errorHandler = null
}
if (this.endHandler) {
this.body.off('end', this.endHandler)
this.endHandler = null
}
}
// TODO: adjust to support H2

@@ -296,0 +335,0 @@ addHeader (key, value) {

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

function destroy (stream, err) {
if (!isStream(stream) || isDestroyed(stream)) {
if (stream == null || !isStream(stream) || isDestroyed(stream)) {
return

@@ -196,0 +196,0 @@ }

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

socketPath,
timeout: connectTimeout == null ? 10e3 : connectTimeout,
timeout: connectTimeout,
...(util.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),

@@ -63,0 +63,0 @@ ...connect

{
"name": "undici",
"version": "5.27.0",
"version": "5.27.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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc