Skip to content

Commit 42464c8

Browse files
committed
Fix #189: expose headers as a basic map in Headers
This removes the getAll() method and changes the semantics of get() and iteration. This was done as only cookies warrant a special case and they will never be exposed through this API.
1 parent e54f6bd commit 42464c8

2 files changed

Lines changed: 77 additions & 45 deletions

File tree

Overview.html

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<p><a class="logo" href="https://whatwg.org/"><img alt="WHATWG" height="100" src="https://resources.whatwg.org/logo-fetch.svg" width="100"></a>
99
<h1 id="cors">Fetch</h1>
10-
<h2 class="no-num no-toc" id="living-standard-—-last-updated-27-january-2016">Living Standard — Last Updated 27 January 2016</h2>
10+
<h2 class="no-num no-toc" id="living-standard-—-last-updated-28-january-2016">Living Standard — Last Updated 28 January 2016</h2>
1111

1212
<dl>
1313
<dt>Participate:
@@ -386,6 +386,13 @@ <h4 id="terminology-headers"><span class="secno">3.1.2 </span>Headers</h4>
386386
<a href="#concept-header-value" title="concept-header-value">value</a>, remove any leading and trailing
387387
<a href="#http-whitespace-bytes">HTTP whitespace bytes</a> from it.
388388

389+
<p>A <dfn id="concept-header-value-combined" title="concept-header-value-combined">combined value</dfn>, given a
390+
<a href="#concept-header-name" title="concept-header-name">name</a> (<var>name</var>) and
391+
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), is the
392+
<a href="#concept-header-value" title="concept-header-value">values</a> of all <a href="#concept-header" title="concept-header">headers</a> in
393+
<var>list</var> whose <a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, separated from
394+
each other by `<code title="">,</code>`, in order.
395+
389396
<hr>
390397

391398
<p>A <dfn id="simple-header">simple header</dfn> is a <a href="#concept-header" title="concept-header">header</a> whose
@@ -3208,7 +3215,6 @@ <h3 id="headers-class"><span class="secno">6.1 </span>Headers class</h3>
32083215
void <a href="#dom-headers-append" title="dom-Headers-append">append</a>(ByteString <var>name</var>, ByteString <var>value</var>);
32093216
void <a href="#dom-headers-delete" title="dom-Headers-delete">delete</a>(ByteString <var>name</var>);
32103217
ByteString? <a href="#dom-headers-get" title="dom-Headers-get">get</a>(ByteString <var>name</var>);
3211-
sequence&lt;ByteString&gt; <a href="#dom-headers-getall" title="dom-Headers-getAll">getAll</a>(ByteString <var>name</var>);
32123218
boolean <a href="#dom-headers-has" title="dom-Headers-has">has</a>(ByteString <var>name</var>);
32133219
void <a href="#dom-headers-set" title="dom-Headers-set">set</a>(ByteString <var>name</var>, ByteString <var>value</var>);
32143220
iterable&lt;ByteString, ByteString&gt;;
@@ -3356,24 +3362,12 @@ <h3 id="headers-class"><span class="secno">6.1 </span>Headers class</h3>
33563362
<li><p>If <var>name</var> is not a <a href="#concept-header-name" title="concept-header-name">name</a>,
33573363
<a class="external" data-anolis-spec="webidl" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code title="">TypeError</code>.
33583364

3359-
<li><p>Return the <a href="#concept-header-value" title="concept-header-value">value</a> of the first
3360-
<a href="#concept-header" title="concept-header">header</a> in
3365+
<li><p>If there is <em>no</em> <a href="#concept-header" title="concept-header">header</a> in
33613366
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a> whose
3362-
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, and null otherwise.
3363-
</ol>
3364-
3365-
<p>The <dfn id="dom-headers-getall" title="dom-Headers-getAll"><code>getAll(<var>name</var>)</code></dfn> method,
3366-
when invoked, must run these steps:
3367-
3368-
<ol>
3369-
<li><p>If <var>name</var> is not a <a href="#concept-header-name" title="concept-header-name">name</a>,
3370-
<a class="external" data-anolis-spec="webidl" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code title="">TypeError</code>.
3367+
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, return null.
33713368

