diff --git a/index.bs b/index.bs index 2c3683824..b0b02dadd 100644 --- a/index.bs +++ b/index.bs @@ -3611,6 +3611,60 @@ To get the base network event data given |request| and |redirect coun +#### The network.BytesValue Type #### {#type-network-Body} + +
+network.BytesValue = network.StringValue / network.Base64Value;
+
+network.StringValue = {
+  type: "string",
+  value: text,
+}
+
+network.Base64Value = {
+  type: "base64",
+  value: text
+}
+
+ +The network.BytesValue type represents binary data sent over the +network. Valid UTF-8 is represented with the network.StringValue +type, any other data is represented in Base64-encoded form as +network.Base64Body. + +
+To deserialize protocol bytes given |protocol bytes|: + +Note: this takes bytes encoded as a network.BytesValue and returns +a [=byte sequence=]. + +1. If |protocol bytes| matches the network.StringValue production, + let |bytes| be [=UTF-8 encode=] |protocol bytes|["value"]. + +1. Otherwise if |protocol bytes| matches the network.Base64Value + production. Let |bytes| be [=forgiving-base64 decode=] |protocol + bytes|["value"]. + +1. Return |bytes|. + +
+ +
+To serialize protocol bytes given |bytes|: + +Note: this takes a [=byte sequence=] and returns a network.BytesValue. + +1. If |bytes| matches the network.StringValue production, + let |protocol value| be [=UTF-8 encode=] |bytes|["value"]. + +1. Otherwise if |bytes| matches the network.Base64Value + production. Let |protocol value| be [=forgiving-base64 decode=] + |bytes|["value"]. + +1. Return |protocol value| + +
+ #### The network.Cookie Type #### {#type-network-Cookie} [=Remote end definition=] and [=local end definition=] @@ -3618,8 +3672,7 @@ To get the base network event data given |request| and |redirect coun
 network.Cookie = {
     name: text,
-    ? value: text,
-    ? binaryValue: [ uint ]
+    value: network.BytesValue,
     domain: text,
     path: text,
     ? expires: js-uint,
@@ -3632,11 +3685,6 @@ network.Cookie = {
 
 The network.Cookie type represents a cookie.
 
-If the cookie value can be represented as a UTF-8 encoded string, the
-value field will be present. Otherwise the binaryValue
-field will be present and consist of an array of integers representing the bytes
-of the cookie value.
-
 
To get a cookie given |stored cookie|: @@ -3645,18 +3693,7 @@ samesite-flag, which is from [[SAME-SITE-COOKIES]]. 1. Let |name| be the result of [=UTF-8 decode=] with |stored cookie|'s name field. -1. Let |utf8 decoded value| be the result of [=UTF-8 decode without BOM or fail=] - with |stored cookie|'s value. - -1. If |utf8 decoded value| is failure, then: - - 1. Let |value| be null and |binary value| be an empty list. - - 1. For each |byte| in |stored cookie|'s value: - - 1. Append the [=byte/value=] of |byte| to |binary value|. - - Otherwise: Let |value| be |utf8 decoded value| and |binary value| be null. +1. Let |value| be [=serialize protocol bytes=] with |stored cookie|'s value. 1. Let |domain| be |stored cookie|'s domain field. @@ -3680,9 +3717,7 @@ samesite-flag, which is from [[SAME-SITE-COOKIES]]. 1. Return a map matching the network.Cookie production, with the name field set to |name|, the value field - set to |value| if it's not null or omitted otherwise, the - binaryValue field set to |binary value| if it's not null or - omitted otherwise, the domain field set to |domain|, the + set to |value|, the domain field set to |domain|, the path field set to |path|, the expires field set to |expires| if it's not null, or omitted otherwise, the size field set to |size|, the httpOnly field set to |http only|, the @@ -3793,45 +3828,25 @@ TODO: Add service worker fields
 network.Header = {
-    name: text,
-    ? value: text,
-    ? binaryValue: [ uint ]
-};
+  name: text,
+  value: network.BytesValue
+}
 
The network.Header type represents a single request header. -If the header value can be represented as a UTF-8 encoded string, the -value field will be present. Otherwise the binaryValue -field will be present and consist of an array of integers representing the bytes -of the header. -
-To get a header given |name bytes| and |value bytes|: +To serialize header given |name bytes| and |value bytes|: 1. Let |name| be the result of [=UTF-8 decode=] with |name bytes|. Assert: Since header names are constrained to be ASCII-only this cannot fail. -1. Let |utf8 decoded value| be the result of [=UTF-8 decode without BOM or fail=] - with |value bytes|. - -1. If |utf8 decoded value| is failure, then: - - 1. Let |value| be null and |binary value| be an empty list. - - 1. For each |byte| in |value bytes|: - - 1. Append the [=byte/value=] of |byte| to |binary value|. - - Otherwise: let |value| be |utf8 decoded value| and let |binary value| - be null. +1. Let |value| be [=serialize protocol bytes=] with |value bytes|. 1. Return a map matching the network.Header production, with the - name field set to |name|, the value field - set to |value| if it's not null, or omitted otherwise, and the - binaryValue field set to |binary value| if it's not null, or - omitted otherwise. + name field set to |name|, and the value field + set to |value|.
@@ -3954,7 +3969,7 @@ To get the request data given |request|: 1. For each (|name|, |value|) in |request|'s [=request/headers list=]: - 1. Append the result of [=get a header=] with |name| and |value| to |headers|. + 1. Append the result of [=serialize header=] with |name| and |value| to |headers|. 1. If |name| is a [=byte-case-insensitive=] match for "Cookie" then: @@ -4089,7 +4104,7 @@ To get the response data given |response|: 1. For each (|name|, |value|) in |response|'s [=response/headers list=]: - 1. Append the result of [=get a header=] with |name| and |value| to |headers|. + 1. Append the result of [=serialize header=] with |name| and |value| to |headers|. 1. Let |bytes received| be the total number of bytes transmitted as part of the HTTP response associated with |response|.