-
Notifications
You must be signed in to change notification settings - Fork 4
/
495.txt
3109 lines (2850 loc) · 146 KB
/
495.txt
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
* Introduction
''This section is non-normative.''
[907] This document is an implementation of Web transport protocols.
* Fetch and connections
[822] In the steps to [[obtain a connection]], to establish an HTTP connection,
run these steps:
[FIG(steps)[
= [808] Let [VAR[transport]] be the result of
[[establishing a transport][establish a transport]]
for the request's [F[current url]], [VAR[credentials]] flag, and the [[user agent]].
= [823] If [VAR[transport]] is a [[failure]]:
== [824] Return a [[failure]].
= [825] Otherwise:
== [826] Return an [[HTTP connection]]:
[FIG(list members)[
[FIGCAPTION[
[[HTTP connection]]
]FIGCAPTION]
: [F[endpoint type][connection's endpoint type]] : [CODE[client]]
: [F[transport][connection's transport]] : [VAR[transport]]
]FIG]
]FIG]
[809] To [[obtain a WebSocket connection]] for [VAR[url]], run these steps:
[FIG(steps)[
= [821] Let [VAR[transport]] be the result of
[[establishing a transport][establish a transport]]
for [VAR[url]] and the [[user agent]], with [VAR[ws]] flag set.
= [827] If [VAR[transport]] is a [[failure]]:
== [828] Return a [[failure]].
= [829] Otherwise:
== [830] Return an [[HTTP connection]]:
[FIG(list members)[
[FIGCAPTION[
[[HTTP connection]]
]FIGCAPTION]
: [F[endpoint type][connection's endpoint type]] : [CODE[client]]
: [F[transport][connection's transport]] : [F[transport]]
]FIG]
]FIG]
[607] To [DFN[wait for other connections]] with [VAR[host]] and [VAR[port]]
in [VAR[user agent]], run these steps:
[FIG(steps)[
= [831] If [VAR[host]] is a [[domain]]:
== [832] Let [VAR[n]] be an implementation dependent small number.
= [833] Otherwise:
== [834] Let [VAR[n]] be [N[1]].
= [835] Wait while the number of [[connections][connection]]
whose
[F[remote address or domain][transport's remote address or domain]] is [VAR[host]],
[F[remote port][transport's remote port]] is [VAR[port]], and
[F[WebSocket接続の状態]] is [CODE[CONNECTING]],
in [VAR[user agent]]'s [F[connection pool]],
is ''not'' less than [VAR[n]].
]FIG]
[896] To modify [VAR[request]]'s [F[header list][request's header list]] per HTTP
in [[HTTP-network-or-cache fetch]], run these steps:
[FIG(steps)[
= [898] Append [CODE[Accept-Encoding]] header, if necessary.
= [897] Append [CODE[DNT]] header, if necessary.
= [899] Append [CODE[Upgrade-Insecure-Requests]] header, if necessary.
]FIG]
[838] To make an HTTP request over [VAR[connection]] using [VAR[request]]
in [[HTTP-network fetch]],
with [VAR[credentials]] flag and optional [VAR[not retryable]] flag,
run these steps:
[FIG(steps)[
= [837] If [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[http protocol][transport's http protocol]] is [CODE[http2]]:
==
@@
= [541] If [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[request mode]] is ''HTTP proxy'':
== [845] Let [VAR[target]] be the result of applying [[URL serializer]] to
[VAR[request]]'s [F[current url]] with [VAR[exclude fragment flag]] set.
= [843] Otherwise:
== [844] Let [VAR[target]] be [VAR[request]]'s [F[current url]]'s [F[pathquery]].
= [901] Let [VAR[host header]] be [VAR[request]]'s [F[current url]]'s [F[hostport]].
= [900] Append [CODE[Host]]/[VAR[host header]] to [VAR[request]]'s [F[header list][request's header list]].
= [905] Append [CODE[Connection]]/[CODE[keep-alive]] to [VAR[request]]'s
[F[header list][request's header list]].
= [840] Send an [[HTTP request]] over [VAR[connection]].
[FIG(list members)[
[FIGCAPTION[
[[HTTP request]]
]FIGCAPTION]
: [F[要求メソッド]] : [VAR[request]]'s [F[method][request method]]
: [F[要求対象]] : [VAR[target]]
: [F[ヘッダーリスト]] : [VAR[request]]'s [F[header list][request's header list]]
: [F[本体]] : [VAR[request]]'s [F[body][request body]]
]FIG]
= [839] Process notifications from [VAR[connection]] as follows:
[FIG(switch)[
: 要求の本体の一部の送信の通知 : Process [VAR[transmitted]] as follows:
[FIG(steps)[
=
@@ Increase [VAR[request]]'s [F[body][request body]] stream's transmitted bytes
]FIG]
: 要求の送信完了の通知 :
[FIG(steps)[
=
@@ Set [VAR[request]]'s [F[body][request body]] stream's done flag
]FIG]
: 応答のヘッダー受信完了の通知 : Process [VAR[http response]] as follows:
[FIG(steps)[
= [856] If [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[request mode]] is ''not'' ''HTTP proxy'' and
[VAR[http response]]'s [F[状態符号]] is [CODE[407]]:
== [857] Set [VAR[response]] to a [[network error]].
= [858] Otherwise:
== [841] Set [VAR[response]] to a [[response]].
[FIG(list members)[
[FIGCAPTION[
[[Response][response]]
]FIGCAPTION]
: [F[status][status code]] : [VAR[http response]]'s [F[状態符号]]
: [F[status message]] : [VAR[http response]]'s [F[理由句]]
: [F[header list][response's header list]] : [VAR[http response]]'s [F[ヘッダーリスト]]
: [F[HTTPS state]] : [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[HTTPS state][connection's HTTPS state]]
]FIG]
== [892] If [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[protocol][transport's protocol]] is
[CODE[tls]] and [VAR[connection]]'s [F[transport][connection's transport]]'s
[F[has alert]] is [[false]]:
=== [893] Process the HSTS header of [VAR[response]], if any.
=== [894] Process the PKP headers of [VAR[response]], if any.
= [842] Now ''headers are transmitted''. Return [VAR[response]].
]FIG]
: データ受信の通知 : Process [VAR[data]] as follows:
[FIG(steps)[
=
@@ Write [VAR[data]] to [VAR[response]]'s [F[body][response body]] stream
]FIG]
: データ終了の通知 :
[FIG(steps)[
=
@@ Set [VAR[response]]'s [F[body][response body]] stream's done flag
]FIG]
: 完了の通知 : Process [VAR[http response]] and [VAR[exit status]] as follows:
[FIG(steps)[
= [851] If [VAR[exit status]]'s [F[失敗]] is true:
== [852] If ''headers are transmitted'':
=== [855] Mutate [VAR[response]] into a [[network error]].
== [257] Otherwise, if [VAR[not retryable]] is [[false]] and
[VAR[exit status]]'s [F[can retry][exit's can retry]] is [[true]]:
=== [882] Let [VAR[connection]] be the result of
[[obtaining a connection][obtain a connection]], given [VAR[request]]'s
[F[current url]]'s [F[origin]] and [VAR[credentials]].
=== [883] If [VAR[connection]] is a [[failure]], return a [[network error]]
and abort these steps.
=== [884] Return the result of recursively making an HTTP request
over [VAR[connection]] using [VAR[request]],
with [VAR[credentials]] flag, with [VAR[not retryable]] flag set.
== [854] Otherwise:
=== [853] Return a [[network error]].
]FIG]
]FIG]
]FIG]
@@ TLS client certificate dialog
@@
[357] [[HTTP]] [CODE(HTTP)[[[CONNECT]]]] プロキシからの応答の受信
- [CODE(HTTP)[[[407]]]] なら、...
- その他非 [CODE(HTTP)[[[200]]]] なら、[[ネットワークエラー]]
@@
[539] [[WebSocket]] client/server steps
* Domain names
** Name resolution
[615] The [DFN[name resolution steps]] for [VAR[host]] are these steps:
[FIG(steps)[
= [616] If [VAR[host]] is a [[domain]]:
== [617] Return the result of applying [[platform]]'s [[name resolution]]
steps to [VAR[host]].
= [618] Otherwise:
== [619] Return [VAR[host]].
]FIG]
;; [620] These steps return an [[IPv4 address]], an [[IPv6 address]],
or an [[error]].
@@ caching of the result
** Verification of service identity
[943] The [DFN[service identity verification steps]] for [VAR[host]] and
[VAR[certificate]] are these steps:
[FIG(steps)[
= [947] Let [VAR[domains]] be a list of the [CODE[dNSName]] values in [VAR[certificate]]'s
[CODE[subjectAltName]] [[extension][TLS extension]], if any.
= [948] Let [VAR[addresses]] be a list of the [CODE[iPAddress]] values in [VAR[certificate]]'s
[CODE[subjectAltName]] [[extension][TLS extension]], if any.
= [949] If all of these conditions are [[true]]:
[FIG(list)[
- [964] [VAR[domains]] is empty
- [965] [VAR[addresses]] is empty
- [966] [VAR[certificate]]'s [CODE[subject]] field has any [CODE[CN]] value
]FIG]
== [967] Let [VAR[cn]] be [VAR[certificate]]'s [CODE[subject]] field has
the first [CODE[CN]] value.
= [968] Otherwise:
== [969] Let [VAR[cn]] be [[null]].
= [944] If [VAR[host]] is a [[domain]]:
== [958] For each [VAR[domain]] in [VAR[domains]]:
=== [957] If [VAR[host]] [[domain-pattern matches][domain-pattern match]] [VAR[domain]]:
==== [959] Return [[true]] and abort these steps.
== [970] If [VAR[cn]] is not [[null]] and
[VAR[host]] [[domain-pattern matches][domain-pattern match]] [VAR[cn]]:
=== [971] Return [[true]] and abort these steps.
= [945] Otherwise, if [VAR[host]] is an [[IPv4 address]]:
== [954] For each [VAR[address]] in [VAR[addresses]]:
=== [955] If [VAR[address]] represents the same [[IPv4 address]] as [VAR[host]]:
==== [956] Return [[true]] and abort these steps.
== [963] If [VAR[cn]] is the result of applying [[IPv4 serializer]] to [VAR[host]]:
=== [972] Return [[true]] and abort these steps.
= [946] Otherwise, if [VAR[host]] is an [[IPv6 address]]:
== [950] For each [VAR[address]] in [VAR[addresses]]:
=== [951] If [VAR[address]] represents the same [[IPv6 address]] as [VAR[host]]:
==== [952] Return [[true]] and abort these steps.
= [953] Return [[false]].
]FIG]
[960] Whether a [[domain]] [VAR[domain]] [DFN[domain-pattern matches][domain-pattern match]]
a string [VAR[pattern]] or not is the value returned by the following steps:
[FIG(steps)[
= [962] If the last character of [VAR[pattern]], if any, is a [CODE[.]] character:
== [973] Return [[false]] and abort these steps.
= [975] Let [VAR[canonicalized pattern]] be [VAR[pattern]], [[converted to ASCII lowercase]].
= [974] If [VAR[domain]] is [VAR[canonicalized pattern]], optionally followed by
a [CODE[.]] character:
== [976] Return [[true]] and abort these steps.
= [977] If the first two characters of [VAR[canonicalized pattern]], if any, is [CODE[*.]]:
== [979] Remove the first two characters from [VAR[canonicalized pattern]].
== [980] If [VAR[canonicalized pattern]] does not contain any [CODE[.]] character,
or [VAR[canonicalized pattern]] is one of [[ICANN DOMAINS]]:
=== [982] Return [[false]] and abort these steps.
== [983] If [VAR[domain]] is one or more characters,
followed by [VAR[canonicalized pattern]], optionally followed by a [CODE[.]] character:
=== [984] Return [[true]] and abort these steps.
= [978] Return [[false]].
]FIG]
* URLs
[1058] The [DFN[[F[hostport]]]] of a [[URL record]] [VAR[url]] is the concatenation of:
[FIG(list)[
= [1059] [F[host]]
= [902] If [VAR[url]]'s [F[port]] is not [[null]]:
== [903] [CODE[:]]
== [904] [VAR[url]]'s [F[port]], [[serialized][serialize an integer]]
]FIG]
[622] The [DFN[effective port]] of [VAR[url]] is the value returned by these steps:
[FIG(steps)[
= [623] Let [VAR[port]] be [VAR[url]]'s [F[port][URL's port]].
= [624] If [VAR[port]] is [[null]]:
== [625] Set [VAR[port]] to the value determined by the [VAR[url]]'s [F[scheme][URL scheme]]:
[FIG(switch)[
: [CODE(URI)@en[ftp]] : [[21]]
: [CODE(URI)@en[http]] : [[80]]
: [CODE(URI)@en[https]] : [[443]]
]FIG]
= [626] Return [VAR[port]].
]FIG]
[1057] The [DFN[[F[pathquery]]]] of a [[URL record]] [VAR[url]] is the concatenation of:
[FIG(list)[
= [846] [CODE[/]]
= [847] The strings in [VAR[url]]'s [F[path]], separated from each other by [CODE[/]]
= [848] If [VAR[url]]'s [F[query]] is not [[null]]:
== [849] [CODE[?]]
== [850] [VAR[url]]'s [F[query]]
]FIG]
* Proxies
** Proxy configuration data structures
[612] A [DFN[proxy configuration]] has [DFN[[F[protocol][proxy's protocol]]]], which is one of:
[CODE[tcp]],
[CODE[unix]],
[CODE[http]],
[CODE[https]],
[CODE[socks4]], and
[CODE[socks5]].
;; [1017] The value [CODE[tcp]] represents direct access (i.e. no proxy).
[613] A [[proxy configuration]] whose [F[protocol][proxy's protocol]] is
[CODE[http]], [CODE[https]], [CODE[socks4]], or [CODE[socks5]] has
[DFN[[F[host][proxy's host]]]], whose value is a [[host]], and
[DFN[[F[port][proxy's port]]]], whose value is an [[integer]] or [[null]].
The initial value of the [F[port][proxy's port]] is [[null]].
[543] A [[proxy configuration]] whose [F[protocol][proxy's protocol]] is
[CODE[http]] or [CODE[https]] has [DFN[[F[username][proxy's username]]]],
whose value is a [[string]],
and [DFN[[F[password][proxy's password]]]], whose value is a [[string]] or [[null]].
The initial value of the [F[username][proxy's username]] is the [[empty string]].
The initial value of the [F[password]] is [[null]].
[614] A [[proxy configuration]] whose [F[protocol][proxy's protocol]] is
[CODE[unix]] has [DFN[[F[path][proxy's path]]]], whose value is a [[byte string]].
[1000] A [[user agent]] has following fields:
[FIG(list members)[
: [DFN[[F[HTTP proxy]]]] : A [[proxy configuration]] or [[null]].
: [DFN[[F[HTTPS proxy]]]] : A [[proxy configuration]] or [[null]].
: [DFN[[F[FTP proxy]]]] : A [[proxy configuration]] or [[null]].
: [DFN[[F[SOCKS proxy]]]] : A [[proxy configuration]] or [[null]].
: [DFN[[F[[[PAC]] [[URL]]]] : A [[URL record]] or [[null]].
: [DFN[[F[use [[WPAD]] flag]]]] : A [[boolean]].
: [DFN[[F[no proxy hosts]]]] : A list of [[host]]s.
]FIG]
[1043] A [[user agent]] [MAY[MAY]] allow the [[user]] to configure
values of these fields in implementation-dependent ways.
** Proxy configuration environment variables
[836] If a [[user agent]] supports [[environment variable]]s,
it [MUST[MUST]] run these steps upon initialization:
[FIG(steps)[
= [1021] Set the [[user agent]]'s [F[HTTP proxy]] to the result of
[[parsing environment variable][parse an environment variable]] [CODE[http_proxy]].
= [1022] Set the [[user agent]]'s [F[HTTPS proxy]] to the result of
[[parsing environment variable][parse an environment variable]] [CODE[https_proxy]].
= [1023] Set the [[user agent]]'s [F[FTP proxy]] to the result of
[[parsing environment variable][parse an environment variable]] [CODE[ftp_proxy]].
= [1037] Let [VAR[no_proxy]] be the result of
[[getting the environment variable][get an environment variable]] [CODE[no_proxy]].
= [1038] If [VAR[no_proxy value]] is not [[null]] and is not the [[empty string]]:
== [1039] For each substring [VAR[value]] obtained by splitting [VAR[no_proxy value]]
by a [CODE[,]] character:
=== [1040] Remove any leading and trailing [[C0 controls and space]] characters
from [VAR[value]].
=== [1041] Let [VAR[host]] be the result of applying the [[host parser]] to [VAR[value]].
=== [1042] If [VAR[host]] is not an error,
append [VAR[host]] to the [[user agent]]'s [F[no proxy hosts]].
]FIG]
[1024] To [DFN[parse an environment variable]] whose name is [VAR[name]],
run these steps:
[FIG(steps)[
= [1025] Let [VAR[value]] be the result of
[[getting the environment variable][get an environment variable]] [VAR[name]].
= [1026] If [VAR[value]] is [[null]] or the [[empty string]]:
== [1027] Return [[null]] and abort these steps.
= [1055] Let [VAR[url]] be the result of applying the [[proxy environment variable parser]]
to [VAR[value]].
= [1030] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE[http][http:]]
or [CODE[https][https:]]:
== [1031] Return a [[proxy configuration]].
[FIG(list members)[
[FIGCAPTION[
[[Proxy configuration][proxy configuration]]
]FIGCAPTION]
: [F[protocol][proxy's protocol]] : [VAR[url]]'s [F[scheme][URL scheme]]
: [F[host][proxy's host]] : [VAR[url]]'s [F[host][URL's host]]
: [F[port][proxy's port]] : [VAR[url]]'s [F[port][URL's port]]
: [F[username][proxy's username]] : [VAR[url]]'s [F[username][URL's username]]
: [F[password][proxy's password]] : [VAR[url]]'s [F[password][URL's password]]
]FIG]
= [1032] Otherwise, if [VAR[url]]'s [F[scheme][URL scheme]] is [CODE[socks4][socks4:]]
or [CODE[socks5][socks5:]] and [CODE[url]]'s [F[host][URL's host]] is not [[null]]:
== [1033] Return a [[proxy configuration]].
[FIG(list members)[
[FIGCAPTION[
[[Proxy configuration][proxy configuration]]
]FIGCAPTION]
: [F[protocol][proxy's protocol]] : [VAR[url]]'s [F[scheme][URL scheme]]
: [F[host][proxy's host]] : [VAR[url]]'s [F[host][URL's host]]
: [F[port][proxy's port]] : [VAR[url]]'s [F[port][URL's port]]
]FIG]
= [1034] Otherwise:
== [1035] The [[user agent]] [MAY[MAY]] report an error and [MAY[MAY]]
terminate the [[user agent]].
== [1036] Return [[null]].
]FIG]
[1045] To [DFN[get an environment variable]] with string [VAR[name]], run these steps:
[FIG(steps)[
= [1046] If the [[user agent]]'s [[process]] has an [[environment variable]]
whose name is [VAR[name]]:
== [1047] Let [VAR[value]] be the value of the [[user agent]]'s [[process]]'s
[[environment variable]] whose name is [VAR[name]].
== [1049] Let [VAR[encoding]] be the [[encoding]] of the [[platform]].
== [1048] Return the result of [[decoding][decode]] [VAR[value]] in [VAR[encoding]].
= [1050] Otherwise:
== [1051] Return [[null]].
]FIG]
[1056] When the [DFN[proxy environment variable parser]] is applied to
a string [VAR[value]], the implementation [MUST[MUST]] run these steps:
[FIG(steps)[
= [1028] If [VAR[value]] does not begin with a [[scheme][URL scheme (syntax)]]
followed by [CODE[://]],
prepend [CODE[http://]] to [VAR[value]].
= [1029] Return the result of applying the [[URL parser]] to [VAR[value]].
]FIG]
** Fetching PAC scripts
[1004] A [[user agent]] has a [F[[[PAC]] script]], which is initially [[null]].
[1001] If [F[use [[WPAD]] flag]] is [[true]], the [[user agent]] [MUST[MUST]]
send appropriate [[WPAD]] request.
[1003] If a [[PAC]] [[URL]] is provided by [[WPAD]] processing,
the [[user agent]] [MUST[MUST]] [[fetch]] the [[PAC]] file.
Otherwise, if [F[[[PAC]] [[URL]]]] is not [[null]],
the [[user agent]] [MUST[MUST]] [[fetch]] the [F[[[PAC]] [[URL]]]].
When a [[PAC]] script file is [[fetch]]ed, the [[user agent]]'s
[F[[[PAC]] script]] [MUST[MUST]] be set to the file.
** Choosing proxy configurations
[1010] To [DFN[get proxies]] for [[URL record]] [VAR[url]], run these steps:
[FIG(steps)[
= [1018] For each [[host]] [VAR[host]] in the [[user agent]]'s [F[no proxy hosts]]:
== [1019] If [VAR[host]] [[equals][host equivalence]] [VAR[url]]'s [F[host]]:
=== [1020] Return a list whose only member is a [[proxy configuration]]
whose [F[protocol][proxy's protocol]] is [CODE[tcp]] and abort these steps.
= [544] If the [[user agent]]'s [F[[[PAC]] script]] is not [[null]]:
== [545] Process the [[user agent]]'s [F[[[PAC]] script]] with [VAR[url]].
== [1011] Return the result of the previous step and abort these steps.
= [609] If the [[user agent]]'s [F[SOCKS proxy]] is not [[null]]:
== [610] Return a list whose only member is the [[user agent]]'s [F[SOCKS proxy]]
and abort these steps.
= [611] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE[http][http:]] and
the [[user agent]]'s [F[HTTP proxy]] is not [[null]]:
== [1012] Return a list whose only member is the [[user agent]]'s [F[HTTP proxy]]
and abort these steps.
= [1013] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE[https][https:]] and
the [[user agent]]'s [F[HTTPS proxy]] is not [[null]]:
== [1014] Return a list whose only member is the [[user agent]]'s [F[HTTPS proxy]]
and abort these steps.
= [1015] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE[ftp][ftp:]] and
the [[user agent]]'s [F[FTP proxy]] is not [[null]]:
== [1016] Return a list whose only member is the [[user agent]]'s [F[FTP proxy]]
and abort these steps.
= [546] Return a list whose only member is a [[proxy configuration]]
whose [F[protocol][proxy's protocol]] is [CODE[tcp]].
]FIG]
;; [1052] [VAR[url]]'s [F[scheme][URL scheme]] has to be a [[network scheme]].
* Transports
[640] A [DFN[transport]] has following states:
[FIG(list members)[
[FIGCAPTION[
[[Transport][transport]]
]FIGCAPTION]
: [DFN[[F[protocol]]][transport's protocol]] :
One of
[CODE[tcp]],
[CODE[unix]],
[CODE[http1connect]],
[CODE[http2connect]],
[CODE[tls]],
[CODE[socks4]], and
[CODE[socks5]].
: [DFN[[F[endpoint type][transport's endpoint type]]]] :
Either [CODE[client]] or [CODE[server]].
: [DFN[[F[remote address or domain][transport's remote address or domain]]]] :
A [[domain]] or [[null]]. Unless stated otherwise, the value is [[null]].
: [DFN[[F[remote port][transport's remote port]]]] :
An [[integer]] or [[null]].
: [DFN[[F[proxy configuration][transport's proxy configuration]]]] : A [[proxy configuration]].
: [DFN[[F[http protocol][transport's http protocol]]]] :
Either [CODE[http1]] or [CODE[http2]].
Unless stated otherwise, the value is [CODE[http1]].
:[VAR[送信閉じ済みフラグ]]:初期状態では未設定。
:[VAR[受信閉じ済みフラグ]]:初期状態では未設定。
:[VAR[送信待ちバッファー]]:初期状態では空のリスト。
: [DFN[[F[request mode]]]] :
The value is either ''default'' or ''HTTP proxy''.
If the [F[request mode]] of a [[transport]] is ''HTTP proxy'',
a [[request]] has to be sent over the [[transport]] as an [[HTTP request]]
whose [[request target]] is an [[absolute URL]].
: [DFN[[F[HTTPS state]]][transport's HTTPS state]] :
An [[HTTPS state]] value. Either [CODE[none]], [CODE[deprecated]], or [CODE[modern]].
Unless stated otherwise, the value is [CODE[none]].
]FIG]
[1054] To [DFN[create a transport for a proxy configuration]] [VAR[proxy]]
with a [[URL record]] [VAR[url]] and optional [VAR[ws]] flag, run rhese steps:
[FIG(steps)[
= [549] If [VAR[user agent]] does not support [VAR[proxy]]'s [F[protocol]]:
== [550] Return a [[failure]] and abort these steps.
= [551] Switch by [VAR[proxy]]'s [F[protocol]]:
[FIG(switch)[
: [CODE[tcp]] :
[FIG(steps)[
= [552] Set [VAR[effective port]] be the [[effective port]] of [VAR[url]].
= [553] Set [VAR[addr]] to the result of applying [[name resolution steps]]
to [VAR[url]]'s [F[host][URL's host]].
= [554] If [VAR[addr]] is an [[error]]:
== [555] Return a [[failure]] and abort these steps.
= [557] If [VAR[ws]] flag is set, [[wait for other connections]]
with [VAR[addr]] and [VAR[port]].
= [558] Return the result of
[[establishing a TCP transport][establish a TCP transport]]
to [VAR[addr]] and [VAR[effective port]].
]FIG]
: [CODE[unix]] :
[FIG(steps)[
= [559] Return the result of
[[establishing a UNIX socket domain transport][establish a UNIX socket domain transport]]
with [VAR[proxy]]'s [F[path][proxy's path]], [VAR[url]]'s [F[host][URL's host]],
and [VAR[url]]'s [[effective port]].
]FIG]
: [CODE[http]] or [CODE[https]] :
[FIG(steps)[
= [560] If [VAR[ws]] flag is set, [[wait for other connections]]
with [VAR[url]]'s [F[host]] and [VAR[port]].
= [561] Let [VAR[proxy port]] be [VAR[proxy]]'s [F[port]].
= [562] If [VAR[proxy port]] is [[null]]:
== [563] If [VAR[proxy]]'s [F[protocol]] is [CODE[http]], set [VAR[proxy port]] to [N[80]].
== [564] If [VAR[proxy]]'s [F[protocol]] is [CODE[https]], set [VAR[proxy port]] to [N[443]].
= [565] Let [VAR[proxy addr]] be the result of applying [[name resolution steps]]
to [VAR[proxy]]'s [F[host]].
= [566] If [VAR[proxy addr]] is an [[error]]:
== [567] Return a [[failure]] and abort these steps.
= [568] Let [VAR[transport]] be the result of
[[establishing a TCP transport][establish a TCP transport]]
to [VAR[proxy addr]] and [VAR[proxy port]].
= [570] If [VAR[proxy]]'s [F[protocol]] is [CODE[https]]:
== [571] Set [VAR[transport]] to the result of running the [[TLS steps]] for
[VAR[transport]] and [VAR[proxy]]'s [F[host]].
= [556] If [VAR[transport]] is a [[failure]]:
== [569] Return a [[failure]] and abort these steps.
= [572] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE(URI)@en[https]]:
== [577] Let [VAR[http]] be an [[HTTP connection]]:
[FIG(list members)[
[FIGCAPTION[
[[HTTP connection]]
]FIGCAPTION]
: [F[endpoint type][connection's endpoint type]] : [CODE[client]]
: [F[transport][connection's transport]] : [VAR[transport]]
]FIG]
== [578] Set [VAR[transport]] to the result of
[[establishing an HTTP [CODE(HTTP)[CONNECT]] transport][establish an HTTP [CODE(HTTP)@en[CONNECT]] transport]]
with [VAR[http]] and [VAR[url]].
@@ [VAR[credentials]] flag and proxy credentials
== [579] If [VAR[transport]] is a [[failure]] whose HTTP response's [F[status]] is
[CODE[407]]:
===
@@ Show proxy auth dialog
= [580] Otherwise:
== [581] Set [VAR[transport]]'s [F[request mode]] to ''HTTP proxy''.
== [576] Set [VAR[transport]]'s
[F[remote address or domain][transport's remote address or domain]] to [VAR[url]]'s
[F[host][URL's host]].
== [909] Set [VAR[transport]]'s [F[remote port][transport's remote port]] to
[VAR[url]]'s [[effective port]].
= [548] Return [VAR[transport]].
]FIG]
: [CODE[socks4]] :
[FIG(steps)[
= [582] Let [VAR[effective port]] be the [[effective port]] of [VAR[url]].
= [583] Set [VAR[addr]] to the result of applying [[name resolution steps]]
to [VAR[url]]'s [F[host]].
= [584] If [VAR[addr]] is ''not'' an [[IPv4 address]]:
== [585] Return a [[failure]] and abort these steps.
= [587] If [VAR[ws]] flag is set, [[wait for other connections]]
with [VAR[addr]] and [VAR[port]].
= [588] Let [VAR[proxy port]] be [VAR[proxy]]'s [F[port]].
= [589] If [VAR[proxy port]] is [[null]], set [VAR[proxy port]] to [N[1080]].
= [590] Let [VAR[proxy addr]] be the result of applying [[name resolution steps]]
to [VAR[proxy]]'s [F[host]].
= [591] Let [VAR[transport]] be the result of
[[establishing a TCP connection][establish a TCP connection]]
to [VAR[proxy addr]] and [VAR[proxy port]].
= [592] Return the result of
[[establishing a SOCKS4 connection][establish a SOCKS4 connection]]
with [VAR[transport]], [VAR[addr]], and [VAR[effective port]].
]FIG]
: [CODE[socks5]] :
[FIG(steps)[
= [593] Let [VAR[effective port]] be the [[effective port]] of [VAR[url]].
= [594] If [VAR[ws]] flag is set, [[wait for other connections]]
with [VAR[url]]'s [F[host]] and [VAR[port]].
= [595] Let [VAR[proxy port]] be [VAR[proxy]]'s [F[port]].
= [597] If [VAR[proxy port]] is [[null]], set [VAR[proxy port]] to [N[1080]].
= [596] Let [VAR[proxy addr]] be the result of applying [[name resolution steps]]
to [VAR[proxy]]'s [F[host]].
= [598] Let [VAR[transport]] be the result of
[[establishing a TCP transport][establish a TCP transport]]
to [VAR[proxy addr]] and [VAR[proxy port]].
= [599] Return the result of
[[establishing a SOCKS5 transport][establish a SOCKS5 transport]]
with [VAR[transport]], [VAR[url]]'s [F[host]], and [VAR[effective port]].
]FIG]
]FIG]
]FIG]
[542] To [DFN[establish a transport]] for an [[URL record]] [VAR[url]]
and a [[user agent]] [VAR[user agent]], optionally with [VAR[credentials]]
and [VAR[ws]] flags, run these steps:
[FIG(steps)[
= [1009] Let [VAR[proxies]] be the result of [[getting proxies][get proxies]] for [VAR[url]].
= [908] Let [VAR[addr]] be [[null]].
= [914] Let [VAR[port]] be [VAR[url]]'s [F[port]].
= [547] For each [VAR[proxy]] in [VAR[proxies]], in order, run these substeps:
== [1053] Set [VAR[transport]] to the result of
[[creating a transport for proxy][create a transport for a proxy configuration]]
[VAR[proxy]] with [VAR[url]] and [VAR[ws]].
== [600] If [VAR[transport]] is not a [[failure]]:
=== [601] If [VAR[url]]'s [F[scheme][URL scheme]] is [CODE(URI)@en[https][https:]]:
==== [602] Set [VAR[transport]] to the result of running the [[TLS steps]] for
[VAR[transport]], [VAR[url]]'s [F[host]], [VAR[credentials]] flag, and [VAR[ws]] flag,
in [VAR[user agent]].
== [927] If [VAR[transport]] is not a [[failure]]:
=== [1182] Set [VAR[transport]]'s [F[proxy configuration][transport's proxy configuration]]
to [VAR[proxy]].
=== [934] If [VAR[transport]]'s [F[request mode]] is '''not''' ''HTTP proxy'' and
[VAR[url]]'s [F[scheme][URL scheme]] is [CODE(URI)@en[ftp][ftp:]]:
==== [935]
@@ Use [[FTP]]
=== [931] Otherwise, if none of these conditions is [[true]]:
[FIG(list)[
- [930] [VAR[transport]]'s [F[request mode]] is ''HTTP proxy''
- [932] [VAR[url]]'s [F[scheme][URL scheme]] is [CODE(URI)@en[http][http:]]
- [933] [VAR[url]]'s [F[scheme][URL scheme]] is [CODE(URI)@en[https][https:]]
]FIG]
==== [929] Set [VAR[transport]] to a [[failure]].
== [603] If [VAR[transport]] is not a [[failure]]:
=== [605] Return [VAR[transport]] and abort these steps.
= [606] Return a [[failure]].
]FIG]
;; [936] [VAR[url]]'s [F[scheme][URL scheme]] has to be a [[network scheme]].
[642] [[アプリケーション]]は、 [[transport]] に次の指示を行えます。
[FIG(list)[
- [[バイト]]の送信の指示
- 正常終了の送信の指示
- 中断の指示
- credentials の送信の指示
]FIG]
[643] [[バイト]]の送信の指示は、送信する[[バイト]] (0-255 のいずれかの値)と、
[[緊急データ]]か否かのフラグ (既定値は未設定。)
を[[引数]]とし、次のように処理します。
[FIG(steps)[
= [644] [VAR[送信閉じ済みフラグ]]が設定されていれば、[[例外]]を投げて停止します。
= [645] [VAR[送信待ちバッファー]]が満杯なら、[[例外]]を投げて停止します。
= [646] [[緊急データ]]フラグが設定されていて、
[[transport]] の種類が[[緊急データ]]に対応していないものなら、
[[例外]]を投げて停止します。
= [647] [VAR[送信待ちバッファー]]の末尾に、
引数の[[バイト]]、
引数の[[緊急データ]]か否かのフラグ、
[[約束]]の組を追加します。
= [648] 追加した[[約束]]を返します。
]FIG]
;; [649] 返された[[約束]]は、[[バイト]]が送信された際に[[解決]]されます。
[650] [[バイト列]]を送信するとは、当該[[バイト列]]について先頭の[[バイト]]から順に[[バイト]]の送信の指示を行い、最後の[[バイト]]が返した[[約束]]を返す
(空バイト列なら[[解決]]済みの[[約束]]を返す) ことをいいます。
[651] 正常終了の送信の指示は、次のように処理します。
[FIG(steps)[
= [652] [VAR[送信閉じ済みフラグ]]が設定されていれば、[[例外]]を投げて停止します。
= [653] [VAR[送信閉じ済みフラグ]]を設定します。
= [654] [[transport]]の種類に応じた処理を行います。
]FIG]
[655] 中断の指示は、次のように処理します。
[FIG(steps)[
= [656] [VAR[送信閉じ済みフラグ]]と[VAR[受信閉じ済みフラグ]]の両方が設定されていれば、
[[例外]]を投げて停止します。
= [657] [VAR[送信閉じ済みフラグ]]を設定します。
= [658] [VAR[受信閉じ済みフラグ]]を設定します。
= [659] [VAR[送信待ちバッファー]]の先頭の項目から順に、
[[約束]]を[[拒絶]]していきます。
= [660] [[transport]]の種類に応じた処理を行います。
= [661] 中断の通知を行います。リセットフラグを設定します。
]FIG]
[662] [[credentials]] の送信の指示は、
[[transport]]の種類に応じた処理を実行します。そのようなものがなければ、
[[例外]]を投げます。
なお引数として、[[transport]]の種類に応じた [[credentials]] を受け取ります。
[663] [[transport]]は、[[アプリケーション]]に対して次の通知を行います。
[FIG(list)[
- [664] [[バイト]]の受信の通知
[FIG(list members)[
:[[バイト]]:受信した[[バイト]]。 0-255 のいずれかの値。
:[[緊急データ]]フラグ: [[TCP]] [[緊急データ]]か否か。既定値は[[偽]]。
]FIG]
- [665] 正常終了の受信の通知
- [666] 中断の通知
[FIG(list members)[
:[[リセット]]フラグ:[[TCP]] [CODE[[[RST]]]] 相当のものであるか否か。既定値は[[偽]]。
]FIG]
- [667] 警告の通知
- [668] challenge の受信の通知
[FIG(list members)[
: [VAR[transport]] :認証を行う [[transport]]。
:[[challenge]]:プロトコル依存の [[challenge]] データ。
]FIG]
]FIG]
[669] [[transport]]の種類に依存した方法で次の[[バイト]]を送信可能であると判断したら、
次のようにします。
[FIG(steps)[
= [670] [VAR[送信待ちバッファー]]が空なら、ここで停止します。
= [671] [VAR[送信待ちバッファー]]の先頭の項目を取得し、バッファーからは削除します。
= [672] [[transport]]の種類に依存した方法で取得した項目の[[バイト]]を送信します。
(あれば) [[緊急データ]]フラグを引渡します。
= [673] 取得した項目の[[約束]]を[[解決]]します。
]FIG]
** TCP
[627] To [DFN[establish a TCP transport]] to [VAR[addr]] and [VAR[port]],
run these steps:
[FIG(steps)[
= [628] Connect to address [VAR[addr]] and port [VAR[port]] using [[TCP]].
= [641] If a [[TCP connection]] has been established:
== [674] Let [VAR[transport]] be a [[transport]] representing the
[[TCP connection]], with following states:
[FIG(list members)[
[FIGCAPTION[
[[Transport][transport]]
]FIGCAPTION]
: [F[protocol][transport's protocol]] : [CODE[tcp]]
: [F[endpoint type][transport's endpoint type]] : [CODE[client]]
: [F[remote address or domain][transport's remote address or domain]] : [VAR[addr]]
: [F[remote port][transport's remote port]] : [VAR[port]]
]FIG]
== [630] Disable the [CODE[SO_OOBINLINE]] option of [VAR[transport]]'s connection.
== [631] Enable the [CODE[SO_NODELAY]] option of [VAR[transport]]'s connection.
== [632] Run the [[TCP keep alive steps]] for [VAR[transport]].
== [818] Return [VAR[transport]].
= [629] Otherwise:
== [819] Return a [[failure]].
]FIG]
[634] The [DFN[TCP keep alive steps]] for [VAR[transport]] are implementation
dependent. An example of such steps is:
[FIG(steps)[
= [635] Enable the [CODE[SO_KEEPALIVE]] option of [VAR[transport]].
= [636] Set [CODE[TCP_KEEPIDLE]] option of [VAR[transport]]'s connection to 45 (seconds).
= [637] Set [CODE[TCP_KEEPINTVL]] option of [VAR[transport]]'s connection to 45 (seconds).
]FIG]
@@ [675] XXX server accept steps
[676] [[TCP]] の[[セグメント]]を受信したら、次のようにします。
[FIG(steps)[
= [677] [[TCP]] に従い処理し、不適切と判断すればここで停止します。
= [678] [CODE[[[RST]]]] フラグが設定されていれば、
== [679] [VAR[送信閉じ済みフラグ]]を設定します。
== [680] [VAR[受信閉じ済みフラグ]]を設定します。
== [681] 中断を通知します。リセットフラグを設定します。
= [682] データの各[[バイト]]について、順に、
== [683] [[バイト]]の受信を通知します。当該[[バイト]]の値を渡します。
[[緊急ポインター]]が本[[バイト]]を指していれば、[[緊急データ]]フラグも設定します。
= [684] [CODE[[[FIN]]]] フラグが設定されていれば、
== [685] [VAR[受信閉じ済みフラグ]]を設定します。
== [686] 正常終了の受信を通知します。
]FIG]
[687] [[タイムアウト]]その他の理由で[[transport]]が利用できないことを検知したら、
次のようにします。
[FIG(steps)[
= [688] [VAR[送信閉じ済みフラグ]]を設定します。
= [689] [VAR[受信閉じ済みフラグ]]を設定します。
= [690] 中断を通知します。
]FIG]
[691] [[バイト]]を送信できるかどうかは、[[フロー制御]]、[[輻輳制御]]その他の状況により決定します。
[692] [[バイト]]の送信は、次のようにします。
[FIG(steps)[
= [693] [[緊急データ]]フラグが設定されていれば、
== [694] 指定された[[バイト]]をデータとして含み、[[緊急ポインター]]が当該[[バイト]]を指す[[セグメント]]を送信することにします。
= [695] それ以外なら、
== [696] 指定された[[バイト]]をデータとして含む[[セグメント]]を送信することにします。
]FIG]
;; [697] 実際の送信時には、前後の[[バイト]]とまとめた[[セグメント]]で送信されたり、
必要に応じて[[再送]]されたりします。
[698] [[緊急データ]]に対応しています。
[699] 正常終了の送信の指示があれば、次のようにします。
[FIG(steps)[
= [700] [CODE[[[FIN]]]] フラグが設定された[[セグメント]]を送信することにします。
]FIG]
[701] 中断の指示があれば、次のようにします。
[FIG(steps)[
= [702] 必要に応じて [CODE[[[FIN]]]] フラグが設定された[[セグメント]]を送信することにします。
= [703] [[TCP]] で受信したデータの処理を以後行わないことにします。
]FIG]
** HTTP [CODE(HTTP)@en[CONNECT]]
[633] A [[transport]] whose [F[protocol][transport's protocol]] is
[CODE[http1connect]] or [CODE[http2connect]] has following additional states:
[FIG(list members)[
: [DFN[[F[http][transport's http]]]] : An [[HTTP connection]].
: [DFN[[F[established][transport's established]]]] : A [[boolean]]. Initially, [[false]].
]FIG]
[739] To [DFN[establish an HTTP [CODE(HTTP)@en[CONNECT]] transport]]
with [[HTTP connection]] [VAR[http]] and [[URL record]] [VAR[url]], run these steps:
[FIG(steps)[
= [740] Let [VAR[transport]] be a [[transport]]:
[FIG(list members)[
[FIGCAPTION[
[[Transport][transport]]
]FIGCAPTION]
: [F[protocol][transport's protocol]] :
If [VAR[http]]'s [F[protocol][connection's protocol]] is [CODE[http2]], [CODE[http2connect]].
Otherwise, [CODE[http1connect]].
: [F[endpoint type][transport's endpoint type]] : [CODE[client]]
: [F[remote address or domain][transport's remote address or domain]] :
[VAR[url]]'s [F[host][url's host]]
: [F[remote port][transport's remote port]] : [VAR[url]]'s [[effective port]]
: [F[http][transport's http]] : [VAR[http]]
]FIG]
= [766] Send an [[HTTP request]] over [VAR[http]]:
[FIG(list members)[
: [F[method][request method]] : [CODE[CONNECT]]
: [F[request target]] : [VAR[url]]'s [F[hostport]]
: [F[header list]] :
[FIG(list members)[
: [CODE[Host]] : [VAR[url]]'s [F[hostport]]
: [CODE[Proxy-Connection]] : [CODE[keep-alive]]
: [CODE[User-Agent]] : [[default `[CODE[User-Agent]]` value]]
]FIG]
]FIG]
= [741] If failed, return a [[failure]] and abort these steps.
= [817] Process notifications from [VAR[http]] as follows:
[FIG(switch)[
: [744] [[要求]]のヘッダー受信完了の通知 :
[FIG(steps)[
= [745] 応答の状態符号が [CODE(HTTP)[[[200]]]] なら、
== [746] Set [VAR[transport]]'s [F[established][transport's established]] to [[true]].
== [747] Return [VAR[transport]].
= [748] Otherwise:
== [749] Return a [[failure]].
]FIG]
: [750] [[要求]]のデータ受信の通知 :
[FIG(steps)[
= [751] If [VAR[transport]]'s [F[established][transport's established]] is [[true]]:
-= [752] データの各バイトについて、順に、
-== [753] バイトの受信を通知します。当該バイトの値を渡します。
]FIG]
: [754] [[要求]]のデータ終了の通知 :
[FIG(steps)[
= [755] If [VAR[transport]]'s [F[established][transport's established]] is [[true]]:
-= [756] [VAR[受信閉じ済みフラグ]]を設定します。
-= [757] 正常終了の受信を通知します。
]FIG]
: [758] [[要求]]の完了の通知 :
[FIG(steps)[
= [759] If [VAR[connection]]'s [F[exit status][connection's exit status]]'s [F[失敗]] is [[true]]:
== [760] If [VAR[transport]]'s [F[established][transport's established]] is [[true]]:
=== [761] [VAR[送信閉じ済みフラグ]]を設定します。
=== [762] [VAR[受信閉じ済みフラグ]]を設定します。
=== [763] 中断を通知します。
== [764] Otherwise:
=== [765] Return a [[failure]].
]FIG]
]FIG]
]FIG]
@@ [738] XXX server accept steps
[767] バイトは常に送信可能とします。
[768] バイトの送信は、次のようにします。
[FIG(steps)[
= [769] [VAR[transport]]'s [F[http][transport's http]] でトンネルに指定されたバイトを送信します。
]FIG]
[770] 正常終了の送信の指示があれば、次のようにします。
[FIG(steps)[
= [771] [VAR[transport]]'s [F[http][transport's http]] に接続の正常終了を指示します。
]FIG]
[772] 中断の指示があれば、次のようにします。
[FIG(steps)[
= [773] [VAR[transport]]'s [F[http][transport's http]] に中断を指示します。
]FIG]
*** HTTP/2
@@
** SOCKS4
[743] A [[transport]] whose [F[protocol][transport's protocol]] is
[CODE[socks4]] has following additional states:
[FIG(list members)[
: [DFN[[F[transport][socks4 transport's transport]]]] : A [[transport]].
]FIG]
[774] To [DFN[establish a SOCKS4 transport]]
to [[IPv4 address]] [VAR[address]] and [[port]] [VAR[port]] over
[[transport]] [VAR[transport]], run these steps:
[FIG(steps)[
= [776] [VAR[transport]]で 0x04 0x01 [VAR[p[SUB[1]]]] [VAR[p[SUB[2]]]] [VAR[a[SUB[1]]]] [VAR[a[SUB[2]]]]
[VAR[a[SUB[3]]]] [VAR[a[SUB[4]]]] 0x00 を送信します。
=- [VAR[p[SUB[1]]]] [VAR[p[SUB[2]]]] は[VAR[port]]を[[16ビット符号無し整数]]
([[ネットワークバイト順]]) としたものです。
=- [VAR[a[SUB[1]]]] [VAR[a[SUB[2]]]] [VAR[a[SUB[3]]]] [VAR[a[SUB[4]]]]
は[VAR[address]]を[[32ビット符号無し整数]] ([[ネットワークバイト順]]) としたものです。
= [777] [VAR[transport]]から8バイト受信するのを最大30s待ちます。
= [778] 受信した最初の2バイトが 0x00 0x5A でなければ、
== [779] [VAR[transport]]の中断を指示します。
== [780] Return a [[failure]] and abort these steps.
= [781] Return a [[transport]]:
[FIG(list members)[
[FIGCAPTION[
[[Transport][transport]]
]FIGCAPTION]
: [F[protocol][transport's protocol]] : [CODE[socks4]]
: [F[endpoint type][transport's endpoint type]] : [CODE[client]]
: [F[remote address or domain][transport's remote address or domain]] : [VAR[address]]
: [F[remote port][transport's remote port]] : [VAR[port]]
: [F[transport][socks4 transport's transport]] : [VAR[transport]]
]FIG]
]FIG]
@@ [742] XXX server
[783] 接続確立後は、指示は[VAR[transport]]への指示とし、
[VAR[transport]]からの通知があればそれを通知します。
** SOCKS5
[775] A [[transport]] whose [F[protocol][transport's protocol]] is
[CODE[socks5]] has following additional states:
[FIG(list members)[
: [DFN[[F[transport][socks5 transport's transport]]]] : A [[transport]].
]FIG]
[784] To [DFN[establish a SOCKS5 transport]]
to destination [VAR[host]] and [[port]] [VAR[port]] over [[transport]] [VAR[transport]],
run these steps:
[FIG(steps)[
= [785] If [VAR[host]] is a [[domain]] whose length is greater than [N[255]]:
== [803] Return a [[failure]] and abort these steps.
= [786] [VAR[transport]]で 0x05 0x01 0x00 を送信します。
= [787] [VAR[transport]]から2バイト受信するのを最大30s待ちます。
= [788] 受信したのが 0x05 0x00 でなければ、
== [789] [VAR[transport]]の中断を指示します。
== [790] Return a [[failure]] and abort these steps.
= [791] [VAR[transport]]で 0x05 0x01 0x00 [VAR[A]] [VAR[p[SUB[1]]]] [VAR[p[SUB[2]]]]
を送信します。
=- [VAR[A]] は、
=-= [VAR[host]]が[[ドメイン名]]の場合、[VAR[host]]を [[UTF-8]] に変換したものの前に
[VAR[host]] を [[UTF-8]] に変換したもののバイト数を[[8ビット符号無し整数]]としたものを置いたものです。
=-= [VAR[host]]が[[IPv4アドレス]]の場合、[VAR[host]]を[[32ビット符号無し整数]] ([[ネットワークバイト順]]) としたものです。
=-= [VAR[host]]が[[IPv6アドレス]]の場合、[VAR[host]]を16バイトのバイト列としたものです。
=- [VAR[p[SUB[1]]]] [VAR[p[SUB[2]]]] は[VAR[port]]を[[16ビット符号無し整数]]
([[ネットワークバイト順]]) としたものです。
= [792] [VAR[transport]]から5バイト受信するのを最大30s待ちます。
= [793] 受信した最初の3バイトが 0x05 0x00 0x00 でないか、
第4バイトが 0x01, 0x03, 0x04 のいずれでもないか、
5バイトに満たなければ、
== [794] [VAR[transport]]の中断を指示します。
== [795] Return a [[failure]] and abort these steps.
= [796] 第4バイトが 0x01 なら、[VAR[transport]]から5バイト受信するのを最大30s待ちます。
= [797] 第4バイトが 0x03 なら、第5バイトを[[8ビット符号無し整数]]として解釈し、
[VAR[transport]]からそのバイト数 + 2 バイト分受信するのを最大30s待ちます。
= [798] 第4バイトが 0x04 なら、[VAR[transport]]から17バイト受信するのを最大30s待ちます。
= [799] 得られたのが指定のバイト数に満たなければ、
== [800] [VAR[transport]]の中断を指示します。
== [801] Return a [[failure]] and abort these steps.
= [802] Return a [[transport]]:
[FIG(list members)[
[FIGCAPTION[
[[Transport][transport]]
]FIGCAPTION]
: [F[protocol][transport's protocol]] : [CODE[socks5]]