forked from whatwg/fetch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Overview.html
5703 lines (4503 loc) · 334 KB
/
Overview.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 href="https://resources.whatwg.org/standard.css" rel="stylesheet">
<link href="https://resources.whatwg.org/logo-fetch.svg" rel="icon">
<div class="head">
<p><a class="logo" href="https://whatwg.org/"><img alt="WHATWG" height="100" src="https://resources.whatwg.org/logo-fetch.svg" width="100"></a>
<h1 id="cors">Fetch</h1>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-27-july-2016">Living Standard — Last Updated 27 July 2016</h2>
<dl>
<dt>Participate:
<dd><a href="https://github.com/whatwg/fetch">GitHub whatwg/fetch</a>
(<a href="https://github.com/whatwg/fetch/issues/new">file an issue</a>,
<a href="https://github.com/whatwg/fetch/issues">open issues</a>,
<a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=WHATWG&component=Fetch&resolution=---">legacy open bugs</a>)
<dd><a href="https://wiki.whatwg.org/wiki/IRC">IRC: #whatwg on Freenode</a>
<dt>Commits:
<dd><a href="https://github.com/whatwg/fetch/commits">GitHub whatwg/fetch/commits</a>
<dd><a href="https://twitter.com/fetchstandard">@fetchstandard</a>
<dt>Translation <small>(non-normative)</small>:
<dd title="Japanese"><a href="https://triple-underscore.github.io/Fetch-ja.html" hreflang="ja" lang="ja" rel="alternative">日本語</a>
</dl>
<script async="" src="https://resources.whatwg.org/file-issue.js"></script>
<script defer="" id="head" src="https://resources.whatwg.org/dfn.js"></script>
</div>
<h2 class="no-num no-toc short" id="abstract">Abstract</h2>
<p>The Fetch standard defines requests, responses, and the process that binds them:
fetching.
<h2 class="no-num no-toc" id="table-of-contents">Table of Contents</h2>
<!--begin-toc-->
<ol class="toc">
<li><a class="no-num short" href="#goals">Goals</a></li>
<li><a class="short" href="#preface"><span class="secno">1 </span>Preface</a></li>
<li><a class="short" href="#conformance"><span class="secno">2 </span>Conformance</a></li>
<li><a href="#infrastructure"><span class="secno">3 </span>Infrastructure</a>
<ol>
<li><a href="#http"><span class="secno">3.1 </span>HTTP</a>
<ol>
<li><a href="#methods"><span class="secno">3.1.1 </span>Methods</a></li>
<li><a href="#terminology-headers"><span class="secno">3.1.2 </span>Headers</a></li>
<li><a href="#statuses"><span class="secno">3.1.3 </span>Statuses</a></li>
<li><a href="#bodies"><span class="secno">3.1.4 </span>Bodies</a></li>
<li><a href="#requests"><span class="secno">3.1.5 </span>Requests</a></li>
<li><a href="#responses"><span class="secno">3.1.6 </span>Responses</a></ol></li>
<li><a href="#authentication-entries"><span class="secno">3.2 </span>Authentication entries</a></li>
<li><a href="#fetch-groups"><span class="secno">3.3 </span>Fetch groups</a></li>
<li><a href="#connections"><span class="secno">3.4 </span>Connections</a></li>
<li><a href="#port-blocking"><span class="secno">3.5 </span>Port blocking</a></li>
<li><a href="#should-response-to-request-be-blocked-due-to-mime-type?"><span class="secno">3.6 </span>Should
<var>response</var> to <var>request</var> be blocked due to its MIME type?</a></li>
<li><a href="#referrer-policies"><span class="secno">3.7 </span>Referrer policies</a></li>
<li><a href="#client-hints-list"><span class="secno">3.8 </span>Client hints list</a></li>
<li><a href="#streams"><span class="secno">3.9 </span>Streams</a>
<ol>
<li><a href="#readablestream"><span class="secno">3.9.1 </span>ReadableStream</a></ol></ol></li>
<li><a href="#http-extensions"><span class="secno">4 </span>HTTP extensions</a>
<ol>
<li><a href="#origin-header"><span class="secno">4.1 </span>`<code title="">Origin</code>` header</a></li>
<li><a href="#http-cors-protocol"><span class="secno">4.2 </span>CORS protocol</a>
<ol>
<li><a href="#general"><span class="secno">4.2.1 </span>General</a></li>
<li><a href="#http-requests"><span class="secno">4.2.2 </span>HTTP requests</a></li>
<li><a href="#http-responses"><span class="secno">4.2.3 </span>HTTP responses</a></li>
<li><a href="#http-new-header-syntax"><span class="secno">4.2.4 </span>HTTP new-header syntax</a></li>
<li><a href="#cors-protocol-and-credentials"><span class="secno">4.2.5 </span>CORS protocol and credentials</a></li>
<li><a href="#cors-protocol-examples"><span class="secno">4.2.6 </span>Examples</a></ol></li>
<li><a href="#x-content-type-options-header"><span class="secno">4.3 </span>`<code title="">X-Content-Type-Options</code>` header</a>
<ol>
<li><a href="#should-response-to-request-be-blocked-due-to-nosniff?"><span class="secno">4.3.1 </span>Should
<var>response</var> to <var>request</var> be blocked due to nosniff?</a></ol></ol></li>
<li><a href="#fetching"><span class="secno">5 </span>Fetching</a>
<ol>
<li><a href="#main-fetch"><span class="secno">5.1 </span>Main fetch</a></li>
<li><a href="#basic-fetch"><span class="secno">5.2 </span>Basic fetch</a></li>
<li><a href="#http-fetch"><span class="secno">5.3 </span>HTTP fetch</a></li>
<li><a href="#http-redirect-fetch"><span class="secno">5.4 </span>HTTP-redirect fetch</a></li>
<li><a href="#http-network-or-cache-fetch"><span class="secno">5.5 </span>HTTP-network-or-cache fetch</a></li>
<li><a href="#http-network-fetch"><span class="secno">5.6 </span>HTTP-network fetch</a></li>
<li><a href="#cors-preflight-fetch"><span class="secno">5.7 </span>CORS-preflight fetch</a></li>
<li><a href="#cors-preflight-cache"><span class="secno">5.8 </span>CORS-preflight cache</a></li>
<li><a href="#cors-check"><span class="secno">5.9 </span>CORS check</a></ol></li>
<li><a href="#fetch-api"><span class="secno">6 </span>Fetch API</a>
<ol>
<li><a href="#headers-class"><span class="secno">6.1 </span>Headers class</a></li>
<li><a href="#body-mixin"><span class="secno">6.2 </span>Body mixin</a></li>
<li><a href="#request-class"><span class="secno">6.3 </span>Request class</a></li>
<li><a href="#response-class"><span class="secno">6.4 </span>Response class</a></li>
<li><a href="#structured-cloning-of-headers,-request,-and-response-objects"><span class="secno">6.5 </span>Structured cloning of <code>Headers</code>, <code>Request</code>, and <code>Response</code> objects</a></li>
<li><a href="#fetch-method"><span class="secno">6.6 </span>Fetch method</a></li>
<li><a href="#garbage-collection"><span class="secno">6.7 </span>Garbage collection</a></ol></li>
<li><a href="#websocket-protocol"><span class="secno">7 </span>WebSocket protocol alterations</a>
<ol>
<li><a href="#websocket-connections"><span class="secno">7.1 </span>Connections</a></li>
<li><a href="#websocket-opening-handshake"><span class="secno">7.2 </span>Opening handshake</a></ol></li>
<li><a class="no-num" href="#background-reading">Background reading</a>
<ol>
<li><a class="no-num" href="#http-header-layer-division">HTTP header layer division</a></li>
<li><a class="no-num" href="#atomic-http-redirect-handling">Atomic HTTP redirect handling</a></li>
<li><a class="no-num" href="#basic-safe-cors-protocol-setup">Basic safe CORS protocol setup</a></li>
<li><a class="no-num" href="#cors-protocol-and-http-caches">CORS protocol and HTTP caches</a></ol></li>
<li><a class="no-num" href="#references">References</a></li>
<li><a class="no-num" href="#acknowledgments">Acknowledgments</a></ol>
<!--end-toc-->
<h2 class="no-num short" id="goals">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
<a class="informative" href="#refsHTML">[HTML]</a>
<li>CORS <a class="informative" href="#refsCORS">[CORS]</a>
<li>HTTP `<a href="#http-origin"><code title="http-origin">Origin</code></a>` header semantics
<a class="informative" href="#refsORIGIN">[ORIGIN]</a>
</ul>
<p>Unifying fetching provides consistent handling of:
<ul class="brief">
<li>URL schemes
<li>Redirects
<li>Cross-origin semantics
<li>CSP <a href="#refsCSP">[CSP]</a>
<li>Service workers <a href="#refsSW">[SW]</a>
<li>Mixed Content <a href="#refsMIX">[MIX]</a>
<li>`<code title="">Referer</code>` <a href="#refsREFERRER">[REFERRER]</a>
</ul>
<h2 class="short" id="preface"><span class="secno">1 </span>Preface</h2>
<p>At a high level, fetching a resource is a fairly simple operation. A request goes in, a
response comes out. <!--You can't explain that! -->The details of that operation are
however quite involved and used to not be written down carefully and differ from one API
to the next.
<p>Numerous APIs provide the ability to fetch a resource, e.g. HTML's <code>img</code> and
<code>script</code> element, CSS' <code>cursor</code> and <code>list-style-image</code>,
the <code>navigator.sendBeacon()</code> and <code>self.importScripts()</code> JavaScript
APIs. The Fetch Standard provides a unified architecture for these features so they are
all consistent when it comes to various aspects of fetching, such as redirects and the
CORS protocol.
<p>The Fetch Standard also defines the <a href="#dom-global-fetch"><code title="dom-global-fetch">fetch()</code></a>
JavaScript API, which exposes most of the networking functionality at a fairly low level
of abstraction.
<h2 class="short" id="conformance"><span class="secno">2 </span>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.
<a href="#refsRFC2119">[RFC2119]</a>
<h2 id="infrastructure"><span class="secno">3 </span>Infrastructure</h2>
<p>This specification uses terminology from the ABNF, Encoding, HTML, IDL, Streams, and URL Standards.
<a href="#refsABNF">[ABNF]</a>
<a href="#refsENCODING">[ENCODING]</a>
<a href="#refsHTML">[HTML]</a>
<a href="#refsWEBIDL">[WEBIDL]</a>
<a href="#refsSTREAMS">[STREAMS]</a>
<a href="#refsURL">[URL]</a>
<p>A <a class="external" data-anolis-spec="encoding" href="https://encoding.spec.whatwg.org/#byte">byte</a> sequence with bytes in the range 0x00 to
0x7F, inclusive, is represented as a <a class="external" data-anolis-spec="encoding" href="https://encoding.spec.whatwg.org/#utf-8">utf-8</a>-encoded
<a class="external" data-anolis-spec="encoding" href="https://encoding.spec.whatwg.org/#string">string</a> with code points in the range U+0000 to
U+007F, inclusive. To avoid confusion with an actual string, backticks are used.
<p class="example">"<code title="">true</code>" is a
<a class="external" data-anolis-spec="encoding" href="https://encoding.spec.whatwg.org/#string">string</a>, while `<code title="">true</code>` is a
byte sequence.
<p>Comparing two byte sequences in a <dfn id="byte-case-insensitive">byte-case-insensitive</dfn> manner means
comparing them exactly, byte for byte, except that the bytes in the range 0x41 to 0x5A,
inclusive, are considered to also match their corresponding byte in the range 0x61 to
0x7A, inclusive.
<p>A <dfn id="case-insensitive-byte-sequence">case-insensitive byte sequence</dfn> is a byte sequence that when compared to
another byte sequence does so in a <a href="#byte-case-insensitive">byte-case-insensitive</a> manner.
<p class="example">The
<a href="#case-insensitive-byte-sequence" title="case-insensitive byte sequence">case-insensitive byte sequences</a>
`<code title="">Content-Type</code>` and `<code title="">content-TYPE</code>` are equal.
<p>To <dfn id="byte-lowercase">byte-lowercase</dfn> a byte sequence, increase each byte it contains, in the
range 0x41 to 0x5A, inclusive, by 0x20.
<p>To <dfn id="byte-uppercase">byte-uppercase</dfn> a byte sequence, subtract each byte it contains, in the
range 0x61 to 0x7A, inclusive, by 0x20.
<hr>
<p id="fetch-url">A <dfn id="response-url">response URL</dfn> is a
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URL</a> for which implementations need not store the
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-fragment" title="concept-url-fragment">fragment</a> as it is never exposed. When
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-serializer" title="concept-url-serializer">serialized</a>, the
<i title="">exclude fragment flag</i> is set, meaning implementations can store the
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-fragment" title="concept-url-fragment">fragment</a> nonetheless.
<hr>
<p><dfn id="credentials">Credentials</dfn> are HTTP cookies, TLS client certificates, and
<a href="#authentication-entry" title="authentication entry">authentication entries</a>.
<hr>
<p><a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task" title="concept-task">Tasks</a> that are
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task" title="queue a task">queued</a> by this standard are annotated as one
of:
<ul class="brief">
<li><dfn id="process-request-body">process request body</dfn>
<li id="process-request-end-of-file"><dfn id="process-request-end-of-body">process request end-of-body</dfn>
<li><dfn id="process-response">process response</dfn>
<li id="process-response-end-of-file"><dfn id="process-response-end-of-body">process response end-of-body</dfn>
</ul>
<p>To <dfn id="queue-a-fetch-task">queue a fetch task</dfn> on <a href="#concept-request" title="concept-request">request</a>
<var>request</var> to <var>run an operation</var>, run these steps:
<ol>
<li><p>If <var>request</var>'s <a href="#concept-request-client" title="concept-request-client">client</a> is
null, terminate these steps.
<li><p><a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to
<var>run an operation</var> on <var>request</var>'s
<a href="#concept-request-client" title="concept-request-client">client</a>'s
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#networking-task-source">networking task source</a>.
</ol>
<p>To <dfn id="queue-a-fetch-request-done-task">queue a fetch-request-done task</dfn>, given a <var>request</var>,
<a href="#queue-a-fetch-task">queue a fetch task</a> on <var>request</var> to <a href="#process-request-end-of-body">process request end-of-body</a>
for <var>request</var>.
<hr>
<p>To <dfn id="read-a-request">read a <var>request</var></dfn>, if <var>request</var>'s
<a href="#concept-request-body" title="concept-request-body">body</a> is non-null, whenever
<var>request</var>'s <a href="#concept-request-body" title="concept-request-body">body</a> is read from (i.e.
is transmitted or read by script), increase <var>request</var>'s
<a href="#concept-request-body" title="concept-request-body">body</a>'s
<a href="#concept-body-transmitted" title="concept-body-transmitted">transmitted bytes</a> with the amount of payload body
bytes transmitted and then <a href="#queue-a-fetch-task">queue a fetch task</a> on <var>request</var> to
<a href="#process-request-body">process request body</a> for <var>request</var>.
<!-- XXX xref "read", "payload body" -->
<h3 id="http"><span class="secno">3.1 </span>HTTP</h3>
<p>While <a href="#concept-fetch" title="concept-fetch">fetching</a> 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).
<p>The <dfn id="http-whitespace-bytes">HTTP whitespace bytes</dfn> are 0x09, 0x0A, 0x0D, and 0x20.
<p>An <dfn id="concept-https-state-value" title="concept-https-state-value">HTTPS state value</dfn> is "<code title="">none</code>",
"<code title="">deprecated</code>", or "<code title="">modern</code>".
<p class="note no-backref">A <a href="#concept-response" title="concept-response">response</a> delivered over HTTPS will
typically have its <a href="#concept-response-https-state" title="concept-response-https-state">HTTPS state</a> set to
"<code title="">modern</code>". A user agent can use "<code title="">deprecated</code>" in a transition
period. E.g., while removing support for a hash function, weak cypher suites, certificates for an
"Internal Name", or certificates with an overly long validity period. How exactly a user agent can
use "<code title="">deprecated</code>" is not defined by this specification. An
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> typically derives its
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#https-state">HTTPS state</a> from a <a href="#concept-response" title="concept-response">response</a>.
<h4 id="methods"><span class="secno">3.1.1 </span>Methods</h4>
<p>A <dfn id="concept-method" title="concept-method">method</dfn> is a byte sequence that matches the
<a class="external" data-anolis-spec="http" href="https://tools.ietf.org/html/rfc7230#section-3.1.1">method</a> token production.
<p id="simple-method">A <dfn id="cors-safelisted-method">CORS-safelisted method</dfn> is a
<a href="#concept-method" title="concept-method">method</a> that is `<code title="">GET</code>`,
`<code title="">HEAD</code>`, or `<code title="">POST</code>`.
<p>A <dfn id="forbidden-method">forbidden method</dfn> is a <a href="#concept-method" title="concept-method">method</a> that is a
<a href="#byte-case-insensitive">byte-case-insensitive</a> match for `<code title="">CONNECT</code>`,
`<code title="">TRACE</code>`, or `<code title="">TRACK</code>`.
<a class="informative" href="#refsHTTPVERBSEC">[HTTPVERBSEC]</a>
<p>To <dfn id="concept-method-normalize" title="concept-method-normalize">normalize</dfn> a
<a href="#concept-method" title="concept-method">method</a>, if it is a <a href="#byte-case-insensitive">byte-case-insensitive</a>
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>`, <a href="#byte-uppercase">byte-uppercase</a> it.
<p class="note no-backref"><a href="#concept-method-normalize" title="concept-method-normalize">Normalization</a> is
done for backwards compatibility and consistency across APIs as
<a href="#concept-method" title="concept-method">methods</a> are actually "case-sensitive".
<p class="example">Using `<code title="">patch</code>` is highly likely to result in a
`<code title="">405 Method Not Allowed</code>`. `<code title="">PATCH</code>` is much more likely to
succeed.
<p class="note no-backref">There are no restrictions on <a href="#concept-method" title="concept-method">methods</a>.
`<code title="">CHICKEN</code>` is perfectly acceptable (and not a misspelling of
`<code title="">CHECKIN</code>`). Other than those that are
<a href="#concept-method-normalize" title="concept-method-normalize">normalized</a> there are no casing restrictions either.
`<code title="">Egg</code>` or `<code title="">eGg</code>` would be fine, though uppercase is encouraged
for consistency.
<h4 id="terminology-headers"><span class="secno">3.1.2 </span>Headers</h4>
<p>A <dfn id="concept-header-list" title="concept-header-list">header list</dfn> consists of zero or more
<a href="#concept-header" title="concept-header">headers</a>.
<p class="note no-backref">A <a href="#concept-header-list" title="concept-header-list">header list</a> is essentially a
specialized multimap. An ordered list of key-value pairs with potentially duplicate keys.
<p>To <dfn id="concept-header-list-append" title="concept-header-list-append">append</dfn> a
<a href="#concept-header-name" title="concept-header-name">name</a>/<a href="#concept-header-value" title="concept-header-value">value</a>
(<var>name</var>/<var>value</var>) pair to a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), append a new
<a href="#concept-header" title="concept-header">header</a> whose <a href="#concept-header-name" title="concept-header-name">name</a>
is <var>name</var>, <a href="#byte-lowercase" title="byte-lowercase">byte-lowercased</a>, and
<a href="#concept-header-value" title="concept-header-value">value</a> is <var>value</var>, to
<var>list</var>.
<p>To <dfn id="concept-header-list-delete" title="concept-header-list-delete">delete</dfn> a
<a href="#concept-header-name" title="concept-header-name">name</a> (<var>name</var>) from a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), remove all
<a href="#concept-header" title="concept-header">headers</a> whose
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>,
<a href="#byte-lowercase" title="byte-lowercase">byte-lowercased</a>, from <var>list</var>.
<p>To <dfn id="concept-header-list-set" title="concept-header-list-set">set</dfn> a
<a href="#concept-header-name" title="concept-header-name">name</a>/<a href="#concept-header-value" title="concept-header-value">value</a>
(<var>name</var>/<var>value</var>) pair in a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), run these
steps:
<ol>
<li><p><a href="#byte-lowercase">Byte-lowercase</a> <var>name</var>.
<li><p>If there are any <a href="#concept-header" title="concept-header">headers</a> in
<var>list</var> whose <a href="#concept-header-name" title="concept-header-name">name</a> is
<var>name</var>, set the <a href="#concept-header-value" title="concept-header-value">value</a> of the first
such <a href="#concept-header" title="concept-header">header</a> to <var>value</var> and remove the
others.
<li><p>Otherwise, append a new <a href="#concept-header" title="concept-header">header</a> whose
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var> and
<a href="#concept-header-value" title="concept-header-value">value</a> is <var>value</var>, to
<var>list</var>.
</ol>
<p>To <dfn id="concept-header-list-combine" title="concept-header-list-combine">combine</dfn> a
<a href="#concept-header-name" title="concept-header-name">name</a>/<a href="#concept-header-value" title="concept-header-value">value</a>
(<var>name</var>/<var>value</var>) pair in a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), run these
steps:
<ol>
<li><p><a href="#byte-lowercase">Byte-lowercase</a> <var>name</var>.
<li><p>If there are any <a href="#concept-header" title="concept-header">headers</a> in <var>list</var> whose
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, set the
<a href="#concept-header-value" title="concept-header-value">value</a> of the first such
<a href="#concept-header" title="concept-header">header</a> to its <a href="#concept-header-value" title="concept-header-value">value</a>,
followed by 0x2C 0x20, followed by <var>value</var>.
<li><p>Otherwise, append a new <a href="#concept-header" title="concept-header">header</a> whose
<a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var> and
<a href="#concept-header-value" title="concept-header-value">value</a> is <var>value</var>, to
<var>list</var>.
</ol>
<p class="note no-backref"><a href="#concept-header-list-combine" title="concept-header-list-combine">Combine</a> is used by
<a href="https://xhr.spec.whatwg.org/#xmlhttprequest"><code class="external" data-anolis-spec="xhr">XMLHttpRequest</code></a> and the
<a href="#concept-websocket-establish" title="concept-websocket-establish">WebSocket protocol handshake</a>.
<p>To <dfn id="concept-header-list-sort-and-combine" title="concept-header-list-sort-and-combine">sort and combine</dfn> a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), run these steps:
<ol>
<li><p>Let <var>headers</var> be an empty list of
<a href="#concept-header-name" title="concept-header-name">name</a>-<a href="#concept-header-value" title="concept-header-value">value</a> pairs
with the key being the <a href="#concept-header-name" title="concept-header-name">name</a> and value the
<a href="#concept-header-value" title="concept-header-value">value</a>.
<li><p>Let <var>names</var> be all the <a href="#concept-header-name" title="concept-header-name">names</a> of the
<a href="#concept-header" title="concept-header">headers</a> in <var>list</var>, with duplicates removed, and sorted
lexicographically.
<li>
<p>For each <var>name</var> in <var>names</var>, run these substeps:
<ol>
<li><p>Let <var>value</var> be the
<a href="#concept-header-value-combined" title="concept-header-value-combined">combined value</a> given <var>name</var> and
<var>list</var>.
<li><p>Append <var>name</var>-<var>value</var> to <var>headers</var>.
</ol>
<li><p>Return <var>headers</var>.
</ol>
<hr>
<p>A <dfn id="concept-header" title="concept-header">header</dfn> consists of a
<dfn id="concept-header-name" title="concept-header-name">name</dfn> and <dfn id="concept-header-value" title="concept-header-value">value</dfn>.
A <a href="#concept-header-name" title="concept-header-name">name</a> is a
<a href="#case-insensitive-byte-sequence">case-insensitive byte sequence</a> that matches the
<a class="external" data-anolis-spec="http" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-name</a> token production. A
<a href="#concept-header-value" title="concept-header-value">value</a> is a byte sequence that matches the
<a class="external" data-anolis-spec="http" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-content</a> token production.
<p class="note no-backref"><a class="external" data-anolis-spec="http" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-value</a> allows 0x0A and
0x0D bytes which can lead to reparsing issues.
<p>To <dfn id="concept-header-value-normalize" title="concept-header-value-normalize">normalize</dfn> a
<a href="#concept-header-value" title="concept-header-value">value</a>, remove any leading and trailing
<a href="#http-whitespace-bytes">HTTP whitespace bytes</a> from it.
<p>A <dfn id="concept-header-value-combined" title="concept-header-value-combined">combined value</dfn>, given a
<a href="#concept-header-name" title="concept-header-name">name</a> (<var>name</var>) and
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>list</var>), is the
<a href="#concept-header-value" title="concept-header-value">values</a> of all <a href="#concept-header" title="concept-header">headers</a> in
<var>list</var> whose <a href="#concept-header-name" title="concept-header-name">name</a> is <var>name</var>, separated from
each other by `<code title="">,</code>`, in order.
<hr>
<p id="simple-header">A <dfn id="cors-safelisted-request-header">CORS-safelisted request-header</dfn> is a
<a href="#concept-header" title="concept-header">header</a> whose <a href="#concept-header-name" title="concept-header-name">name</a> is one of
<ul class="brief">
<li>`<code title="">Accept</code>`
<li>`<code title="">Accept-Language</code>`
<li>`<code title="">Content-Language</code>`
<li>`<code title="">Content-Type</code>` and whose <a href="#concept-header-value" title="concept-header-value">value</a>,
<a href="#concept-header-parse" title="concept-header-parse">once parsed</a>, has a MIME type (ignoring parameters)
that is `<code title="">application/x-www-form-urlencoded</code>`,
`<code title="">multipart/form-data</code>`, or `<code title="">text/plain</code>`
</ul>
<!-- XXX * needs better xref
* ignoring parameters has been the standard for a long time now
* interesting test: "Content-Type: text/plain;" -->
<p>or whose <a href="#concept-header-name" title="concept-header-name">name</a> is one of
<ul class="brief">
<li>`<code title=""><a href="http://httpwg.org/http-extensions/client-hints.html#dpr">DPR</a></code>`
<li>`<code title=""><a href="http://httpwg.org/http-extensions/client-hints.html#downlink">Downlink</a></code>`
<li>`<code title=""><a href="http://httpwg.org/http-extensions/client-hints.html#save-data">Save-Data</a></code>`
<li>`<code title=""><a href="http://httpwg.org/http-extensions/client-hints.html#viewport-width">Viewport-Width</a></code>`
<li>`<code title=""><a href="http://httpwg.org/http-extensions/client-hints.html#width">Width</a></code>`
</ul>
<p>and whose <a href="#concept-header-value" title="concept-header-value">value</a>,
<a href="#concept-header-parse" title="concept-header-parse">once parsed</a>, is not a failure.
<p>A <dfn id="cors-non-wildcard-request-header-name">CORS non-wildcard request-header name</dfn> is `<code title="">Authorization</code>`.
<p>A <dfn id="cors-safelisted-response-header-name">CORS-safelisted response-header name</dfn>, given a
<a href="#concept-response-cors-exposed-header-name-list" title="concept-response-cors-exposed-header-name-list">CORS-exposed header-name list</a>
<var>list</var>, is a <a href="#concept-header" title="concept-header">header</a>
<a href="#concept-header-name" title="concept-header-name">name</a> that is one of
<ul class="brief">
<li>`<code title="">Cache-Control</code>`
<li>`<code title="">Content-Language</code>`
<li>`<code title="">Content-Type</code>`
<li>`<code title="">Expires</code>`
<li>`<code title="">Last-Modified</code>`
<li>`<code title="">Pragma</code>`
<li>Any <a href="#concept-header-value" title="concept-header-value">value</a> in <var>list</var> that is not a
<a href="#forbidden-response-header-name">forbidden response-header name</a>.
</ul>
<p>A <dfn id="forbidden-header-name">forbidden header name</dfn> is a <a href="#concept-header" title="concept-header">header</a>
<a href="#concept-header-name" title="concept-header-name">name</a> that 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>`<a href="#http-origin"><code title="http-origin">Origin</code></a>`
<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="">Via</code>`
</ul>
<p>or a <a href="#concept-header" title="concept-header">header</a> <a href="#concept-header-name" title="concept-header-name">name</a> that
starts with `<code title="">Proxy-</code>` or `<code title="">Sec-</code>` (including being 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.
<a href="#concept-header-name" title="concept-header-name">Names</a> starting with `<code title="">Sec-</code>` are
reserved to allow new <a href="#concept-header" title="concept-header">headers</a> to be minted that are safe
from APIs using <a href="#concept-fetch" title="concept-fetch">fetch</a> that allow control over
<a href="#concept-header" title="concept-header">headers</a> by developers, such as
<a href="https://xhr.spec.whatwg.org/#xmlhttprequest"><code class="external" data-anolis-spec="xhr">XMLHttpRequest</code></a>.
<a class="informative" href="#refsXHR">[XHR]</a>
<p>A <dfn id="forbidden-response-header-name">forbidden response-header name</dfn> is a <a href="#concept-header" title="concept-header">header</a>
<a href="#concept-header-name" title="concept-header-name">name</a> that is one of:
<ul class="brief">
<li>`<code title="">Set-Cookie</code>`
<li>`<code title="">Set-Cookie2</code>`
</ul>
<hr>
<p>To <dfn id="concept-header-parse" title="concept-header-parse">parse a header value</dfn> given a
<a href="#concept-header-name" title="concept-header-name">name</a> (<var>name</var>) and a
<a href="#concept-header" title="concept-header">header</a> or a <a href="#concept-header-list" title="concept-header-list">header list</a>
(<var>headers</var>), run these steps:
<ol>
<li><p>If <var>name</var> is not in <var>headers</var>, return null.
<li>
<p>If the ABNF for <var>name</var> allows a single
<a href="#concept-header" title="concept-header">header</a> and <var>headers</var> contains more than
one, return failure.
<p class="note no-backref">If different error handling is required, extract the desired
<a href="#concept-header" title="concept-header">header</a> first.
<li><p>If parsing all the <a href="#concept-header" title="concept-header">headers</a>
<a href="#concept-header-name" title="concept-header-name">named</a> <var>name</var> in
<var>headers</var>, per the ABNF for <var>name</var>, failed, return failure.
<li><p>Return one or more <a href="#concept-header-value" title="concept-header-value">values</a> resulting from
parsing all the <a href="#concept-header" title="concept-header">headers</a>
<a href="#concept-header-name" title="concept-header-name">named</a> <var>name</var> in
<var>headers</var>, per the ABNF for <var>name</var>.
</ol>
<p>To <dfn id="concept-header-extract-mime-type" title="concept-header-extract-MIME-type">extract a MIME type</dfn> from a
<a href="#concept-header-list" title="concept-header-list">header list</a> (<var>headers</var>), run these
steps:
<ol>
<li><p>Let <var>MIMEType</var> be the result of
<a href="#concept-header-parse" title="concept-header-parse">parsing</a> `<code title="">Content-Type</code>` in
<var>headers</var>.
<li><p>If <var>MIMEType</var> is null or failure, return the empty byte sequence.
<li><p>Return <var>MIMEType</var>,
<a href="#byte-lowercase" title="byte-lowercase">byte-lowercased</a>.
</ol>
<hr>
<p>A <dfn id="default-user-agent-value">default `<code>User-Agent</code>` value</dfn> is a
user-agent-defined <a href="#concept-header-value" title="concept-header-value">value</a> for the
`<code title="http-user-agent">User-Agent</code>` <a href="#concept-header" title="concept-header">header</a>.
<h4 id="statuses"><span class="secno">3.1.3 </span>Statuses</h4>
<p>A <dfn id="concept-status">status</dfn> is a code.
<p>A <dfn id="null-body-status">null body status</dfn> is a <a href="#concept-status">status</a> that is <code>101</code>,
<code>204</code>, <code>205</code>, or <code>304</code>.
<p>An <dfn id="ok-status">ok status</dfn> is any <a href="#concept-status">status</a> in the range <code>200</code> to
<code>299</code>, inclusive.
<p>A <dfn id="redirect-status">redirect status</dfn> is a <a href="#concept-status">status</a> that is <code>301</code>, <code>302</code>,
<code>303</code>, <code>307</code>, or <code>308</code>.
<h4 id="bodies"><span class="secno">3.1.4 </span>Bodies</h4>
<p>A <dfn id="concept-body" title="concept-body">body</dfn> consists of:
<ul>
<li>
<p>A <dfn id="concept-body-stream" title="concept-body-stream">stream</dfn> (a
<a href="#concept-readablestream"><code title="concept-ReadableStream">ReadableStream</code></a> object).
<p class="XXX"><a href="https://github.com/whatwg/streams/issues/379">This might become a
<code>ReadableByteStream</code> object</a>. While the type might change, the behavior specified
will be equivalent since the hypothetical <code title="">ReadableByteStream</code> object will have
the same members as the <a href="#concept-readablestream"><code title="concept-ReadableStream">ReadableStream</code></a> object has today.
<li><p>A <dfn id="concept-body-transmitted" title="concept-body-transmitted">transmitted bytes</dfn> (an integer), initially 0.
<li><p>A <dfn id="concept-body-total-bytes" title="concept-body-total-bytes">total bytes</dfn> (an integer), initially 0.
</ul>
<p>A <a href="#concept-body" title="concept-body">body</a> <var>body</var> is said to be
<dfn id="concept-body-done" title="concept-body-done">done</dfn> if <var>body</var> is null or <var>body</var>'s
<a href="#concept-body-stream" title="concept-body-stream">stream</a> is
<a href="#concept-readablestream-closed" title="concept-ReadableStream-closed">closed</a> or
<a href="#concept-readablestream-errored" title="concept-ReadableStream-errored">errored</a>.
<p>To <dfn id="concept-body-wait" title="concept-body-wait">wait</dfn> for a <a href="#concept-body" title="concept-body">body</a>
<var>body</var>, wait for <var>body</var> to be <a href="#concept-body-done" title="concept-body-done">done</a>.
<p>To <dfn id="concept-body-clone" title="concept-body-clone">clone</dfn> a <a href="#concept-body" title="concept-body">body</a>
<var>body</var>, run these steps:
<ol>
<li><p>Let «<var>out1</var>, <var>out2</var>» be the result of
<a href="#concept-tee-readablestream" title="concept-tee-ReadableStream">teeing</a> <var>body</var>'s
<a href="#concept-body-stream" title="concept-body-stream">stream</a>. Rethrow any exceptions.
<li><p>Set <var>body</var>'s <a href="#concept-body-stream" title="concept-body-stream">stream</a> to <var>out1</var>.
<li><p>Return a <a href="#concept-body" title="concept-body">body</a> whose
<a href="#concept-body-stream" title="concept-body-stream">stream</a> is <var>out2</var> and other members are copied from
<var>body</var>.
</ol>
<p>To <dfn id="handle-content-codings">handle content codings</dfn> given <var>codings</var> and
<var>bytes</var>, run these substeps:
<ol>
<li><p>If <var>codings</var> are not supported, return <var>bytes</var>.
<li><p>Return the result of decoding bytes with the given
<var>codings</var> as explained in HTTP. <a href="#refsHTTP">[HTTP]</a>
</ol>
<!-- XXX no hook in HTTP -->
<h4 id="requests"><span class="secno">3.1.5 </span>Requests</h4>
<p>The input to <a href="#concept-fetch" title="concept-fetch">fetch</a> is a
<dfn id="concept-request" title="concept-request">request</dfn>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-method" title="concept-request-method">method</dfn> (a
<a href="#concept-method" title="concept-method">method</a>). Unless stated otherwise it is
`<code title="">GET</code>`.
<p class="note no-backref">This can be updated during redirects to `<code title="">GET</code>` as
described in <a href="#concept-http-fetch" title="concept-http-fetch">HTTP fetch</a>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-url" title="concept-request-url">url</dfn> (a
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URL</a>).
<p class="note no-backref">Implementations are encouraged to make this a pointer to the first
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URL</a> in
<a href="#concept-request" title="concept-request">request</a>'s <a href="#concept-request-url-list" title="concept-request-url-list">url list</a>.
It is provided as a distinct field solely for the convenience of other standards hooking into Fetch.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="local-urls-only-flag">local-URLs-only flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="sandboxed-storage-area-urls-flag">sandboxed-storage-area-URLs flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-header-list" title="concept-request-header-list">header list</dfn> (a
<a href="#concept-header-list" title="concept-header-list">header list</a>). Unless stated otherwise it is empty.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="unsafe-request-flag">unsafe-request flag</dfn>. Unless stated otherwise it is unset.
<p class="note no-backref">The <a href="#unsafe-request-flag">unsafe-request flag</a> is set by APIs such as
<a href="#dom-global-fetch"><code title="dom-global-fetch">fetch()</code></a> and
<a href="https://xhr.spec.whatwg.org/#xmlhttprequest"><code class="external" data-anolis-spec="xhr">XMLHttpRequest</code></a> to ensure a
<a href="#cors-preflight-fetch-0">CORS-preflight fetch</a> is done based on the supplied
<a href="#concept-request-method" title="concept-request-method">method</a> and
<a href="#concept-request-header-list" title="concept-request-header-list">header list</a>. It does not free an API from
outlawing <a href="#forbidden-method" title="forbidden method">forbidden methods</a> and
<a href="#forbidden-header-name" title="forbidden header name">forbidden header names</a>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-body" title="concept-request-body">body</dfn> (null or a
<a href="#concept-body" title="concept-body">body</a>). Unless stated otherwise it is null.
<p class="note no-backref">This can be updated during redirects to null as described in
<a href="#concept-http-fetch" title="concept-http-fetch">HTTP fetch</a>.
<hr>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-client" title="concept-request-client">client</dfn> (null or an
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>).
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-window" title="concept-request-window">window</dfn> ("<code>no-window</code>",
"<code>client</code>", or an
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> whose
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global" title="concept-settings-object-global">global object</a> is a
<a href="https://html.spec.whatwg.org/multipage/browsers.html#window"><code class="external" data-anolis-spec="html">Window</code></a> object). Unless stated otherwise it is
"<code>client</code>".
<p class="note no-backref">The "<code>client</code>" value is changed to "<code>no-window</code>" or
<a href="#concept-request" title="concept-request">request</a>'s <a href="#concept-request-client" title="concept-request-client">client</a> during
<a href="#concept-fetch" title="concept-fetch">fetching</a>. It provides a convenient way for standards to not have to
explicitly set <a href="#concept-request" title="concept-request">request</a>'s
<a href="#concept-request-window" title="concept-request-window">window</a>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-target-browsing-context" title="concept-request-target-browsing-context">target browsing context</dfn> (null or a
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>). Unless stated otherwise it is null.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="keep-alive-flag">keep-alive flag</dfn>. Unless stated otherwise it is unset.
<p class="note no-backref">This is used by <code>navigator.sendBeacon</code> and the HTML
<code>img</code> element to outlive the
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="skip-service-worker-flag">skip-service-worker flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-initiator" title="concept-request-initiator">initiator</dfn>, which is
the empty string,
"<code title="">download</code>",
"<code title="">imageset</code>",
"<code title="">manifest</code>", or
"<code title="">xslt</code>". Unless stated otherwise it is the empty string.
<p class="note no-backref">A <a href="#concept-request" title="concept-request">request</a>'s
<a href="#concept-request-initiator" title="concept-request-initiator">initiator</a> is not particularly granular for
the time being as other specifications do not require it to. It is primarily a
specification device to assist defining CSP and Mixed Content. It is not exposed to
JavaScript. <a href="#refsCSP">[CSP]</a> <a href="#refsMIX">[MIX]</a>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-type" title="concept-request-type">type</dfn>, which is
the empty string,
"<code title="">audio</code>",
"<code title="">font</code>",
"<code title="">image</code>",
"<code title="">script</code>",
"<code title="">style</code>",
"<code title="">track</code>", or
"<code title="">video</code>". Unless stated otherwise it is the empty string.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-destination" title="concept-request-destination">destination</dfn>, which is
the empty string,
"<code title="">document</code>",
"<code title="">embed</code>",
"<code title="">font</code>",
"<code title="">image</code>",
"<code title="">manifest</code>",
"<code title="">media</code>",
"<code title="">object</code>",
"<code title="">report</code>",
"<code title="">script</code>",
"<code title="">serviceworker</code>",
"<code title="">sharedworker</code>",
"<code title="">style</code>",
"<code title="">worker</code>", or
"<code title="">xslt</code>". Unless stated otherwise it is the empty string.
<div class="note">
<p>The following table illustrates the relationship between a
<a href="#concept-request" title="concept-request">request</a>'s
<a href="#concept-request-initiator" title="concept-request-initiator">initiator</a>,
<a href="#concept-request-type" title="concept-request-type">type</a>,
<a href="#concept-request-destination" title="concept-request-destination">destination</a>, CSP directives, and features.
<table>
<tr>
<th><a href="#concept-request-initiator" title="concept-request-initiator">Initiator</a>
<th><a href="#concept-request-type" title="concept-request-type">Type</a>
<th><a href="#concept-request-destination" title="concept-request-destination">Destination</a>
<th>CSP directive
<th>Features
<tr>
<td rowspan="16">""
<td rowspan="6">""
<td>"<code title="">report</code>"
<td rowspan="2">?
<td>CSP, NEL reports.
<tr>
<td>"<code title="">document</code>"
<td>HTML's navigate algorithm.
<tr>
<td>"<code title="">document</code>"
<td><code title="">child-src</code>
<td>HTML's <code><iframe></code> and <code><frame></code>
<tr>
<td>""
<td><code title="">connect-src</code>
<td><code>navigator.sendBeacon()</code>, <code>EventSource</code>,
HTML's <code>ping=""</code>, <a href="#dom-global-fetch"><code title="dom-global-fetch">fetch()</code></a>,
<code>XMLHttpRequest</code>, <code>WebSocket</code>, Cache API?
<tr>
<td>"<code title="">object</code>"
<td><code title="">object-src</code>
<td>HTML's <code><object></code>
<tr>
<td>"<code title="">embed</code>"
<td><code title="">object-src</code>
<td>HTML's <code><embed></code>
<tr>
<td>"<code title="">audio</code>"
<td>"<code title="">media</code>"
<td><code title="">media-src</code>
<td>HTML's <code><audio></code>
<tr>
<td>"<code title="">font</code>"
<td>"<code title="">font</code>"
<td><code title="">font-src</code>
<td>CSS' <code>@font-face</code>
<tr>
<td>"<code title="">image</code>"
<td>"<code title="">image</code>"
<td><code title="">img-src</code>
<td>HTML's <code><img src></code>, <code title="">/favicon.ico</code> resource,
SVG's <code><image></code>, CSS' <code>background-image</code>, CSS'
<code>cursor</code>, CSS' <code>list-style-image</code>, …
<tr>
<td rowspan="4">"<code title="">script</code>"
<td>"<code title="">script</code>"
<td><code title="">script-src</code>
<td>HTML's <code><script></code>, <code>importScripts()</code>
<tr>
<td>"<code title="">serviceworker</code>"
<td>?
<td><code title="">navigator.serviceWorker.register()</code>
<tr>
<td>"<code title="">sharedworker</code>"
<td><code title="">child-src</code>
<td><code>SharedWorker</code>
<tr>
<td>"<code title="">worker</code>"
<td><code title="">child-src</code>
<td><code>Worker</code>
<tr>
<td>"<code title="">style</code>"
<td>"<code title="">style</code>"
<td><code title="">style-src</code>
<td>HTML's <code><link rel=stylesheet></code>, CSS' <code>@import</code>
<tr>
<td>"<code title="">track</code>"
<td>"<code title="">media</code>"
<td><code title="">media-src</code>
<td>HTML's <code><track></code>
<tr>
<td>"<code title="">video</code>"
<td>"<code title="">media</code>"
<td><code title="">media-src</code>
<td>HTML's <code><video></code> element
<tr>
<td>"<code title="">download</code>"
<td>""
<td>""
<td>?
<td>HTML's <code>download=""</code>, "Save Link As…" UI
<tr>
<td>"<code title="">imageset</code>"
<td>"<code title="">image</code>"
<td>"<code title="">image</code>"
<td><code title="">img-src</code>
<td>HTML's <code><img srcset></code> and <code><picture></code>
<tr>
<td>"<code title="">manifest</code>"
<td rowspan="2">""
<td>"<code title="">manifest</code>"
<td><code title="">manifest-src</code>
<td>HTML's <code><link rel=manifest></code>
<tr>
<td>"<code title="">xslt</code>"
<td>"<code title="">xslt</code>"
<td><code title="">script-src</code>
<td><code><?xml-stylesheet></code>
</table>
<p>CSP's <code>form-action</code> needs to be a hook directly in HTML's navigate or form
submission algorithm.
<p>CSP will also need to check
<a href="#concept-request" title="concept-request">request</a>'s
<a href="#concept-request-client" title="concept-request-client">client</a>'s
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>'s
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#ancestor-browsing-context" title="ancestor browsing context">ancestor browsing contexts</a>
for various CSP directives.
</div>
<hr>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-priority" title="concept-request-priority">priority</dfn> (null or a user-agent-defined object).
Unless otherwise stated it is null.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-origin" title="concept-request-origin">origin</dfn>, which is "<code>client</code>" or an
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#origin">origin</a>. Unless stated otherwise it is "<code>client</code>".
<p class="note no-backref">"<code>client</code>" is changed to an
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#origin">origin</a> during <a href="#concept-fetch" title="concept-fetch">fetching</a>. It
provides a convenient way for standards to not have to set
<a href="#concept-request" title="concept-request">request</a>'s <a href="#concept-request-origin" title="concept-request-origin">origin</a>.
<a href="#concept-request" title="concept-request">Request</a>'s <a href="#concept-request-origin" title="concept-request-origin">origin</a> can be
changed during redirects too.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="omit-origin-header-flag">omit-<code>Origin</code>-header flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="same-origin-data-url-flag">same-origin data-URL flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-referrer" title="concept-request-referrer">referrer</dfn>, which is "<code>no-referrer</code>",
"<code>client</code>", or a <a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URL</a>.
Unless stated otherwise it is "<code>client</code>".
<p class="note no-backref">"<code>client</code>" is changed to "<code>no-referrer</code>" or a
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URL</a> during
<a href="#concept-fetch" title="concept-fetch">fetching</a>. It provides a convenient way for standards to not have to
set <a href="#concept-request" title="concept-request">request</a>'s
<a href="#concept-request-referrer" title="concept-request-referrer">referrer</a>.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-referrer-policy" title="concept-request-referrer-policy">referrer policy</dfn>, which is a
<a href="#concept-referrer-policy" title="concept-referrer-policy">referrer policy</a>. Unless stated otherwise it is
the empty string.
<p class="note no-backref">This can be used to override a referrer policy associated with
an <a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>.
<a href="#refsREFERRER">[REFERRER]</a>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-client-hints-list" title="concept-request-client-hints-list">client hints list</dfn>, which is a
<a href="#concept-client-hints-list" title="concept-client-hints-list">client-hints list</a>. Unless stated otherwise, it is
the empty list.
<p class="note no-backref">This will be used to override a client hints list associated with
an <a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>.
<a href="#refsCLIENT-HINTS">[CLIENT-HINTS]</a>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="synchronous-flag">synchronous flag</dfn>. Unless stated otherwise it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-mode" title="concept-request-mode">mode</dfn>, which is "<code title="">same-origin</code>",
"<code title="">cors</code>", "<code title="">no-cors</code>", "<code title="">navigate</code>", or
"<code title="">websocket</code>". Unless stated otherwise, it is "<code title="">no-cors</code>".
<p class="note no-backref">Even though the default <a href="#concept-request" title="concept-request">request</a>
<a href="#concept-request-mode" title="concept-request-mode">mode</a> is "<code title="">no-cors</code>", standards are highly
discouraged from using it for new features. It is rather unsafe. "<code title="">navigate</code>" and
"<code title="">websocket</code>" are special values for the HTML Standard.
<a href="#refsHTML">[HTML]</a>
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="use-cors-preflight-flag">use-CORS-preflight flag</dfn>. Unless stated otherwise, it is unset.
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
<dfn id="concept-request-credentials-mode" title="concept-request-credentials-mode">credentials mode</dfn>, which is
"<code title="">omit</code>", "<code title="">same-origin</code>", or
"<code title="">include</code>". Unless stated otherwise, it is "<code title="">omit</code>".
<p class="note no-backref"><a href="#concept-request" title="concept-request">Request</a>'s
<a href="#concept-request-credentials-mode" title="concept-request-credentials-mode">credentials mode</a> controls the flow of
<a href="#credentials">credentials</a> during a <a href="#concept-fetch" title="concept-fetch">fetch</a>. When
<a href="#concept-request" title="concept-request">request</a>'s <a href="#concept-request-mode" title="concept-request-mode">mode</a> is
"<code title="">navigate</code>", its
<a href="#concept-request-credentials-mode" title="concept-request-credentials-mode">credentials mode</a> is assumed to be