Skip to content

Commit

Permalink
Define get(All)ResponseHeader(s) in terms of Fetch
Browse files Browse the repository at this point in the history
Fixes #50.
  • Loading branch information
annevk committed Jun 7, 2016
1 parent 4be9ce5 commit ecce390
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 42 deletions.
55 changes: 34 additions & 21 deletions Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -1335,19 +1335,15 @@ <h4 id="the-getresponseheader()-method"><span class="secno">4.6.4 </span>The <co

<ol>
<li><p>If <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a> has
multiple <a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header" title="concept-header">headers</a> whose
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-name" title="concept-header-name">name</a> is <var>name</var>,
return their <a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-value" title="concept-header-value">values</a> in
list order as a single byte sequence separated from each other by a 0x2C 0x20 byte pair.

<li><p>If <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a> has
one <a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header" title="concept-header">header</a> whose
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-name" title="concept-header-name">name</a> is <var>name</var>,
return its <a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-value" title="concept-header-value">value</a>.

<li><p>Return null.
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a> has <em>no</em>
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header" title="concept-header">header</a> whose
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, then return
null.

<li><p>Return the
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-value-combined" title="concept-header-value-combined">combined value</a> given
<var>name</var> and <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a>.
</ol>

<p class="note no-backref">The Fetch Standard filters <a href="#response">response</a>'s
Expand Down Expand Up @@ -1378,14 +1374,31 @@ <h4 id="the-getallresponseheaders()-method"><span class="secno">4.6.5 </span>The

<p>The
<dfn id="dom-xmlhttprequest-getallresponseheaders" title="dom-XMLHttpRequest-getAllResponseHeaders"><code>getAllResponseHeaders()</code></dfn>
method must return <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a>, in
list order, as a single byte sequence with each
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header" title="concept-header">header</a> separated by a 0x0D 0x0A
byte pair, and each <a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-name" title="concept-header-name">name</a> and
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-value" title="concept-header-value">value</a> of a
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header" title="concept-header">header</a> separated by a 0x3A 0x20
byte pair.
method, when invoked, must run these steps:</p>

<ol>
<li><p>Let <var>output</var> be an empty byte sequence.

<li><p>Let <var>headers</var> be the result of running
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine" title="concept-header-list-sort-and-combine">sort and combine</a>
with <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a>.

<li>
<p>For each <var>header</var> in <var>headers</var>, run these substeps:

<ol>
<li><p>Append <var>header</var>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-name" title="concept-header-name">name</a>, followed by a 0x3A 0x20 byte
pair, followed by <var>header</var>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-header-value" title="concept-header-value">value</a>, to <var>output</var>.

<li><p>If <var>header</var> is not the last pair in <var>headers</var>, then append a 0x0D 0x0A
byte pair, to <var>output</var>.
</ol>

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

<p class="note no-backref">The Fetch Standard filters <a href="#response">response</a>'s
<a class="external" data-anolis-spec="fetch" href="https://fetch.spec.whatwg.org/#concept-response-header-list" title="concept-response-header-list">header list</a>.
Expand Down
55 changes: 34 additions & 21 deletions Overview.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -1287,19 +1287,15 @@ <h4>The <code title>getResponseHeader()</code> method</h4>

<ol>
<li><p>If <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span> has
multiple <span data-anolis-spec=fetch title=concept-header>headers</span> whose
<span data-anolis-spec=fetch title=concept-header-name>name</span> is <var>name</var>,
return their <span data-anolis-spec=fetch title=concept-header-value>values</span> in
list order as a single byte sequence separated from each other by a 0x2C 0x20 byte pair.

<li><p>If <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span> has
one <span data-anolis-spec=fetch title=concept-header>header</span> whose
<span data-anolis-spec=fetch title=concept-header-name>name</span> is <var>name</var>,
return its <span data-anolis-spec=fetch title=concept-header-value>value</span>.

<li><p>Return null.
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span> has <em>no</em>
<span data-anolis-spec=fetch title=concept-header>header</span> whose
<span data-anolis-spec=fetch title=concept-header-name>name</span> is <var>name</var>, then return
null.

<li><p>Return the
<span data-anolis-spec=fetch title=concept-header-value-combined>combined value</span> given
<var>name</var> and <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span>.
</ol>

<p class="note no-backref">The Fetch Standard filters <span>response</span>'s
Expand Down Expand Up @@ -1330,14 +1326,31 @@ <h4>The <code title>getAllResponseHeaders()</code> method</h4>

<p>The
<dfn title="dom-XMLHttpRequest-getAllResponseHeaders"><code>getAllResponseHeaders()</code></dfn>
method must return <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span>, in
list order, as a single byte sequence with each
<span data-anolis-spec=fetch title=concept-header>header</span> separated by a 0x0D 0x0A
byte pair, and each <span data-anolis-spec=fetch title=concept-header-name>name</span> and
<span data-anolis-spec=fetch title=concept-header-value>value</span> of a
<span data-anolis-spec=fetch title=concept-header>header</span> separated by a 0x3A 0x20
byte pair.
method, when invoked, must run these steps:</p>

<ol>
<li><p>Let <var>output</var> be an empty byte sequence.

<li><p>Let <var>headers</var> be the result of running
<span data-anolis-spec=fetch title=concept-header-list-sort-and-combine>sort and combine</span>
with <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span>.

<li>
<p>For each <var>header</var> in <var>headers</var>, run these substeps:

<ol>
<li><p>Append <var>header</var>'s
<span data-anolis-spec=fetch title=concept-header-name>name</span>, followed by a 0x3A 0x20 byte
pair, followed by <var>header</var>'s
<span data-anolis-spec=fetch title=concept-header-value>value</span>, to <var>output</var>.

<li><p>If <var>header</var> is not the last pair in <var>headers</var>, then append a 0x0D 0x0A
byte pair, to <var>output</var>.
</ol>

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

<p class="note no-backref">The Fetch Standard filters <span>response</span>'s
<span data-anolis-spec=fetch title=concept-response-header-list>header list</span>.
Expand Down

0 comments on commit ecce390

Please sign in to comment.