@@ -6404,23 +6404,39 @@ new Headers(meta2);
6404
6404
6405
6405
<hr>
6406
6406
6407
- <p> To <dfn export for=Headers id=concept-headers-append>append </dfn> a <a for=/>header</a>
6408
- ( <var> name </var> , <var> value </var> ) to a {{Headers}} object <var> headers</var> , run these steps :
6407
+ <p> To <dfn for=Headers>validate </dfn> a <a for=/>header</a> ( <var> name </var> , <var> value </var> ) for
6408
+ a {{Headers}} object <var> headers</var> :
6409
6409
6410
6410
<ol>
6411
- <li><p> <a for="header value">Normalize</a> <var> value</var> .
6412
-
6413
6411
<li><p> If <var> name</var> is not a <a for=/>header name</a> or <var> value</var> is not a
6414
6412
<a for=/>header value</a> , then <a>throw</a> a {{TypeError}} .
6415
6413
6416
6414
<li><p> If <var> headers</var> 's <a for=Headers>guard</a> is "<code> immutable</code> ", then
6417
6415
<a>throw</a> a {{TypeError}} .
6418
6416
6419
- <li><p> Otherwise, if <var> headers</var> 's <a for=Headers>guard</a> is "<code> request</code> " and
6420
- (<var> name</var> , <var> value</var> ) is a <a>forbidden request-header</a> , return.
6417
+ <li><p> If <var> headers</var> 's <a for=Headers>guard</a> is "<code> request</code> " and
6418
+ (<var> name</var> , <var> value</var> ) is a <a>forbidden request-header</a> , then return false.
6419
+
6420
+ <li><p> If <var> headers</var> 's <a for=Headers>guard</a> is "<code> response</code> " and
6421
+ <var> name</var> is a <a>forbidden response-header name</a> , then return false.
6422
+
6423
+ <li><p> Return true.
6424
+ </ol>
6425
+
6426
+ <p class=note> Steps for "<code> request-no-cors</code> " are not shared as you cannot have a fake
6427
+ value (for {{Headers/delete()}} ) that always succeeds in <a>CORS-safelisted request-header</a> .
6428
+
6429
+ <p> To <dfn export for=Headers id=concept-headers-append>append</dfn> a <a for=/>header</a>
6430
+ (<var> name</var> , <var> value</var> ) to a {{Headers}} object <var> headers</var> , run these steps:
6431
+
6432
+ <ol>
6433
+ <li><p> <a for="header value">Normalize</a> <var> value</var> .
6434
+
6435
+ <li><p> If <a for=Headers>validating</a> (<var> name</var> , <var> value</var> ) for <var> headers</var>
6436
+ returns false, then return.
6421
6437
6422
6438
<li>
6423
- <p> Otherwise, if <var> headers</var> 's <a for=Headers>guard</a> is "<code> request-no-cors</code> ":
6439
+ <p> If <var> headers</var> 's <a for=Headers>guard</a> is "<code> request-no-cors</code> ":
6424
6440
6425
6441
<ol>
6426
6442
<li><p> Let <var> temporaryValue</var> be the result of <a for="header list">getting</a>
@@ -6436,9 +6452,6 @@ new Headers(meta2);
6436
6452
<a>no-CORS-safelisted request-header</a> , then return.
6437
6453
</ol>
6438
6454
6439
- <li><p> Otherwise, if <var> headers</var> 's <a for=Headers>guard</a> is "<code> response</code> " and
6440
- <var> name</var> is a <a>forbidden response-header name</a> , return.
6441
-
6442
6455
<li><p> <a for="header list">Append</a> (<var> name</var> , <var> value</var> ) to <var> headers</var> 's
6443
6456
<a for=Headers>header list</a> .
6444
6457
@@ -6498,27 +6511,19 @@ method steps are to <a for=Headers>append</a> (<var>name</var>, <var>value</var>
6498
6511
<p> The <dfn export for=Headers method><code>delete(<var>name</var>)</code></dfn> method steps are:
6499
6512
6500
6513
<ol>
6501
- <li><p> If <var> name</var> is not a <a for=/>header name</a> , then <a>throw</a> a {{TypeError}} .
6502
-
6503
- <li><p> If <a>this</a> 's <a for=Headers>guard</a> is "<code> immutable</code> ", then <a>throw</a> a
6504
- {{TypeError}} .
6505
-
6506
6514
<li>
6507
- <p> Otherwise, if <a>this </a>'s <a for=Headers>guard</a> is " <code> request </code> " and
6508
- ( <var> name </var> , ``) is a <a>forbidden request-header</a> , return.
6515
+ <p> If <a for=Headers>validating </a> ( <var> name </var> , ``) for <var> headers </var> returns false,
6516
+ then return.
6509
6517
6510
- <p class=note> Passing a dummy <a>header value</a> to <a>forbidden request-header</a> ought not to
6511
- have any negative repercussions.
6518
+ <p class=note> Passing a dummy <a>header value</a> ought not to have any negative repercussions.
6512
6519
6513
- <li><p> Otherwise, if <a>this</a> 's <a for=Headers>guard</a> is "<code> request-no-cors</code> ",
6514
- <var> name</var> is not a <a>no-CORS-safelisted request-header name</a> , and <var> name</var> is not
6515
- a <a>privileged no-CORS request-header name</a> , return.
6516
-
6517
- <li><p> Otherwise, if <a>this</a> 's <a for=Headers>guard</a> is "<code> response</code> " and
6518
- <var> name</var> is a <a>forbidden response-header name</a> , return.
6520
+ <li><p> If <a>this</a> 's <a for=Headers>guard</a> is "<code> request-no-cors</code> ", <var> name</var>
6521
+ is not a <a>no-CORS-safelisted request-header name</a> , and <var> name</var> is not a
6522
+ <a>privileged no-CORS request-header name</a> , then return.
6519
6523
6520
6524
<li><p> If <a>this</a> 's <a for=Headers>header list</a> <a for="header list">does not contain</a>
6521
6525
<var> name</var> , then return.
6526
+ <!-- This is intentional to avoid hitting the last step. -->
6522
6527
6523
6528
<li><p> <a for="header list">Delete</a> <var> name</var> from <a>this</a> 's
6524
6529
<a for=Headers>header list</a> .
@@ -6551,20 +6556,11 @@ method steps are:
6551
6556
<ol>
6552
6557
<li><p> <a for="header value">Normalize</a> <var> value</var> .
6553
6558
6554
- <li><p> If <var> name</var> is not a <a for=/>header name</a> or <var> value</var> is not a
6555
- <a for=/>header value</a> , then <a>throw</a> a {{TypeError}} .
6556
-
6557
- <li><p> If <a>this</a> 's <a for=Headers>guard</a> is "<code> immutable</code> ", then <a>throw</a> a
6558
- {{TypeError}} .
6559
-
6560
- <li><p> Otherwise, if <a>this</a> 's <a for=Headers>guard</a> is "<code> request</code> " and
6561
- (<var> name</var> , <var> value</var> ) is a <a>forbidden request-header</a> , return.
6562
-
6563
- <li><p> Otherwise, if <a>this</a> 's <a for=Headers>guard</a> is "<code> request-no-cors</code> " and
6564
- (<var> name</var> , <var> value</var> ) is not a <a>no-CORS-safelisted request-header</a> , return.
6559
+ <li><p> If <a for=Headers>validating</a> (<var> name</var> , <var> value</var> ) for <var> headers</var>
6560
+ returns false, then return.
6565
6561
6566
- <li><p> Otherwise, if <a>this</a> 's <a for=Headers>guard</a> is "<code> response </code> " and
6567
- <var> name</var> is a <a>forbidden response -header name </a> , return.
6562
+ <li><p> If <a>this</a> 's <a for=Headers>guard</a> is "<code> request-no-cors </code> " and
6563
+ ( <var> name</var> , <var> value </var> ) is not a <a>no-CORS-safelisted request -header</a> , then return.
6568
6564
6569
6565
<li><p> <a for="header list">Set</a> (<var> name</var> , <var> value</var> ) in <a>this</a> 's
6570
6566
<a for=Headers>header list</a> .
0 commit comments