Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return null if parsing a structured field value fails #1056

Merged
merged 3 commits into from
Jul 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 19 additions & 17 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ url:https://tools.ietf.org/html/rfc7230#section-3.2;text:field-content;type:dfn;
url:https://tools.ietf.org/html/rfc7230#section-3.2;text:field-value;type:dfn;spec:http
url:https://tools.ietf.org/html/rfc7230#section-3.1.2;text:reason-phrase;type:dfn;spec:http
url:https://tools.ietf.org/html/rfc7234#section-1.2.1;text:delta-seconds;type:dfn;spec:http-caching
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-2;text:structured header value;type:dfn;spec:header-structure
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.1;text:serializing structured headers;type:dfn;spec:header-structure
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.2;text:parsing structured headers;type:dfn;spec:header-structure
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-2;text:structured field value;type:dfn;spec:header-structure
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.1;text:serializing structured fields;type:dfn;spec:header-structure
url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.2;text:parsing structured fields;type:dfn;spec:header-structure
</pre>

<pre class=biblio>
Expand Down Expand Up @@ -75,9 +75,7 @@ url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.2;
"title": "HTTP proxy default configurations allow arbitrary TCP connections."
},
"EXPECT-CT": {
"authors": [
"Emily Stark"
],
"authors": ["Emily Stark"],
"href": "https://tools.ietf.org/html/draft-ietf-httpbis-expect-ct-02",
"publisher": "IETF",
"title": "Expect-CT Extension for HTTP"
Expand All @@ -86,10 +84,10 @@ url:https://tools.ietf.org/html/draft-ietf-httpbis-header-structure#section-4.2;
"aliasOf": "RFC2560"
},
"HEADER-STRUCTURE": {
"authors": ["Mark Nottingham","Paul-Henning Kamp"],
"authors": ["Mark Nottingham", "Poul-Henning Kamp"],
"href": "https://tools.ietf.org/html/draft-ietf-httpbis-header-structure",
"publisher": "IETF",
"title": "Structured Headers for HTTP"
"title": "Structured Field Values for HTTP"
}
}
</pre>
Expand Down Expand Up @@ -384,7 +382,7 @@ for consistency.
specialized multimap. An ordered list of key-value pairs with potentially duplicate keys.

<p>To
<dfn export for="header list" id=concept-header-list-get-structured-header>get a structured header</dfn>
<dfn export for="header list" id=concept-header-list-get-structured-header>get a structured field value</dfn>
given a <var>name</var> and a <var>type</var> from a <a for=/>header list</a> <var>list</var>, run
these steps:

Expand All @@ -397,28 +395,32 @@ these steps:

<li><p>If <var>value</var> is null, then return null.

<li><p>Let <var>result</var> be the result of executing the <a>parsing structured headers</a>
algorithm with <var ignore>input_string</var> set to <var>value</var>, and
<var ignore>header_type</var> set to <var>type</var>.
<li><p>Let <var>result</var> be the result of <a>parsing structured fields</a> with
<var ignore>input_string</var> set to <var>value</var> and <var ignore>header_type</var> set to
<var>type</var>.

<li><p>If parsing failed, then return failure.
<li><p>If parsing failed, then return null.
annevk marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Return <var>result</var>.
</ol>

<p class="note"><a>Get a structured field value</a> intentionally does not distinguish between a
<a for=/>header</a> not being present and its <a for=header>value</a> failing to parse as a
<a>structured field value</a>. This ensures uniform processing across the web platform.

<p>To
<dfn export for="header list" id=concept-header-list-set-structured-header>set a structured header</dfn>
<a for=header>name</a>/<a>structured header value</a> <var>name</var>/<var>structuredValue</var>
<dfn export for="header list" id=concept-header-list-set-structured-header>set a structured field value</dfn>
<a for=header>name</a>/<a>structured field value</a> <var>name</var>/<var>structuredValue</var>
pair in a <a for=/>header list</a> <var>list</var>, run these steps:

<ol>
<li><p>Let <var>serializedValue</var> be the result of executing the
<a>serializing structured headers</a> algorithm on <var>structuredValue</var>.
<a>serializing structured fields</a> algorithm on <var>structuredValue</var>.

<li><p><a for="header list">Set</a> <var>name</var>/<var>serializedValue</var> in <var>list</var>.
</ol>

<p class=note><a>Structured header values</a> are defined as objects which HTTP can (eventually)
<p class=note><a>Structured field values</a> are defined as objects which HTTP can (eventually)
serialize in interesting and efficient ways. For the moment, Fetch only supports <a for=/>header</a>
<a for=header>values</a> as <a for=/>byte sequences</a>, which means that these objects can be set
in <a for=/>header lists</a> only via serialization, and they can be obtained from
Expand Down