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
.
+
+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|.
+
+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|
+
+network.Cookie = { name: text, - ? value: text, - ? binaryValue: [ uint ] + value: network.BytesValue, domain: text, path: text, ? expires: js-uint, @@ -3632,11 +3685,6 @@ network.Cookie = { Thenetwork.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 thebinaryValue
-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 thenetwork.Cookie
production, with thename
field set to |name|, thevalue
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, thedomain
field set to |domain|, the + set to |value|, thedomain
field set to |domain|, thepath
field set to |path|, theexpires
field set to |expires| if it's not null, or omitted otherwise, thesize
field set to |size|, thehttpOnly
field set to |http only|, the @@ -3793,45 +3828,25 @@ TODO: Add service worker fieldsnetwork.Header = { - name: text, - ? value: text, - ? binaryValue: [ uint ] -}; + name: text, + value: network.BytesValue +}Thenetwork.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 thebinaryValue
-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@@ -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 "network.Header
production, with the -name
field set to |name|, thevalue
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 thevalue
field + set to |value|.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|.