Skip to content

Commit

Permalink
Rebase onto network.BytesValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Jul 5, 2023
1 parent f15a14a commit cc4ea59
Showing 1 changed file with 12 additions and 53 deletions.
65 changes: 12 additions & 53 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3502,7 +3502,7 @@ intecept id and a [=tuple=] with fields <code>url patterns</code> and
is initially empty.

A [=BiDi session=] has an <dfn>blocked request map</dfn>, used to track the
requests which are actively being blocked. It is an [=map=] between request id
requests which are actively being blocked. It is an [=/map=] between request id
and a [=tuple=] with fields <code>request</code>, <code>phase</code>, and
<code>response</code>. It is initially empty. It's

Expand Down Expand Up @@ -3681,39 +3681,6 @@ To <dfn>process a network event</dfn> given |session|, |event|, and |request|:

</div>

#### The network.Body Type #### {#type-network-Body}

<pre class="cddl local-cddl remote-cddl">
network.Body = network.StringBody / network.Base64Body;

network.StringBody = {
type: "string",
value: text,
}

network.Base64Body = {
type: "base64",
value: text
}
</pre>

The <code>network.Body</code> type represents a request or response body,
possibly encoded.

<div algorithm>
To <dfn>get the body</dfn> given |protocol body|:

1. If |protocol body| matches the <code>network.StringBody</code> production,
let |body| be |protocol body|["<code>value</code>"].

1. Otherwise if |protocol body| matches the
<code>network.Base64Body</code>production. Let |body| be [=forgiving-base64
decode=] |protocol body|["<code>value</code>"].

1. Return |body|

</div>

#### The network.BytesValue Type #### {#type-network-Body}

<pre class="cddl local-cddl remote-cddl">
Expand All @@ -3736,7 +3703,7 @@ type, any other data is represented in Base64-encoded form as
<code>network.Base64Body</code>.

<div algorithm>
To <dfn ignore>deserialize protocol bytes</dfn> given |protocol bytes|:
To <dfn>deserialize protocol bytes</dfn> given |protocol bytes|:

Note: this takes bytes encoded as a <code>network.BytesValue</code> and returns
a [=byte sequence=].
Expand Down Expand Up @@ -3789,7 +3756,7 @@ network.Cookie = {
The <code>network.Cookie</code> type represents a cookie.

<div algorithm>
To <dfn>get a cookie</dfn> given |stored cookie|:
To <dfn>serialize cookie</dfn> given |stored cookie|:

Note: The definitions of |stored cookie|'s fields are from [[COOKIES]], except
samesite-flag, which is from [[SAME-SITE-COOKIES]].
Expand Down Expand Up @@ -3954,21 +3921,12 @@ To <dfn>serialize header</dfn> given |name bytes| and |value bytes|:
</div>

<div algorithm>
To <dfn>serialize a header</dfn> given |header|:

1. Let |name| be the result of [=UTF-8 encode=] with
|header|["<code>name</code>"].

1. If |header| [=map/contains=] "<code>value</code>", let |value| be [=UTF-8
encode=] |header|["<code>value</code>"].
To <dfn>deserialize header</dfn> given |protocol header|:

1. If |header| [=map/contains=] "<code>binaryValue</code>":
1. Let |name| be [=UTF-8 encode=] |protocol header|["<code>name</code>"].

1. Let <code>value</code> be an empty [=byte sequence=].

1. For each |byte| in |header|["<code>binaryValue</code>"]:

1. Append |byte| to |value|
1. Let |value| be [=deserialize protocol bytes=] with |protocol
header|["<code>value</code>"].

1. Return a [=/header=] (|name|, |value|).

Expand Down Expand Up @@ -4114,7 +4072,7 @@ To <dfn>get the request data</dfn> given |request|:
the store can be included in a request, but user agents are free to
impose additional constraints.

1. Append the result of [=get a cookie=] given |cookie| to |cookies|.
1. Append the result of [=serialize cookie=] given |cookie| to |cookies|.

1. Let |timings| be [=get the fetch timings=] with |request|.

Expand Down Expand Up @@ -4403,7 +4361,7 @@ The [=remote end steps=] given |session| and |command parameters| are:

1. If |command parameters| [=map/contains=] "<code>body</code>":

1. Let |body| be [=deserialize bytes=] with |command
1. Let |body| be [=deserialize protocol bytes=] with |command
parameters|["<code>body</code>"].

1. Set |request|'s [=request/body=] to |body|.
Expand Down Expand Up @@ -4671,7 +4629,7 @@ response and bypassing any further network request processing.

network.ProvideResponseParameters = {
request: network.Request,
?body: network.Body,
?body: network.BytesValue,
?headers: [*network.Header],
?reasonPhrase: text,
?statusCode: js-uint,
Expand All @@ -4696,7 +4654,8 @@ The [=remote end steps=] given |session| and |command parameters| are:

1. If |command parameters| [=map/contains=] "<code>body</code>":

1. Let |body| be [=get the body=] with |command parameters["<code>body</code>"].
1. Let |body| be [=deserialize protocol bytes=] with |command
parameters["<code>body</code>"].

1. Set |response|'s [=response/body=] to |body| [=as a body=].

Expand Down

0 comments on commit cc4ea59

Please sign in to comment.