3372-
<li><p>Return the <a href="#concept-header-value" title="concept-header-value">values</a> of all
3373-
<a href="#concept-header" title="concept-header">headers</a> in
3374-
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a> whose
3375-
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, in list order, and
3376-
the empty sequence otherwise.
3369+
<li><p>Return the <a href="#concept-header-value-combined" title="concept-header-value-combined">combined value</a> given
3370+
<var>name</var> and <a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a>.
33773371
</ol>
33783372

33793373
<p>The <dfn id="dom-headers-has" title="dom-Headers-has"><code>has(<var>name</var>)</code></dfn> method,
@@ -3421,11 +3415,33 @@ <h3 id="headers-class"><span class="secno">6.1 </span>Headers class</h3>
34213415
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a>.
34223416
</ol>
34233417

3424-
<p>The <a class="external" data-anolis-spec="webidl" href="https://heycam.github.io/webidl/#dfn-value-pairs-to-iterate-over">value pairs to iterate over</a> are the
3425-
<a href="#concept-header" title="concept-header">headers</a> in the
3426-
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a> with the key being the
3427-
<a href="#concept-header-name" title="concept-header-name">name</a> and value the
3428-
<a href="#concept-header-value" title="concept-header-value">value</a>.
3418+
<p>The <a class="external" data-anolis-spec="webidl" href="https://heycam.github.io/webidl/#dfn-value-pairs-to-iterate-over">value pairs to iterate over</a> are the return value of
3419+
running these steps:
3420+
3421+
<ol>
3422+
<li><p>Let <var>headers</var> be an empty list of
3423+
<a href="#concept-header-name" title="concept-header-name">name</a>-<a href="#concept-header-value" title="concept-header-value">value</a> pairs
3424+
with the key being the <a href="#concept-header-name" title="concept-header-name">name</a> and value the
3425+
<a href="#concept-header-value" title="concept-header-value">value</a>.
3426+
3427+
<li><p>Let <var>names</var> be all the <a href="#concept-header-name" title="concept-header-name">names</a> of the
3428+
<a href="#concept-header" title="concept-header">headers</a> in the
3429+
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a>, with duplicates removed, and sorted
3430+
lexicographically.
3431+
3432+
<li>
3433+
<p>For each <var>name</var> in <var>names</var>, run these substeps:
3434+
3435+
<ol>
3436+
<li><p>Let <var>value</var> be the
3437+
<a href="#concept-header-value-combined" title="concept-header-value-combined">combined value</a> given <var>name</var> and
3438+
<a href="#concept-headers-header-list" title="concept-Headers-header-list">header list</a>.
3439+
3440+
<li><p>Append <var>name</var>-<var>value</var> to <var>headers</var>.
3441+
</ol>
3442+
3443+
<li><p>Return <var>headers</var>
3444+
</ol>
34293445

34303446

34313447
<h3 id="body-mixin"><span class="secno">6.2 </span>Body mixin</h3>

Overview.src.html

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ <h4 id=terminology-headers>Headers</h4>
325325
<span title=concept-header-value>value</span>, remove any leading and trailing
326326
<span>HTTP whitespace bytes</span> from it.
327327

328+
<p>A <dfn title=concept-header-value-combined>combined value</dfn>, given a
329+
<span title=concept-header-name>name</span> (<var>name</var>) and
330+
<span title=concept-header-list>header list</span> (<var>list</var>), is the
331+
<span title=concept-header-value>values</span> of all <span title=concept-header>headers</span> in
332+
<var>list</var> whose <span title=concept-header-name>name</span> is <var>name</var>, separated from
333+
each other by `<code title>,</code>`, in order.
334+
328335
<hr>
329336

