/
Overview.src.html
3559 lines (2831 loc) · 152 KB
/
Overview.src.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang=en-US>
<meta charset=utf-8>
<title>Fetch Standard</title>
<link rel=stylesheet href=//whatwg.org/style/specification>
<link rel=icon href=//resources.whatwg.org/logo-fetch.svg>
<div class=head>
<p><a class=logo href=//whatwg.org/><img alt=WHATWG src=//resources.whatwg.org/logo-fetch.svg width=100 height=100></a>
<h1 id=cors>Fetch</h1>
<h2 class="no-num no-toc">Living Standard — Last Updated [DATE: 3 August 2002]</h2>
<dl>
<dt>Participate:
<dd>Send feedback to <a href="//whatwg.org/mailing-list">whatwg@whatwg.org</a>
(<a href="http://lists.w3.org/Archives/Public/public-whatwg-archive/">archives</a>)
or
<a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WHATWG&component=Fetch">file a bug</a>
(<a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=WHATWG&component=Fetch&resolution=---">open bugs</a>)
<dd>Temporary: ServiceWorker <a href="https://github.com/slightlyoff/ServiceWorker/labels/fetch">issues labeled "fetch"</a>
<dd><a href=//wiki.whatwg.org/wiki/IRC>IRC: #whatwg on Freenode</a>
<dt>Commits:
<dd><a href=https://github.com/whatwg/fetch/commits>https://github.com/whatwg/fetch/commits</a>
<dd><a href=https://twitter.com/fetchstandard>@fetchstandard</a>
</dl>
<script src=//resources.whatwg.org/file-bug.js async></script>
</div>
<h2 class="no-num no-toc short">Abstract</h2>
<p>The Fetch standard defines requests, responses, and the process that binds them;
fetching.
<h2 class="no-num no-toc">Table of Contents</h2>
<!-- toc -->
<h2 class="no-num short">Goals</h2>
<p>To unify fetching across the web platform this specification supplants a number of algorithms and specifications:
<ul class="brief no-backref">
<li>HTML Standard's fetch and potentially CORS-enabled fetch algorithms
<span data-anolis-ref class=informative>HTML</span>
<li>CORS <span data-anolis-ref class=informative>CORS</span>
<li>HTTP `<code title=http-origin>Origin</code>` header semantics
<span data-anolis-ref class=informative>ORIGIN</span>
</ul>
<p>Unifying fetching provides consistent handling of:
<ul class=brief>
<li>URL schemes
<li>Redirects
<li>Cross-origin semantics
<li>CSP <span data-anolis-ref>CSP</span>
<li>Service Workers <span data-anolis-ref>SW</span>
<li>Mixed Content <span data-anolis-ref>MIX</span>
<li>`<code title>Referer</code>` <span data-anolis-ref>REFERRER</span>
</ul>
<h2 class="short">Conformance</h2>
<p>All diagrams, examples, and notes in this specification are
non-normative, as are all sections explicitly marked non-normative.
Everything else in this specification is normative.
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this specification are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification.
<span data-anolis-ref>RFC2119</span>
<h2>Infrastructure</h2>
<p>This specification uses terminology from the Encoding, HTML, and URL Standards.
<span data-anolis-ref>ENCODING</span>
<span data-anolis-ref>HTML</span>
<span data-anolis-ref>URL</span>
<p>A <span data-anolis-spec=encoding>byte</span> sequence with bytes in the range 0x00 to
0x7F is represented as a <span data-anolis-spec=encoding>utf-8</span> encoded
<span data-anolis-spec=encoding>string</span> with code points in the range U+0000 to
U+007F. To avoid confusion with an actual string backticks are used.
<p class=example>"<code title>true</code>" is a
<span data-anolis-spec=encoding>string</span>, while `<code title>true</code>` is a
byte sequence.
<p>Comparing two byte sequences in a <dfn>byte case-insensitive</dfn> manner means
comparing them exactly, byte for byte, except that the bytes in the range 0x41 to 0x5A are
considered to also match their corresponding byte in the range 0x61 to 0x7A.
<p>A <dfn>case-insensitive byte sequence</dfn> is a byte sequence that when compared to
another byte sequence does so in a <span>byte case-insensitive</span> manner.
<p class=example>The
<span title="case-insensitive byte sequence">case-insensitive byte sequences</span>
`<code title>Content-Type</code>` and `<code title>content-TYPE</code>` are equal.
<p>To <dfn>byte lowercase</dfn> a byte sequence, increase each byte it contains, in the
range 0x41 to 0x5A, by 0x20.
<p>To <dfn>byte uppercase</dfn> a byte sequence, subtract each byte it contains, in the
range 0x61 to 0x7A, by 0x20.
<hr>
<p>To <dfn>queue a fetch task</dfn> on <span title=concept-request>request</span>
<var title>request</var> to <var title>run an operation</var>,
<span data-anolis-spec=html>queue a task</span> to <var title>run an operation</var> on
<var title>request</var>'s <span title=concept-request-client>client</span>'s
<span data-anolis-spec=html>responsible event loop</span> using the
<span data-anolis-spec=html>networking task source</span>.
<h3>HTTP</h3>
<p>While <span title=concept-fetch>fetching</span> encompasses more than just HTTP, it
borrows a number of concepts from HTTP and applies these to resources obtained via other
means (e.g. <code title>data</code> URLs).
<h4>Methods</h4>
<p>A <dfn title=concept-method>method</dfn> is a byte sequence that matches the
<span data-anolis-spec=http>Method</span> token production.
<p>A <dfn>simple method</dfn> is a <span title=concept-method>method</span> that is
`<code title>GET</code>`, `<code title>HEAD</code>`, or `<code title>POST</code>`.
<p>A <dfn>forbidden method</dfn> is a <span title=concept-method>method</span> that is a
<span>byte case-insensitive</span> match for one of `<code title>CONNECT</code>`,
`<code title>TRACE</code>`, and `<code title>TRACK</code>`.
<span data-anolis-ref class=informative>HTTPVERBSEC</span>
<p>To <dfn title=concept-method-normalize>normalize</dfn> a
<span title=concept-method>method</span>, if it is a <span>byte case-insensitive</span>
match for `<code title>DELETE</code>`, `<code title>GET</code>`,
`<code title>HEAD</code>`, `<code title>OPTIONS</code>`, `<code title>POST</code>`, or
`<code title>PUT</code>`, <span>byte uppercase</span> it.
<p class="note no-backref"><span title=concept-method-normalize>Normalization</span> is
done for backwards compatibility and consistency across APIs as
<span title=concept-method>methods</span> are actually "case-sensitive".
<h4 id=terminology-headers>Headers</h4>
<p>A <dfn title=concept-header-list>header list</dfn> consists of zero or more
<span title=concept-header>headers</span>.
<p>To <dfn title=concept-header-list-append>append</dfn> a
<span title=concept-header-name>name</span>/<span title=concept-header-value>value</span>
(<var title>name</var>/<var title>value</var>) pair to a
<span title=concept-header-list>header list</span> (<var title>list</var>), append a new
<span title=concept-header>header</span> whose <span title=concept-header-name>name</span>
is <var title>name</var>, <span title="byte lowercase">byte lowercased</span>, and
<span title=concept-header-value>value</span> is <var title>value</var>, to
<var title>list</var>.
<p>To <dfn title=concept-header-list-delete>delete</dfn> a
<span title=concept-header-name>name</span> (<var title>name</var>) from a
<span title=concept-header-list>header list</span> (<var title>list</var>), remove all
<span title=concept-header>headers</span> whose
<span title=concept-header-name>name</span> is <var title>name</var>,
<span title="byte lowercase">byte lowercased</span>, from <var title>list</var>.
<p>To <dfn title=concept-header-list-set>set</dfn> a
<span title=concept-header-name>name</span>/<span title=concept-header-value>value</span>
(<var title>name</var>/<var title>value</var>) pair in a
<span title=concept-header-list>header list</span> (<var title>list</var>), run these
steps:
<ol>
<li><p><span>Byte lowercase</span> <var title>name</var>.
<li><p>If there are any <span title=concept-header>headers</span> in
<var title>list</var> whose <span title=concept-header-name>name</span> is
<var title>name</var>, set the <span title=concept-header-value>value</span> of the first
such <span title=concept-header>header</span> to <var title>value</var> and remove the
others.
<li><p>Otherwise, append a new <span title=concept-header>header</span> whose
<span title=concept-header-name>name</span> is <var title>name</var> and
<span title=concept-header-value>value</span> is <var title>value</var>, to
<var title>list</var>.
</ol>
<p>To <dfn title=concept-header-list-combine>combine</dfn> a
<span title=concept-header-name>name</span>/<span title=concept-header-value>value</span>
(<var title>name</var>/<var title>value</var>) pair in a
<span title=concept-header-list>header list</span> (<var title>list</var>), run these
steps:
<ol>
<li><p><span>Byte lowercase</span> <var title>name</var>.
<li><p>If there are any <span title=concept-header>headers</span> in
<var title>list</var> whose <span title=concept-header-name>name</span> is
<var title>name</var>, set the <span title=concept-header-value>value</span> of the first
such <span title=concept-header>header</span> to
<span title=concept-header-value>value</span>, followed by 0x2C 0x20, followed by <var title>value</var>.
<li><p>Otherwise, append a new <span title=concept-header>header</span> whose
<span title=concept-header-name>name</span> is <var title>name</var> and
<span title=concept-header-value>value</span> is <var title>value</var>, to
<var title>list</var>.
</ol>
<p class="note no-backref"><span title=concept-header-list-combine>Combine</span> solely
exists for <code data-anolis-spec=xhr>XMLHttpRequest</code>.
<hr>
<p>A <dfn title=concept-header>header</dfn> consists of a
<dfn title=concept-header-name>name</dfn> and <dfn title=concept-header-value>value</dfn>.
A <span title=concept-header-name>name</span> is a
<span>case-insensitive byte sequence</span> that matches the
<span data-anolis-spec=http>field-name</span> token production. A
<span title=concept-header-value>value</span> is a byte sequence that matches the
<span data-anolis-spec=http>field-value</span> token production and contains no 0x0A or
0x0D bytes.
<p class=note>Allowing 0x0A and 0x0D bytes can lead to reparsing issues.
<hr>
<p>A <dfn>simple header</dfn> is a <span title=concept-header>header</span> whose
<span title=concept-header-name>name</span> is either one of `<code title>Accept</code>`,
`<code title>Accept-Language</code>`, and `<code title>Content-Language</code>`, or whose
<span title=concept-header-name>name</span> is `<code title>Content-Type</code>` and
<span title=concept-header-value>value</span>,
<span title=concept-header-parse>once parsed</span>, has a MIME type (ignoring parameters)
that is one of `<code title>application/x-www-form-urlencoded</code>`,
`<code title>multipart/form-data</code>`, and `<code title>text/plain</code>`.
<!-- XXX * needs better xref
* ignoring parameters has been the standard for a long time now
* interesting test: "Content-Type: text/plain;" -->
<p>A <dfn>forbidden header name</dfn> is a <span title=concept-header>header</span>
<span title=concept-header-name>name</span> that either is one of
<ul class=brief>
<li>`<code title>Accept-Charset</code>`
<li>`<code title>Accept-Encoding</code>`
<li>`<code title>Access-Control-Request-Headers</code>`
<li>`<code title>Access-Control-Request-Method</code>`
<li>`<code title>Connection</code>`
<li>`<code title>Content-Length</code>`
<li>`<code title>Cookie</code>`
<li>`<code title>Cookie2</code>`
<li>`<code title>Date</code>`
<li>`<code title>DNT</code>`
<li>`<code title>Expect</code>`
<li>`<code title>Host</code>`
<li>`<code title>Keep-Alive</code>`
<li>`<code title=http-origin>Origin</code>`
<li>`<code title>Referer</code>`
<li>`<code title>TE</code>`
<li>`<code title>Trailer</code>`
<li>`<code title>Transfer-Encoding</code>`
<li>`<code title>Upgrade</code>`
<li>`<code title>User-Agent</code>`
<li>`<code title>Via</code>`
</ul>
<p>or starts with `<code title>Proxy-</code>` or `<code title>Sec-</code>`
(including when it is just `<code title>Proxy-</code>` or `<code title>Sec-</code>`).
<p class=note>These are forbidden so the user agent remains in full control over them.
<span title=concept-header-name>Names</span> starting with `<code title>Sec-</code>` are
reserved to allow new <span title=concept-header>headers</span> to be minted that are safe
from APIs using <span title=concept-fetch>fetch</span> that allow control over
<span title=concept-header>headers</span> by developers, such as
<code data-anolis-spec=xhr>XMLHttpRequest</code>.
<span data-anolis-ref class=informative>XHR</span>
<p>A <dfn>forbidden response header name</dfn> is a <span title=concept-header>header</span>
<span title=concept-header-name>name</span> that is one of:
<ul class=brief>
<li>`<code title>Set-Cookie</code>`
<li>`<code title>Set-Cookie2</code>`
</ul>
<hr>
<p>To <dfn title=concept-header-parse>parse a header value</dfn> given a
<span title=concept-header-name>name</span> (<var title>name</var>) and either a
<span title=concept-header>header</span> or a
<span title=concept-header-list>header list</span> (<var title>headers</var>), run these
steps:
<ol>
<li><p>If <var title>name</var> is not in <var title>headers</var>, return null.
<li>
<p>If the ABNF for <var title>name</var> allows a single
<span title=concept-header>header</span> and <var title>headers</var> contains more than
one, return failure.
<p class="note no-backref">That if you require different error handling, you need to
extract the desired <span title=concept-header>header</span> first.
<li><p>If parsing all the <span title=concept-header>headers</span>
<span title=concept-header-name>named</span> <var title>name</var> in
<var title>headers</var>, per the ABNF for <var title>name</var>, failed, return failure.
<li><p>Return one or more <span title=concept-header-value>values</span> resulting from
parsing all the <span title=concept-header>headers</span>
<span title=concept-header-name>named</span> <var title>name</var> in
<var title>headers</var>, per the ABNF for <var title>name</var>.
</ol>
<p>To <dfn title=concept-header-extract-MIME-type>extract a MIME type</dfn> from a
<span title=concept-header-list>header list</span> (<var title>headers</var>), run these
steps:
<ol>
<li><p>Let <var title>MIMEType</var> be the result of
<span title=concept-header-parse>parsing</span> `<code title>Content-Type</code>` in
<var title>headers</var>.
<li><p>If <var title>MIMEType</var> is null or failure, return the empty byte sequence.
<li><p>Return <var title>MIMEType</var>,
<span title="byte lowercase">byte lowercased</span>.
</ol>
<h4>Bodies</h4>
<p>A <dfn title=concept-body>body</dfn> is a byte stream. It has an associated
<dfn title=concept-body-transmitted>transmitted</dfn> which is an integer and initially 0,
<dfn title=concept-body-length>length</dfn> which is an integer and initially 0, and
<dfn title=concept-body-error-flag>error flag</dfn> which is initially unset.
<p>To <dfn>handle content codings</dfn> given <var title>codings</var> and
<var title>bytes</var>, run these substeps:
<ol>
<li><p>If <var title>codings</var> are not supported, return <var title>bytes</var>.
<li><p>Return the result of decoding bytes with the given
<var title>codings</var> as explained in HTTP. <span data-anolis-ref>HTTP</span>
</ol>
<!-- XXX no hook in HTTP -->
<h4>Requests</h4>
<p>The input to <span title=concept-fetch>fetch</span> is a
<dfn title=concept-request>request</dfn>.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-method>method</dfn> (a
<span title=concept-method>method</span>). Unless stated otherwise it is
`<code title>GET</code>`.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-url>url</dfn> (a
<span data-anolis-spec=url title=concept-url>URL</span>).
<p class="note no-backref">This is updated during redirects as described in
<span title=concept-http-fetch>HTTP fetch</span>.
<p>A <span title=concept-request>request</span> has an associated
<dfn>sandboxed storage area URLs flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-header-list>header list</dfn> (a
<span title=concept-header-list>header list</span>). Unless stated otherwise it is empty.
<p>A <span title=concept-request>request</span> has an associated
<dfn>unsafe request flag</dfn>. Unless stated otherwise it is unset.
<p class="note no-backref">The <span>unsafe request flag</span> is set by APIs such as
<code title=dom-global-fetch>fetch()</code> and
<code data-anolis-spec=xhr>XMLHttpRequest</code> to ensure a
<span>CORS preflight fetch</span> is done based on the supplied
<span title=concept-request-method>method</span> and
<span title=concept-request-header-list>header list</span>. It does not free an API from
outlawing <span title="forbidden method">forbidden methods</span> and
<span title="forbidden header name">forbidden header names</span>.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-body>body</dfn> (null or a
<span title=concept-body>body</span>). Unless stated otherwise it is null.
<hr>
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-client>client</dfn> (an
<span data-anolis-spec=html>environment settings object</span>).
<p>A <span title=concept-request>request</span> has an associated
<dfn>skip service worker flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-context>context</dfn>, which is one of
<i title>audio</i>,
<i title>beacon</i>,
<i title>cspreport</i>,
<i title>download</i>,
<i title>embed</i>,
<i title>eventsource</i>,
<i title>favicon</i>,
<i title>fetch</i>,
<i title>font</i>,
<i title>form</i>,
<i title>frame</i>,
<i title>hyperlink</i>,
<i title>iframe</i>,
<i title>image</i>,
<i title>imageset</i>,
<i title>import</i>,
<i title>internal</i>,
<i title>location</i>,
<i title>manifest</i>,
<i title>object</i>,
<i title>ping</i>,
<i title>plugin</i>,
<i title>prefetch</i>,
<i title>script</i>,
<i title>serviceworker</i>,
<i title>sharedworker</i>,
<i title>subresource</i>,
<i title>style</i>,
<i title>track</i>,
<i title>video</i>,
<i title>worker</i>,
<i title>xmlhttprequest</i>, and
<i title>xslt</i>.
<!--
https://wiki.whatwg.org/wiki/Contexts
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIContentPolicy
-->
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-context-frame-type>context frame type</dfn>, which is one of
<i title>auxiliary</i>, <i title>top-level</i>, <i title>nested</i>, and
<i title>none</i>. Unless stated otherwise it is <i title>none</i>.
<p class=XXX>Remove <i title>auxiliary</i>? Not sure it is distinctive enough.
<div class=note>
<p>The following table illustrates the relationship between a
<span title=concept-request>request</span>'s
<span title=concept-request-context>context</span>, its
<span title=concept-request-context-frame-type>context frame type</span>, and
CSP directives:
<table>
<tr>
<th><span title=concept-request-context>context</span>
<th><span title=concept-request-context-frame-type>context frame type</span>
<th>CSP directive
<th>Platform feature example
<tr>
<td><i title>audio</i>
<td><i title>none</i>
<td><code title>media-src</code>
<td>HTML's <code>audio</code> element
<tr>
<td><i title>beacon</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td><code>navigator.sendBeacon()</code>
<tr>
<td><i title>cspreport</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td>CSP's report feature
<tr>
<td><i title>download</i>
<td><i title>none</i>
<td>—
<td>HTML's <code>a</code> element when its <code>download</code> attribute is set
<tr>
<td><i title>embed</i>
<td><i title>none</i>
<td><code title>object-src</code>
<td>HTML's <code>embed</code> element
<tr>
<td><i title>eventsource</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td><code>EventSource</code>
<tr>
<td><i title>favicon</i>
<td><i title>none</i>
<td>—
<td><code title>/favicon.ico</code> resource
<tr>
<td><i title>fetch</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td><code title=dom-global-fetch>fetch()</code>
<tr>
<td><i title>font</i>
<td><i title>none</i>
<td><code title>font-src</code>
<td>CSS' <code>@font-face</code>
<tr>
<td><i title>form</i>
<td>any but <i title>none</i>
<td><code title>form-action</code>, potentially <code title>child-src</code>
<td>HTML's <code>form</code> element
<tr>
<td><i title>frame</i>
<td><i title>nested</i>
<td><code title>child-src</code>
<td>HTML's <code>frame</code> element
<tr>
<td><i title>hyperlink</i>
<td>any but <i title>none</i>
<td>potentially <code title>child-src</code>
<td>HTML's <code>a</code> element
<tr>
<td><i title>iframe</i>
<td><i title>nested</i>
<td><code title>child-src</code>
<td>HTML's <code>iframe</code> element
<tr>
<td><i title>image</i>
<td><i title>none</i>
<td><code title>img-src</code>
<td>SVG's <code>image</code> element
<tr>
<td><i title>imageset</i>
<td><i title>none</i>
<td><code title>img-src</code>
<td>HTML's <code>picture</code> element
<tr>
<td><i title>import</i>
<td><i title>none</i>
<td><code title>script-src</code>
<td>HTML's <code>link</code> element when its <code>rel</code> attribute is set to
"<code>import</code>"
<tr>
<td><i title>internal</i>
<td>any
<td>—
<td>User agent actions such as refresh, back, forward; other user agent usage
<tr>
<td><i title>location</i>
<td>any but <i title>none</i>
<td>potentially <code title>child-src</code>
<td><code title>window.location</code>
<tr>
<td><i title>manifest</i>
<td><i title>none</i>
<td>—
<td>HTML's <code>link</code> element when its <code>rel</code> attribute is set to
"<code>manifest</code>"
<tr>
<td><i title>object</i>
<td><i title>none</i>
<td><code title>object-src</code>
<td>HTML's <code>object</code> element
<tr>
<td><i title>ping</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td>HTML's <code>ping</code> attribute
<tr>
<td><i title>plugin</i>
<td><i title>none</i>
<td>—
<td>A <span title=concept-fetch>fetch</span> from a plugin
<tr>
<td><i title>prefetch</i>
<td><i title>none</i>
<td>—
<td>HTML's <code>link</code> element when its <code>rel</code> attribute is set to
"<code>prefetch</code>"
<tr>
<td><i title>script</i>
<td><i title>none</i>
<td><code title>script-src</code>
<td>HTML's <code>script</code> element
<tr>
<td><i title>serviceworker</i>
<td><i title>none</i>
<td>—
<td><code title>navigator.serviceWorker.register()</code>
<tr>
<td><i title>sharedworker</i>
<td><i title>none</i>
<td><code title>child-src</code>
<td><code>SharedWorker</code>
<tr>
<td><i title>subresource</i>
<td><i title>none</i>
<td>—
<td>HTML's <code>link</code> element when its <code>rel</code> attribute is set to
"<code>subresource</code>"
<tr>
<td><i title>style</i>
<td><i title>none</i>
<td><code title>style-src</code>
<td>HTML's <code>link</code> element when its <code>rel</code> attribute is set to
"<code>stylesheet</code>"
<tr>
<td><i title>track</i>
<td><i title>none</i>
<td><code title>media-src</code>
<td>HTML's <code>track</code> element
<tr>
<td><i title>video</i>
<td><i title>none</i>
<td><code title>media-src</code>
<td>HTML's <code>video</code> element
<tr>
<td><i title>worker</i>
<td><i title>none</i>
<td><code title>child-src</code>
<td><code>Worker</code>
<tr>
<td><i title>xmlhttprequest</i>
<td><i title>none</i>
<td><code title>connect-src</code>
<td><code data-anolis-spec=xhr>XMLHttpRequest</code>
<tr>
<td><i title>xslt</i>
<td><i title>none</i>
<td><code title>script-src</code>
<td><code><?xml-stylesheet></code>
</table>
</div>
<hr>
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-origin>origin</dfn> (an
<span data-anolis-spec=html>origin</span>). Unless stated otherwise it is an
opaque identifier.
<p>A <span title=concept-request>request</span> has an associated
<dfn>force <code title>Origin</code> header flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn>same-origin data URL flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-referrer>referrer</dfn>, which is <i title>no referrer</i>,
<i title>client</i>, or a <span data-anolis-spec=url title=concept-url>URL</span>. Unless
stated otherwise it is <i title>client</i>.
<p>A <span title=concept-request>request</span> has an associated
<dfn>authentication flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn>synchronous flag</dfn>. Unless stated otherwise it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-mode>mode</dfn>, which is one of <i title>same-origin</i>,
<i title>no CORS</i>, <i title>CORS</i>, and
<i title>CORS-with-forced-preflight</i>. Unless stated otherwise, it is
<i title>no CORS</i>.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-credentials-mode>credentials mode</dfn>, which is
one of <i title>omit</i>, <i title>same-origin</i>, and <i title>include</i>. Unless
stated otherwise, it is <i title>omit</i>.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-use-url-credentials-flag>use URL credentials flag</dfn>.
Unless stated otherwise, it is unset.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-cache-mode>cache mode</dfn>, which is one of
<i title>default</i>, <i title>no-store</i>, <i title>reload</i>, <i title>no-cache</i>,
<i title>force cache</i>, and <i title>only-if-cached</i>. Unless stated otherwise, it is
<i title>default</i>.
<p class="note no-backref">If <span title=concept-request-header-list>header list</span>
contains a <span title=concept-header>header</span> whose
<span title=concept-header-name>name</span> is one of
`<code title>If-Modified-Since</code>`,
`<code title>If-None-Match</code>`,
`<code title>If-Unmodified-Since</code>`,
`<code title>If-Match</code>`, and
`<code title>If-Range</code>`, <span title=concept-fetch>fetch</span> will set
<span title=concept-request-cache-mode>cache mode</span> to <i title>no-store</i> if it is
<i title>default</i>.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-manual-redirect-flag>manual redirect flag</dfn>. Unless stated
otherwise, it is unset.
<hr>
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-redirect-count>redirect count</dfn>. Unless stated otherwise,
it is zero.
<p>A <span title=concept-request>request</span> has an associated
<dfn title=concept-request-response-tainting>response tainting</dfn>, which is one of
<i title>basic</i>, <i title>CORS</i>, and <i title>opaque</i>. Unless stated otherwise,
it is <i title>basic</i>.
<p class="note no-backref">A <span title=concept-request>request</span>'s
<span title=concept-request-redirect-count>redirect count</span> and
<span title=concept-request-response-tainting>response tainting</span> are used as
bookkeeping details by the <span title=concept-fetch>fetch</span> algorithm.
<hr>
<p>A <dfn>client request</dfn> is a <span title=concept-request>request</span> whose
<span title=concept-request-context>context</span> is one of
<i title>form</i>,
<i title>frame</i>,
<i title>hyperlink</i>,
<i title>iframe</i>,
<i title>internal</i> (as long as <span title=concept-request-context-frame-type>context frame type</span> is not <i title>none</i>),
<i title>location</i>,
<i title>serviceworker</i>,
<i title>sharedworker</i>, and
<i title>worker</i>.
<p>A <dfn>potential client request</dfn> is a <span title=concept-request>request</span>
whose <span title=concept-request-context>context</span> is <i title>embed</i> or
<i title>object</i>.
<p>A <dfn>resource request</dfn> is a <span title=concept-request>request</span> that is
neither a <span>client request</span> nor a <span>potential client request</span>.
<!-- These concepts are introduced for service workers. At some point we should xref that. -->
<h4>Responses</h4>
<p>The result of <span title=concept-fetch>fetch</span> is a
<dfn title=concept-response>response</dfn>. A <span title=concept-response>response</span>
evolves over time. That is, not all its fields are available straight away.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-type>type</dfn> which is one of
<i title>basic</i>,
<i title>CORS</i>,
<i title>default</i>,
<i title>error</i>, and
<i title>opaque</i>.
Unless stated otherwise, it is <i title>default</i>.
<p>A <span title=concept-response>response</span> can have an associated
<dfn title=concept-response-termination-reason>termination reason</dfn> which is one of
<i title>end-user abort</i>, <i title>fatal</i>, and <i title>timeout</i>.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-url>url</dfn> (null or a
<span data-anolis-spec=url title=concept-url>URL</span>). Unless stated otherwise it is
null.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-final-url-flag>final url flag</dfn>. Unless stated otherwise
it is unset.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-status>status</dfn>. Unless stated otherwise it is
<code title>200</code>.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-status-message>status message</dfn>. Unless stated otherwise
it is `<code title>OK</code>`.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-header-list>header list</dfn> (a
<span title=concept-header-list>header list</span>). Unless stated otherwise it is empty.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-body>body</dfn> (null or a
<span title=concept-body>body</span>). Unless stated otherwise it is null.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-cache-state>cache state</dfn> which is one of
<i title>none</i>,
<i title>local</i>,
<i title>validated</i>, and
<i title>partial</i>. Unless stated otherwise, it is <i title>none</i>.
<p>A <span title=concept-response>response</span> has an associated
<dfn title=concept-response-tls-state>TLS state</dfn> which is one of
<i title>unauthenticated</i>,
<i title>deprecated authentication</i>, and
<i title>authenticated</i>. Unless stated otherwise, it is <i title>unauthenticated</i>.
<p class="note no-backref">A <span title=concept-response>response</span> delivered over
TLS will typically have its <span title=concept-response-tls-state>TLS state</span> set to
<i title>authenticated</i>.
<hr>
<p>A <span title=concept-response>response</span> whose
<span title=concept-response-type>type</span> is <i title>error</i> is known as a
<dfn title=concept-network-error>network error</dfn>.
<p>A <span title=concept-network-error>network error</span> is a
<span title=concept-response>response</span> whose
<span title=concept-response-status>status</span> is always <code title>0</code>,
<span title=concept-response-status-message>status message</span> is always the empty byte sequence,
<span title=concept-response-header-list>header list</span> is always empty,
<span title=concept-response-body>body</span> is always null, and
<span title=concept-response-cache-state>cache state</span> is always <i title>none</i>.
<!-- XXX Introduce concept-redirect and concept-redirect-location for navigate algorithm? -->
<hr>
<p>A <dfn title=concept-filtered-response>filtered response</dfn> is a limited view on a
<span title=concept-response>response</span> that is not a
<span title=concept-network-error>network error</span>. This
<span title=concept-response>response</span> is referred to as the
<span title=concept-filtered-response>filtered response</span>'s associated
<dfn title=concept-internal-response>internal response</dfn>.
<p class="note no-backref">The <span title=concept-fetch>fetch</span> algorithm returns
such a view to ensure APIs do not accidentally leak information. If the information is
required, e.g. to feed image data to a decoder, the associated
<span title=concept-internal-response>internal response</span> can be used, which is only
"accessible" to internal specification algorithms.
<p>A <dfn title=concept-filtered-response-basic>basic filtered response</dfn> is a
<span title=concept-filtered-response>filtered response</span> whose
<span title=concept-response-type>type</span> is <i title>basic</i>,
<span title=concept-response-header-list>header list</span> excludes any
<span title=concept-header>headers</span> in
<span title=concept-internal-response>internal response</span>'s
<span title=concept-response-header-list>header list</span> whose
<span title=concept-header-name>name</span> is `<code title>Set-Cookie</code>` or
`<code title>Set-Cookie2</code>`.
<p>A <dfn title=concept-filtered-response-cors>CORS filtered response</dfn> is a
<span title=concept-filtered-response>filtered response</span> whose
<span title=concept-response-type>type</span> is <i title>CORS</i>,
<span title=concept-response-header-list>header list</span> excludes all
<span title=concept-header>headers</span> in
<span title=concept-internal-response>internal response</span>'s
<span title=concept-response-header-list>header list</span>, except those whose
<span title=concept-header-name>name</span> is either one of
`<code title>Cache-Control</code>`, `<code title>Content-Language</code>`,
`<code title>Content-Type</code>`, `<code title>Expires</code>`,
`<code title>Last-Modified</code>`, and `<code title>Pragma</code>`, and except those
whose <span title=concept-header-name>name</span> is one of the
<span title=concept-header-value>values</span> resulting from
<span title=concept-header-parse>parsing</span>
`<code title=http-access-control-expose-headers>Access-Control-Expose-Headers</code>` in
<span title=concept-internal-response>internal response</span>'s
<span title=concept-response-header-list>header list</span>.
<p>An <dfn title=concept-filtered-response-opaque>opaque filtered response</dfn> is a
<span title=concept-filtered-response>filtered response</span> whose
<span title=concept-response-type>type</span> is <i title>opaque</i>,
<span title=concept-response-status>status</span> is <code title>0</code>,
<span title=concept-response-status-message>status message</span> is the empty byte sequence,
<span title=concept-response-header-list>header list</span> is an empty list,
<span title=concept-response-body>body</span> is null, and
<span title=concept-response-cache-state>cache state</span> is <i title>none</i>.
<p class="note no-backref">In other words, an
<span title=concept-filtered-response-opaque>opaque filtered response</span> is nearly
indistinguishable from a <span title=concept-network-error>network error</span>. When
introducing new APIs, do not use the
<span title=concept-internal-response>internal response</span> for internal specification
algorithms as you will leak information.
<h3>Authentication entries</h3>
<p>An <dfn>authentication entry</dfn> and a <dfn>proxy authentication entry</dfn> are
tuples of username, password, and realm, associated with one or more
<span title=concept-request>requests</span>.
<p>User agents should allow either to be cleared together with HTTP cookies and similar
tracking functionality.
<!-- fingerprinting -->
<p>Further details are defined by HTTP.
<span data-anolis-ref>HTTPAUTH</span>
<h2>HTTP extensions</h2>
<h3>`<code title>Origin</code>` header</h3>
<p>The `<dfn title=http-origin><code>Origin</code></dfn>` request
<span title=concept-header>header</span> indicates where a
<span title=concept-fetch>fetch</span> originates from.
<p class="note no-backref">The `<code title=http-origin>Origin</code>` header is a version
of the `<code title=http-referer>Referer</code>` [sic] header that does not reveal a
<span data-anolis-spec=url title=concept-url-path>path</span>. It is used for
all <span title=concept-http-fetch>HTTP fetches</span> whose <i title>CORS flag</i> is
set as well as those where <span title=concept-request>request</span>'s
<span title=concept-request-method>method</span> is `<code title>POST</code>`. Due to
compatibility constraints it is not included in all
<span title=concept-fetch>fetches</span>.
<!-- Ian Hickson told me Adam Barth researched that -->
<p>Its <span title=concept-header-value>value</span> ABNF:
<pre>Origin = origin-or-null
origin-or-null = origin / %x6E.75.6C.6C ; "null", case-sensitive
origin = <span data-anolis-spec=url title=concept-url-scheme>scheme</span> "://" <span data-anolis-spec=url title=concept-url-host>host</span> [ ":" <span data-anolis-spec=url title=concept-url-port>port</span> ]</pre>
<p class="note no-backref">This supplants the `<code title=http-origin>Origin</code>`
<span title=concept-header>header</span>.
<span data-anolis-ref class=informative>ORIGIN</span>
<h3 id=http-cors-protocol>CORS protocol</h3>
<p>To allow sharing resources cross-origin and allow for more versatile HTTP requests than
possible with HTML's <code data-anolis-spec=html>form</code> element, the platform has
a <dfn>CORS protocol</dfn> layered on top of HTTP. It allows resources to declare they
can be shared with resources residing on a different
<span data-anolis-spec=html>origin</span>.
<p class=note>It needs to be an opt-in mechanism to prevent leaking data from resources
behind a firewall (intranets). Additionally, for credentialed HTTP requests it needs to be
opt-in to prevent leaking potentially-sensitive data.
<p>This section explains the <span>CORS protocol</span> as it pertains to servers.
Requirements for user agents are part of the <span title=concept-fetch>fetch</span>
algorithm.
<h4>General</h4>
<p>The <span>CORS protocol</span> consists of a set of headers that indicates whether a
particular resource can be shared cross-origin.
<p>For HTTP requests that are more involved than what is possible with HTML's
<code data-anolis-spec=html>form</code> element, a <span>CORS preflight fetch</span> is
performed, to ensure the resource understands the <span>CORS protocol</span>.
<h4>HTTP requests</h4>
<p>An HTTP request can be identified as pertaining in the <span>CORS protocol</span> if it
includes an `<code title=http-origin>Origin</code>` header. This is named a
<dfn>CORS request</dfn>.
<p>An HTTP request can be identified as being a check to see if the
<span>CORS protocol</span> is understood if it is a <span>CORS request</span>, uses
`<code title>OPTIONS</code>` as <span title=concept-method>method</span>, and includes
these <span title=concept-header>headers</span>:
<dl>
<dt>`<dfn title=http-access-control-request-method><code>Access-Control-Request-Method</code></dfn>`
<dd><p>Indicates which <span title=concept-method>method</span> a future
<span>CORS request</span> to the same resource might use.
<dt>`<dfn title=http-access-control-request-headers><code>Access-Control-Request-Headers</code></dfn>`
<dd><p>Indicates which <span title=concept-header>headers</span> a future
<span>CORS request</span> to the same resource might use.
</dl>
<p>This is named a <dfn>CORS preflight request</dfn>.
<h4>HTTP responses</h4>
<p>An HTTP response to a <span>CORS request</span> can include the following
<span title=concept-header>headers</span>:
<dl>
<dt>`<dfn title=http-access-control-allow-origin><code>Access-Control-Allow-Origin</code></dfn>`
<dd><p>Indicates whether a resource can be shared, via returning the literal
<span title=concept-header-value>value</span> of the
`<code title=http-origin>Origin</code>` request <span title=concept-header>header</span>
(which can be `<code title>null</code>`) or `<code title>*</code>` in a response.
<dt>`<dfn title=http-access-control-allow-credentials><code>Access-Control-Allow-Credentials</code></dfn>`
<dd>
<p>Indicates whether a resource can be shared when
<span title=concept-request>request</span>'s
<span title=concept-request-credentials-mode>credentials mode</span> is
<i title>include</i>.
<p class=note>For a <span>CORS preflight request</span>,
<span title=concept-request>request</span>'s
<span title=concept-request-credentials-mode>credentials mode</span> is always
<i title>omit</i>, but for any subsequent
<span title="CORS request">CORS requests</span> it might not be. Support therefore needs