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

Add a command to get response body #856

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/
text: no such alert; url: dfn-no-such-alert
text: no such element; url: dfn-no-such-element
text: no such frame; url: dfn-no-such-frame
text: no such response; url: dfn-no-such-response
text: no response body; url: dfn-no-response-body
text: parse a page range; url: dfn-parse-a-page-range
text: handler; for: prompt handler configuration; url: dfn-handler
text: process capabilities; url: dfn-capabilities-processing
Expand Down Expand Up @@ -659,6 +661,7 @@ ErrorCode = "invalid argument" /
"invalid session id" /
"invalid web extension" /
"move target out of bounds" /
"no response body" /
"no such alert" /
"no such element" /
"no such frame" /
Expand All @@ -667,6 +670,7 @@ ErrorCode = "invalid argument" /
"no such intercept" /
"no such node" /
"no such request" /
"no such response" /
"no such script" /
"no such storage partition" /
"no such user context" /
Expand Down Expand Up @@ -5383,6 +5387,7 @@ NetworkCommand = (
network.ContinueResponse //
network.ContinueWithAuth //
network.FailRequest //
network.GetResponseBody //
network.ProvideResponse //
network.RemoveIntercept //
network.SetCacheBehavior
Expand Down Expand Up @@ -5412,6 +5417,23 @@ A [=remote end=] has a <dfn>before request sent map</dfn> which is initially an
empty map. It's used to track the network events for which a
<code>network.beforeRequestSent</code> event has already been sent.

A [=remote end=] has a <dfn>response map</dfn> that maps a [=request id=]
to [=/response=]. Responses must be removed on the following conditions:

- when a browsing context group switch or destruction happens, responses
associated with the previous browsing context group are removed.

- when a navigation commits a new document, resources associated with the
previous document are removed.

- when a worker scope is removed the responses provided by the worker are
removed.

- when a user-configured (command to be defined) per navigable size limit is
exceeded, the oldest response body is evicted until there is space for
the new body. Evicted resources should result in a distinct error
code.

A [=remote end=] has a <dfn>default cache behavior</dfn> which is a string. It is
initially "<code>default</code>".

Expand Down Expand Up @@ -7156,6 +7178,63 @@ The [=remote end steps=] given |session| and |command parameters| are:

</div>

#### The network.getResponseBody Command #### {#command-network-getResponseBody}

The <dfn export for=commands>network.getResponseBody</dfn> command retrieved the
response body data if it is available.

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
network.GetResponseBody = (
method: "network.getResponseBody",
params: network.GetResponseBodyParameters
)

network.GetResponseBodyParameters = {
request: network.Request,
}
</pre>
</dd>
<dt>Return Type</dt>
<dd>
<pre class="cddl local-cddl">
script.GetResponseBodyResult = {
body: network.BytesValue,
}
</pre>
</dd>
</dl>

<div algorithm="remote end steps for network.getResponseBody">
The [=remote end steps=] given <var ignore>session</var> and |command parameters| are:

1. Let |request id| be |command parameters|["<code>request</code>"].

1. If [=response map=] does not [=map/contain=] |request id|:

1. Return [=error=] with [=error code=] [=no such response=].

1. Let |response| be [=response map=][|request id|].

1. If |response|'s [=response/body=] is null,

1. Return [=error=] with [=error code=] [=no response body=].

Issue: what do we do with bodies that are too large? The limit is often
determined on the transport level and the implementation might not know
it.

1. Let |body| be a [=/map=] matching the <code>script.GetResponseBodyResult</code> production,
with the <code>body</code> field set to base-64 encoded value of |response|'s [=response/body=].
TODO: specify exact steps how to read the body.

1. Return [=success=] with data |body|.

</div>


#### The network.provideResponse Command #### {#command-network-provideResponse}

The <dfn export for=commands>network.provideResponse</dfn> command continues a
Expand Down Expand Up @@ -7653,6 +7732,9 @@ completed</dfn> steps given |request| and |response|:
[=request/client=]. Otherwise let |related navigables| be an empty
set.

1. If the implementation is configured to save response data for |request|,
set [=response map=][|request|'s [=request id=]] to |response|.

1. For each |session| in the [=set of sessions for which an event is enabled=]
given "<code>network.responseCompleted</code>" and |related navigables|:

Expand Down