330337
<p>A <dfn>simple header</dfn> is a <span title=concept-header>header</span> whose
@@ -3147,7 +3154,6 @@ <h3>Headers class</h3>
31473154
void <span title=dom-Headers-append>append</span>(ByteString <var>name</var>, ByteString <var>value</var>);
31483155
void <span title=dom-Headers-delete>delete</span>(ByteString <var>name</var>);
31493156
ByteString? <span title=dom-Headers-get>get</span>(ByteString <var>name</var>);
3150-
sequence&lt;ByteString> <span title=dom-Headers-getAll>getAll</span>(ByteString <var>name</var>);
31513157
boolean <span title=dom-Headers-has>has</span>(ByteString <var>name</var>);
31523158
void <span title=dom-Headers-set>set</span>(ByteString <var>name</var>, ByteString <var>value</var>);
31533159
iterable&lt;ByteString, ByteString>;
@@ -3295,24 +3301,12 @@ <h3>Headers class</h3>
32953301
<li><p>If <var>name</var> is not a <span title=concept-header-name>name</span>,
32963302
<span data-anolis-spec=webidl>throw</span> a <code title>TypeError</code>.
32973303

3298-
<li><p>Return the <span title=concept-header-value>value</span> of the first
3299-
<span title=concept-header>header</span> in
3304+
<li><p>If there is <em>no</em> <span title=concept-header>header</span> in
33003305
<span title=concept-Headers-header-list>header list</span> whose
3301-
<span title=concept-header-name>name</span> is <var>name</var>, and null otherwise.
3302-
</ol>
3303-
3304-
<p>The <dfn title=dom-Headers-getAll><code>getAll(<var>name</var>)</code></dfn> method,
3305-
when invoked, must run these steps:
3306-
3307-
<ol>
3308-
<li><p>If <var>name</var> is not a <span title=concept-header-name>name</span>,
3309-
<span data-anolis-spec=webidl>throw</span> a <code title>TypeError</code>.
3306+
<span title=concept-header-name>name</span> is <var>name</var>, return null.
33103307

3311-
<li><p>Return the <span title=concept-header-value>values</span> of all
3312-
<span title=concept-header>headers</span> in
3313-
<span title=concept-Headers-header-list>header list</span> whose
3314-
<span title=concept-header-name>name</span> is <var>name</var>, in list order, and
3315-
the empty sequence otherwise.
3308+
<li><p>Return the <span title=concept-header-value-combined>combined value</span> given
3309+
<var>name</var> and <span title=concept-Headers-header-list>header list</span>.
33163310
</ol>
33173311

33183312
<p>The <dfn title=dom-Headers-has><code>has(<var>name</var>)</code></dfn> method,
@@ -3360,11 +3354,33 @@ <h3>Headers class</h3>
33603354
<span title=concept-Headers-header-list>header list</span>.
33613355
</ol>
33623356

3363-
<p>The <span data-anolis-spec=webidl>value pairs to iterate over</span> are the
3364-
<span title=concept-header>headers</span> in the
3365-
<span title=concept-Headers-header-list>header list</span> with the key being the
3366-
<span title=concept-header-name>name</span> and value the
3367-
<span title=concept-header-value>value</span>.
3357+
<p>The <span data-anolis-spec=webidl>value pairs to iterate over</span> are the return value of
3358+
running these steps:
3359+
3360+
<ol>
3361+
<li><p>Let <var>headers</var> be an empty list of
3362+
<span title=concept-header-name>name</span>-<span title=concept-header-value>value</span> pairs
3363+
with the key being the <span title=concept-header-name>name</span> and value the
3364+
<span title=concept-header-value>value</span>.
3365+
3366+
<li><p>Let <var>names</var> be all the <span title=concept-header-name>names</span> of the
3367+
<span title=concept-header>headers</span> in the
3368+
<span title=concept-Headers-header-list>header list</span>, with duplicates removed, and sorted
3369+
lexicographically.
3370+
3371+
<li>
3372+
<p>For each <var>name</var> in <var>names</var>, run these substeps:
3373+
3374+
<ol>
3375+
<li><p>Let <var>value</var> be the
3376+
<span title=concept-header-value-combined>combined value</span> given <var>name</var> and
3377+
<span title=concept-Headers-header-list>header list</span>.
3378+
3379+
<li><p>Append <var>name</var>-<var>value</var> to <var>headers</var>.
3380+
</ol>
3381+
3382+
<li><p>Return <var>headers</var>
3383+
</ol>
33683384

33693385

33703386
<h3>Body mixin</h3>

0 commit comments

Comments
 (0)