aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/undici/lib/core
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/undici/lib/core')
-rw-r--r--node_modules/undici/lib/core/errors.js21
-rw-r--r--node_modules/undici/lib/core/request.js14
2 files changed, 32 insertions, 3 deletions
diff --git a/node_modules/undici/lib/core/errors.js b/node_modules/undici/lib/core/errors.js
index 535c733..2028801 100644
--- a/node_modules/undici/lib/core/errors.js
+++ b/node_modules/undici/lib/core/errors.js
@@ -379,6 +379,24 @@ class SecureProxyConnectionError extends UndiciError {
[kSecureProxyConnectionError] = true
}
+const kMessageSizeExceededError = Symbol.for('undici.error.UND_ERR_WS_MESSAGE_SIZE_EXCEEDED')
+class MessageSizeExceededError extends UndiciError {
+ constructor (message) {
+ super(message)
+ this.name = 'MessageSizeExceededError'
+ this.message = message || 'Max decompressed message size exceeded'
+ this.code = 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED'
+ }
+
+ static [Symbol.hasInstance] (instance) {
+ return instance && instance[kMessageSizeExceededError] === true
+ }
+
+ get [kMessageSizeExceededError] () {
+ return true
+ }
+}
+
module.exports = {
AbortError,
HTTPParserError,
@@ -402,5 +420,6 @@ module.exports = {
ResponseExceededMaxSizeError,
RequestRetryError,
ResponseError,
- SecureProxyConnectionError
+ SecureProxyConnectionError,
+ MessageSizeExceededError
}
diff --git a/node_modules/undici/lib/core/request.js b/node_modules/undici/lib/core/request.js
index 7800303..4da6066 100644
--- a/node_modules/undici/lib/core/request.js
+++ b/node_modules/undici/lib/core/request.js
@@ -66,6 +66,10 @@ class Request {
throw new InvalidArgumentError('upgrade must be a string')
}
+ if (upgrade && !isValidHeaderValue(upgrade)) {
+ throw new InvalidArgumentError('invalid upgrade header')
+ }
+
if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) {
throw new InvalidArgumentError('invalid headersTimeout')
}
@@ -360,13 +364,19 @@ function processHeader (request, key, val) {
val = `${val}`
}
- if (request.host === null && headerName === 'host') {
+ if (headerName === 'host') {
+ if (request.host !== null) {
+ throw new InvalidArgumentError('duplicate host header')
+ }
if (typeof val !== 'string') {
throw new InvalidArgumentError('invalid host header')
}
// Consumed by Client
request.host = val
- } else if (request.contentLength === null && headerName === 'content-length') {
+ } else if (headerName === 'content-length') {
+ if (request.contentLength !== null) {
+ throw new InvalidArgumentError('duplicate content-length header')
+ }
request.contentLength = parseInt(val, 10)
if (!Number.isFinite(request.contentLength)) {
throw new InvalidArgumentError('invalid content-length header')