diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 60d1b511172..0cb6528ae06 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -612,7 +612,7 @@ class Parser { // have been queued since then. util.destroy(socket, new InformationalError('reset')) return constants.ERROR.PAUSED - } else if (client[kPipelining] === 1) { + } else if (client[kPipelining] == null || client[kPipelining] === 1) { // We must wait a full event loop cycle to reuse this socket to make sure // that non-spec compliant servers are not closing the connection even if they // said they won't. @@ -735,6 +735,7 @@ async function connectH1 (client, socket) { return { version: 'h1', + defaultPipelining: 1, write (...args) { return writeH1(client, ...args) }, diff --git a/lib/dispatcher/client-h2.js b/lib/dispatcher/client-h2.js index c0cfd5c88f6..7202c654397 100644 --- a/lib/dispatcher/client-h2.js +++ b/lib/dispatcher/client-h2.js @@ -124,6 +124,7 @@ async function connectH2 (client, socket) { return { version: 'h2', + defaultPipelining: Infinity, write (...args) { // TODO (fix): return writeH2(client, ...args) diff --git a/lib/dispatcher/client.js b/lib/dispatcher/client.js index 91acddd8371..7c75c2ff239 100644 --- a/lib/dispatcher/client.js +++ b/lib/dispatcher/client.js @@ -66,6 +66,10 @@ const connectH2 = require('./client-h2.js') const kClosedResolve = Symbol('kClosedResolve') +function getPipelining (client) { + return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1 +} + /** * @type {import('../../types/client.js').default} */ @@ -280,7 +284,7 @@ class Client extends DispatcherBase { const socket = this[kSocket] return ( (socket && (socket[kReset] || socket[kWriting] || socket[kBlocking])) || - (this[kSize] >= (this[kPipelining] || 1)) || + (this[kSize] >= (getPipelining(this) || 1)) || this[kPending] > 0 ) } @@ -564,10 +568,8 @@ function _resume (client, sync) { return } - if (client[kHTTPContext]?.version === 'h1') { - if (client[kRunning] >= (client[kPipelining] || 1)) { - return - } + if (client[kRunning] >= (getPipelining(client) || 1)) { + return } const request = client[kQueue][client[kPendingIdx]]