Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Apr 3, 2024
1 parent 9ec58f6 commit 0ced8c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ class Request {
abort.paused = false
abort.aborted = false
abort.internal = null
abort.abort = function (...args) {
abort.abort = function (err) {
abort.aborted = true
abort(...args)
abort(err)
}
abort.pause = function () {
abort.paused = true
Expand Down
2 changes: 1 addition & 1 deletion lib/dispatcher/client-h2.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function writeH2 (client, request) {
stream.pause()
}

if (request.onHeaders(Number(statusCode), realHeaders, resume, '') === false) {
if (request.onHeaders(Number(statusCode), parseH2Headers(realHeaders), resume, '') === false) {
stream.pause()
}

Expand Down
1 change: 1 addition & 0 deletions lib/mock/mock-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ function mockDispatch (opts, handler) {
super()
this.resume = this.resume.bind(this)
this.pause = this.pause.bind(this)
this.abort = this.abort.bind(this)
}

resume () {
Expand Down
16 changes: 8 additions & 8 deletions test/node-test/client-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,15 @@ test('dispatches in expected order', async (t) => {
method: 'POST',
body: 'body'
}, {
onConnect () {
onConnect (controller) {
assert(typeof controller.resume === 'function')
assert(typeof controller.pause === 'function')
dispatches.push('onConnect')
},
onBodySent () {
dispatches.push('onBodySent')
},
onStart (controller) {
assert(typeof controller.resume === 'function')
assert(typeof controller.pause === 'function')
onStart () {
dispatches.push('onStart')
},
onResponseStarted () {
Expand Down Expand Up @@ -937,15 +937,15 @@ test('dispatches in expected order for http2', async (t) => {
method: 'POST',
body: 'body'
}, {
onConnect () {
onConnect (controller) {
assert(typeof controller.resume === 'function')
assert(typeof controller.pause === 'function')
dispatches.push('onConnect')
},
onBodySent () {
dispatches.push('onBodySent')
},
onStart (controller) {
assert(typeof controller.resume === 'function')
assert(typeof controller.pause === 'function')
onStart () {
dispatches.push('onStart')
},
onResponseStarted () {
Expand Down
6 changes: 4 additions & 2 deletions types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,16 @@ declare namespace Dispatcher {
export interface Controller {
pause (): void;
resume (): void;
abort (err?): void;
readonly paused: boolean;
readonly aborted: boolean;
}

export interface DispatchHandlers {
/** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
onConnect?(abort: () => void): void;
onConnect?(controller: Controller): void;
/** */
onStart?(controller: Controller): void;
onStart?(): void;
/** Invoked when an error has occurred. */
onError?(err: Error): void;
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
Expand Down

0 comments on commit 0ced8c7

Please sign in to comment.