Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove onResponseStarted #2724

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/api/Dispatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo
* **onConnect** `(abort: () => void, context: object) => void` - 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.
* **onError** `(error: Error) => void` - Invoked when an error has occurred. May not throw.
* **onUpgrade** `(statusCode: number, headers: Buffer[], socket: Duplex) => void` (optional) - Invoked when request is upgraded. Required if `DispatchOptions.upgrade` is defined or `DispatchOptions.method === 'CONNECT'`.
* **onResponseStarted** `() => void` (optional) - Invoked when response is received, before headers have been read.
* **onHeaders** `(statusCode: number, headers: Buffer[], resume: () => void, statusText: string) => boolean` - Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. Not required for `upgrade` requests.
* **onData** `(chunk: Buffer) => boolean` - Invoked when response payload data is received. Not required for `upgrade` requests.
* **onComplete** `(trailers: Buffer[]) => void` - Invoked when response payload and trailers have been received and the request has completed. Not required for `upgrade` requests.
Expand Down
2 changes: 0 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ class Parser {
if (!request) {
return -1
}
request.onResponseStarted()
}

onHeaderField (buf) {
Expand Down Expand Up @@ -1789,7 +1788,6 @@ function writeH2 (client, session, request) {

stream.once('response', headers => {
const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers
request.onResponseStarted()

if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) {
stream.pause()
Expand Down
4 changes: 0 additions & 4 deletions lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@ class Request {
}
}

onResponseStarted () {
return this[kHandler].onResponseStarted?.()
}

onHeaders (statusCode, headers, resume, statusText) {
assert(!this.aborted)
assert(!this.completed)
Expand Down
4 changes: 1 addition & 3 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2113,15 +2113,13 @@ async function httpNetworkFetch (
timingInfo.finalNetworkRequestStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
},

onResponseStarted () {
onHeaders (status, rawHeaders, resume, statusText) {
// Set timingInfo’s final network-response start time to the coarsened shared current
// time given fetchParams’s cross-origin isolated capability, immediately after the
// user agent’s HTTP parser receives the first byte of the response (e.g., frame header
// bytes for HTTP/2 or response status line for HTTP/1.x).
timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability)
},

onHeaders (status, rawHeaders, resume, statusText) {
if (status < 200) {
return
}
Expand Down
10 changes: 2 additions & 8 deletions test/node-test/client-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,6 @@ test('dispatches in expected order', async (t) => {
onBodySent () {
dispatches.push('onBodySent')
},
onResponseStarted () {
dispatches.push('onResponseStarted')
},
onHeaders () {
dispatches.push('onHeaders')
},
Expand All @@ -892,7 +889,7 @@ test('dispatches in expected order', async (t) => {
},
onComplete () {
dispatches.push('onComplete')
p.deepStrictEqual(dispatches, ['onConnect', 'onBodySent', 'onResponseStarted', 'onHeaders', 'onData', 'onComplete'])
p.deepStrictEqual(dispatches, ['onConnect', 'onBodySent', 'onHeaders', 'onData', 'onComplete'])
},
onError (err) {
p.ifError(err)
Expand Down Expand Up @@ -938,9 +935,6 @@ test('dispatches in expected order for http2', async (t) => {
onBodySent () {
dispatches.push('onBodySent')
},
onResponseStarted () {
dispatches.push('onResponseStarted')
},
onHeaders () {
dispatches.push('onHeaders')
},
Expand All @@ -949,7 +943,7 @@ test('dispatches in expected order for http2', async (t) => {
},
onComplete () {
dispatches.push('onComplete')
p.deepStrictEqual(dispatches, ['onConnect', 'onBodySent', 'onResponseStarted', 'onHeaders', 'onData', 'onComplete'])
p.deepStrictEqual(dispatches, ['onConnect', 'onBodySent', 'onHeaders', 'onData', 'onComplete'])
},
onError (err) {
p.ifError(err)
Expand Down
2 changes: 0 additions & 2 deletions types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ declare namespace Dispatcher {
onError?(err: Error): void;
/** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
/** Invoked when response is received, before headers have been read. **/
onResponseStarted?(): void;
/** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void, statusText: string): boolean;
/** Invoked when response payload data is received. */
Expand Down