Skip to content

Commit

Permalink
Add a command to get response body
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jan 17, 2025
1 parent 374e7ba commit 9444817
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 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,9 @@ 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=]. Implementations may remove data from [=response map=] map at any time.

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 +7164,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 +7718,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

0 comments on commit 9444817

Please sign in to comment.