Skip to content

Commit

Permalink
"Get" a structured header from a header list.
Browse files Browse the repository at this point in the history
As discussed in #930 and WICG/cross-origin-embedder-policy#2, this patch adds a "get"
method on header lists that allows consistent extraction of
structured headers.
  • Loading branch information
mikewest committed Dec 13, 2019
1 parent b93383c commit 4c7978e
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ url:https://tools.ietf.org/html/rfc7230#section-3.1.2;text:reason-phrase;type:df
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
</pre>

<pre class=biblio>
Expand Down Expand Up @@ -584,10 +585,32 @@ pair in a <a for=/>header list</a> <var>list</var>, run these steps:
<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)
serialize in interesting and efficient ways. For the moment, Fetch only supports setting these
objects in <a for=/>header lists</a> by serializing them. In the future the fact that they are
objects might be preserved end-to-end. [[!HEADER-STRUCTURE]]
<p>To
<dfn export for="header list" id=concept-header-list-get-structured-header>get a structured header</dfn>
given a <var>name</var> and a <var>type</var> from a <a for=/>header list</a> <var>list</var>, run
these steps:

<ol>
<li><p>If <var>type</var> is not one of "<code>dictionary</code>", "<code>list</code>", or
"<code>item</code>", return failure.
<li><p>Let <var>value</var> be the result of <a for="header list">getting</a> <var>name</var> from
<var>list</var>.
<li><p>If <var>value</var> is null, 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>If parsing failed, return failure.
<li><p>Return <var>result</var>.
</ol>

<p class=note><a>Structured header 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>, setting these objects in <a for=/>header
lists</a> by serializing them, and supports getting these objects from <a for=/>header lists</a> by
parsing them. In the future the fact that they are objects might be preserved end-to-end.
[[!HEADER-STRUCTURE]]

</div>

<p>To <dfn export for="header list" id=concept-header-list-combine>combine</dfn> a
<a for=header>name</a>/<a for=header>value</a> <var>name</var>/<var>value</var> pair in a
Expand Down

0 comments on commit 4c7978e

Please sign in to comment.