network.responseCompleted event
The network.responseCompleted event of the network module fires when the browser has received the whole body of a response.
Event data
The params field in the event notification is an object with the following fields:
context-
A string that contains the ID of the context in which the request was made, or
nullif the request wasn't made by a document in a context, for example a request made by a worker. isBlocked-
A boolean that indicates whether the request is blocked by an intercept. It is always
falsefor this event because intercepts can't block a request after the browser has received the complete response, so the event never includes theinterceptsfield. -
A string that contains the UUID that uniquely identifies the navigation that the request is part of, or
nullif the request isn't a navigation request. For example, the value isnullwhen requesting a document's subresources, such as stylesheets and scripts, or when making a request withfetch(). If the navigation was started using thebrowsingContext.navigateorbrowsingContext.reloadcommand, this ID matches thenavigationvalue in the command's response. Other events related to this navigation share the same navigation ID, including events in thebrowsingContextandnetworkmodules. redirectCount-
A non-negative integer that contains the number of redirects the browser has followed for this request. It is
0for the original request and increases by one with each redirect. request-
An object that describes the request. It contains the following fields:
bodySize-
A non-negative integer that contains the size of the request body in bytes, or
nullif the request has no body. -
An array of objects, each representing a cookie sent with the request. The array is empty if the request has no
Cookieheader. Each object contains the following fields and may additionally include browser-specific fields:domain-
A string that contains the domain of the cookie.
expiryOptional-
A non-negative integer that contains the expiry time of the cookie, as seconds elapsed since the epoch. This field is omitted for a cookie that has no expiry time, such as a session cookie.
httpOnly-
A boolean that indicates whether the cookie is hidden from page scripts by its
HttpOnlyattribute (true) or is accessible to them (false). name-
A string that contains the name of the cookie.
path-
A string that contains the path of the cookie.
sameSite-
A string that indicates the cookie's
SameSitesetting. It has one of the following values:default: The cookie has noSameSiteattribute or has an unrecognized value, so the browser's default behavior applies.lax: The cookie hasSameSite=Lax.none: The cookie hasSameSite=None.strict: The cookie hasSameSite=Strict.
secure-
A boolean that indicates whether the cookie is restricted to secure connections by its
Secureattribute (true) or can be sent over insecure connections (false). size-
A non-negative integer that contains the combined size of the cookie's name and value, in bytes.
value-
An object that contains the value of the cookie. It contains the following fields:
destination-
A string that contains the destination of the request, such as
document,script, orstyle. The string is empty for requests made withfetch()orXMLHttpRequest. headers-
An array of objects, each representing a header of the request, including headers added with the
network.setExtraHeaderscommand. Each object contains the following fields:name-
A string that contains the header name, such as
Accept. value-
An object that contains the header value. It contains the following fields:
headersSize-
A non-negative integer that contains the size of the request headers in bytes. For protocols that compress headers, such as HTTP/2, it represents the compressed size.
initiatorType-
A string that indicates what started the request, such as
fetch,link, orscript. For a request with no initiator type, such as the request for a page loaded into a tab, the value isnullinstead of a string. SeePerformanceResourceTiming.initiatorTypefor descriptions of common values. method-
A string that contains the HTTP request method, such as
GETorPOST. request-
A string that contains the ID of the request. The ID stays the same even when the request is redirected.
timings-
An object that contains the times at which the stages of the request happened. The
timeOriginfield contains a time in milliseconds since the epoch. The other fields in this object contain times in milliseconds relative totimeOrigin. A field is0if its stage hasn't happened, for example the redirect fields for a request that wasn't redirected. All the fields are0if the request wasn't made by a document or a worker. It contains the following fields:connectEnd-
A number that represents the time when the browser finished establishing the connection to the server, similar to
PerformanceResourceTiming.connectEnd. connectStart-
A number that represents the time when the browser started establishing the connection to the server, similar to
PerformanceResourceTiming.connectStart. dnsEnd-
A number that represents the time when the browser finished the domain name lookup, similar to
PerformanceResourceTiming.domainLookupEnd. dnsStart-
A number that represents the time when the browser started the domain name lookup, similar to
PerformanceResourceTiming.domainLookupStart. fetchStart-
A number that represents the time when the browser started fetching the resource after any redirects, similar to
PerformanceResourceTiming.fetchStart. redirectEnd-
A number that represents the time when the browser received the last byte of the response to the last redirect, similar to
PerformanceResourceTiming.redirectEnd. redirectStart-
A number that represents the time when the request that was redirected first started, similar to
PerformanceResourceTiming.redirectStart. requestStart-
A number that represents the time when the browser started sending the request, similar to
PerformanceResourceTiming.requestStart. requestTime-
A number that represents the time when the request started, similar to
PerformanceEntry.startTime. responseEnd-
A number that represents the time when the browser received the last byte of the response, similar to
PerformanceResourceTiming.responseEnd. responseStart-
A number that represents the time when the browser received the first byte of the response, similar to
PerformanceResourceTiming.responseStart. timeOrigin-
A number that represents the time origin of the document or worker that made the request.
tlsStart-
A number that represents the time when the browser started the TLS handshake to secure the connection, similar to
PerformanceResourceTiming.secureConnectionStart.
url-
A string that contains the URL of the request.
response-
An object that describes the response. It contains the following fields:
authChallengesOptional-
An array of objects, each representing an authentication challenge from the server. This field is included only when the response status is
401or407. The challenges come from theWWW-Authenticateheader for401responses or theProxy-Authenticateheader for407responses. The array is empty if the response doesn't include the corresponding header. Each object contains the following fields:realm-
A string that contains the realm of the challenge, or an empty string if the challenge has no realm.
scheme-
A string that contains the authentication scheme, such as
Basic.
bodySize-
A non-negative integer that contains the size of the response body, in bytes, before the browser decodes it (for example, before decompression), or
nullif the browser doesn't report it. bytesReceived-
A non-negative integer that contains the total number of bytes received for the response, including its headers. It is
0for a response served from the browser's cache. content-
An object that describes the decoded response body. It contains the following field:
size-
A non-negative integer that contains the size of the response body in bytes after the browser decodes it (for example, after decompression).
fromCache-
A boolean that indicates whether the browser served the response from its cache.
true: The browser served the response from its cache without contacting the server.false: The browser didn't serve the response from its cache. This includes cases where it contacted the server to revalidate a cached response.
headers-
An array of objects, each representing a header of the response. Each object contains the following fields:
name-
A string that contains the header name, such as
Content-Type. value-
An object that contains the header value. It contains the following fields:
headersSize-
A non-negative integer that contains the size of the response headers, in bytes, as received, or
nullif the browser doesn't report it. mimeType-
A string that contains the MIME type that the browser uses for the response, such as
text/htmlorapplication/json. The value doesn't include MIME type parameters. It can differ from theContent-Typeheader, for example when the browser determines the type from the content. It can also be an empty string, for example for a redirect response. protocol-
A string that contains the protocol of the response, such as
http/1.1orh2. For a response that wasn't received over HTTP, it is the scheme of the response URL, such asdata. status-
A non-negative integer that contains the HTTP status code of the response, such as
200. statusText-
A string that contains the status message of the response, such as
OK. url-
A string that contains the URL of the response.
timestamp-
A non-negative integer that represents the time when the event was fired, as milliseconds elapsed since the epoch.
userContextOptional-
A string that contains the ID of the user context in which the request was made, or
nullif the request wasn't made by a document in a context.
Description
In the lifecycle of a request, this is the last event for a response that the browser received successfully.
It fires after network.beforeRequestSent and network.responseStarted for the same request.
If the request fails at any point, network.fetchError fires as the last event for the request.
When the server responds with a redirect, this event fires for the redirect response too.
The browser then sends network.beforeRequestSent for the new URL.
The request ID stays the same and redirectCount increases by one.
The other events for the new URL follow.
The browser doesn't wait for the client after sending this event: a response can't be blocked at this point.
Examples
>Following a request through a redirect
Assume you have a WebDriver BiDi connection, an active session, and a subscription to the network.beforeRequestSent, network.responseStarted, and network.responseCompleted events.
Suppose a tab has loaded https://example.com/.
The page calls fetch("/old-items").
The server responds with a 302 redirect to /api/items.
The browser sends network.beforeRequestSent and network.responseStarted for /old-items, and then the following network.responseCompleted event for the redirect response (only some of the fields are shown):
{
"type": "event",
"method": "network.responseCompleted",
"params": {
"context": "93ee5bd6-d256-4608-a002-9a8995cc0e5f",
"isBlocked": false,
"navigation": null,
"redirectCount": 0,
"request": {
"method": "GET",
"request": "b9e201af-6475-4bea-a174-51a8290f8087",
"url": "https://example.com/old-items"
},
"response": {
"headers": [
{
"name": "Location",
"value": {
"type": "string",
"value": "/api/items"
}
}
],
"status": 302,
"statusText": "Found",
"url": "https://example.com/old-items"
},
"timestamp": 1791903501504
}
}
It then sends network.beforeRequestSent and network.responseStarted for /api/items, and finally the following network.responseCompleted event (only some of the fields are shown):
{
"type": "event",
"method": "network.responseCompleted",
"params": {
"context": "93ee5bd6-d256-4608-a002-9a8995cc0e5f",
"isBlocked": false,
"navigation": null,
"redirectCount": 1,
"request": {
"method": "GET",
"request": "b9e201af-6475-4bea-a174-51a8290f8087",
"url": "https://example.com/api/items"
},
"response": {
"mimeType": "application/json",
"status": 200,
"statusText": "OK",
"url": "https://example.com/api/items"
},
"timestamp": 1791903501505
}
}
The request objects in both network.responseCompleted events have the same request ID, so you can tell that they belong to the same request.
The redirectCount of 1 shows that the second response is the result of one redirect.
Specifications
| Specification |
|---|
| WebDriver BiDi> # event-network-responseCompleted> |
Browser compatibility
See also
network.beforeRequestSenteventnetwork.responseStartedeventnetwork.fetchErroreventnetwork.authRequiredeventsession.subscribecommand- Redirections in HTTP guide