New struct for BiDi session
A BiDi session has a an optional response bodies configuration which is a
network.ResponseBodiesConfiguration. It is initially null.
network.ResponseBodiesConfiguration = (
maxResponseSize: js-uint,
urlPatterns: [*network.UrlPattern]
)
New struct for BiDi session
network.ResponseBodyData = (
request: network.Request,
navigable: browsingContext.BrowsingContext,
response: network.BytesValue / null,
isAvailable: bool
)
A BiDi session has a response map which is a map between
network.Request and network.ResponseBodyData.
Q: should we rather prefill the map on beforerequestsent and have state instead of isAvailable with "pending" "available" "unavailable" values?
Update current event
Add to the session steps for browsingContext.navigationCommitted:
If the context is a top level navigable
For each response body in session response bodies map
If response body navigable is navigable
then set the response field of response body to null and the isAvailable
field to false
Add same steps as for navigationCommitted
To maybe add response to response map given response
If session response bodies configuration is not null:
Let url patterns be intercept’s url patterns
If url patterns is not empty:
Let match be false
For each url pattern in url patterns:
If match URL pattern with url pattern and url:
Set match to true.
Break.
If match is false, return.
Let response body be a map matching the network.ResponseBodyData
production with request set to response's request, navigable set to
response's context, response set to null, and isAvailable set to false.
If response content size is smaller than response bodies configuration
maxResponseSize:
Set response body response to a map matching the network.BytesValue
production (...).
Q: Should we have a different status for responses which are too big?
Set response map[response's request] to response body.
Before the emit step, call maybe add response to response map
New command
network.EnableResponseBodies = (
method: "network.enableResponseBodies",
params: network.EnableResponseBodiesParameters
)
network.EnableResponseBodiesParameters = {
configuration: network.ResponseBodiesConfiguration
}
Let configuration be command parameters["configuration"].
If session response bodies configuration is not null, raise unable to set
response bodies configuration.
Set session response bodies configuration to a map matching the
network.ResponseBodiesConfiguration production with maxResponseSize set to
configuration["maxResponseSize"] and urlPatterns set to
configuration["urlPatterns"].
New command
network.DisableResponseBodies = (
method: "network.disableResponseBodies",
params: EmptyParams,
)
Set session response bodies configuration to null.
New command
network.ClearResponseBodiesCache = (
method: "network.clearResponseBodiesCache",
params: EmptyParams,
)
Set session response map to an empty map
New command
network.GetResponseBody = (
method: "network.getResponseBody",
params: network.GetResponseBodyParameters
)
network.getResponseBodyParameters = {
request: network.Request
}
browser.GetResponseBodyResult = {
body: network.BytesValue,
}
Same as in the current PR.
Some side comments:
enableResponseBodies
, but we could