Skip to content

Commit

Permalink
Rebase onto network.BytesValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham authored and jrandolf-2 committed Jul 6, 2023
1 parent 33d5668 commit 2b90cd8
Showing 1 changed file with 13 additions and 54 deletions.
67 changes: 13 additions & 54 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3503,7 +3503,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 @@ -3682,40 +3682,7 @@ 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-BytesValue}
#### The network.BytesValue Type #### {#type-network-Body}

<pre class="cddl local-cddl remote-cddl">
network.BytesValue = network.StringValue / network.Base64Value;
Expand All @@ -3737,7 +3704,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 @@ -3790,7 +3757,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 @@ -3955,21 +3922,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 @@ -4115,7 +4073,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 @@ -4404,7 +4362,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 @@ -4672,7 +4630,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 @@ -4697,7 +4655,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 2b90cd8

Please sign in to comment.