This section is non-normative.
[907] This document is an implementation of Web transport protocols.
Fetch and connections [908] The request 's current server url
is a URL record . Once a value is set, the current server url
is that value. Otherwise, the current server url
is same as its current url .
[1303] In the basic fetch , when request 's current url 's
scheme is ftp
,
return the result of performing an HTTP fetch using request .
[896] To modify request 's header list per HTTP
in HTTP-network-or-cache fetch , run these steps:[898] Append Accept-Encoding
header, if necessary.[897] Append DNT
header, if necessary.[899] Append Upgrade-Insecure-Requests
header, if necessary.
[1304] In the steps to obtain a connection , to choose a connection
for origin origin from the user agent 's connection pool , run these steps:[1305] If origin 's scheme is ftp
:[1306] Return null .[1307] Otherwise:[1308] Return a connection whose
to be closed is false ,
状態 is 「初期」 or 「要求待ち」, and
WebSocket接続の状態 is null in the user agent 's connection pool ,
if any, or null .
[1325] In the steps to obtain a connection , just before establishing an HTTP connection,
run these steps:[1326] Wait until implementation dependent constraints on the number of relevant
connections in the user agent 's connection pool is small enough.
If the user agent detects an idle connection in its connection pool ,
it may choose to abort that connection.
[822] In the steps to obtain a connection , to establish an HTTP connection,
run these steps:[808] Let transport be the result of
establishing a transport .request url the request's current url server url the request's current server url credentials true acceptSslCerts
the request's acceptSslCerts
flag user agent the user agent skip DNS cache whether the request's cache mode
is either one of no-cache
, reload
, and no-store
, or not [823] If transport is a failure :[824] Return a failure .[1296] Otherwise, if transport 's http protocol
is http2
:
[932] Otherwise, if transport 's http protocol
is ftp
:[934] If the HTTP-network-or-cache fetch steps set credentials to the request:[935] Set username and password to the appropriate values.[1285] Otherwise:[1286] Set username to anonymous
.[1287] Set password to User@
.[933] Let connection be the result of
initiating an FTP connection
with transport , username , and password .[1291] Wait until connection 's established promise
is resolved or rejected.[1292] If connection 's established promise
is resolved:[1293] Return ftp .[1294] Otherwise:[1295] Return a failure .[825] Otherwise:[826] Return an HTTP connection :HTTP connection endpoint type client
transport transport
[809] To obtain a WebSocket connection for url , run these steps:[821] Let transport be the result of
establishing a transport .request url url server url url acceptSslCerts
the request's acceptSslCerts
flag user agent the user agent ws true skip DNS cache whether the request's cache mode
is either one of no-cache
, reload
, and no-store
, or not [827] If transport is a failure :[828] Return a failure .[829] Otherwise:[830] Return an HTTP connection :HTTP connection endpoint type client
transport transport
[607] To wait for other connections of host , port , and ws
in user agent , run these steps:[1324] If ws is false , abort these steps.[831] If host is a domain :[832] Let n be an implementation dependent small number.[833] Otherwise:[834] Let n be 1 .[835] Wait while the number of connections with the following
conditions is not less than n :
[1336] To establish a WebSocket connection , given a url ,
protocols , and client , run these steps:[1337] Let requestURL be a copy of url , with its
scheme set to "http
", if url 's scheme
is "ws
", and to "https
" otherwise.[1338] Let request be a request :Request url url client client skip-service-worker flag true synchronous flag true mode websocket
credentials mode include
cache mode no-store
redirect mode error
WebSocket subprotocols protocols [1339] Fetch request with process response >>1348
and process response done >>1342 .
[1348] The process response with response is as follows:[1340] If response is not a network error and
response 's WebSocket connection established is true :[1346] The WebSocket Connection is Established with:Extensions In Use
response 's header list 's
`Sec-WebSocket-Extensions
` header's value, if any, or null
Subprotocol In Use
response 's header list 's
`Sec-WebSocket-Protocol
` header's value, if any, or null
[1342] The process response done with response is as follows:[1345] Let exit status be response 's exit status .[1350] If exit status is null
:[1351] Set exit status to an exit status whose 失敗 is false .[1343] The WebSocket Connection Is Closed with:Fail The WebSocket Connection exit status 's 失敗 cleanly exit status 's WebSocket cleanly is true The WebSocket Connection Close Code exit status 's WebSocket状態符号 The WebSocket Connection Close Reason exit status 's WebSocket理由文字列
[838] To make an HTTP request over connection using request
in HTTP-network fetch ,
with credentials flag and optional not retryable flag,
run these steps:[1344] Configure connection such that any notification is handled by >>839 ,
which uses websocket data type and websocket data .[837] If connection 's transport 's
http protocol is http2
:
[930] If connection 's transport 's
http protocol is ftp
:[1289] Send an FTP request request over connection .[931] Otherwise:[541] If connection 's transport 's
request mode is HTTP proxy :[845] Let target be request 's originpathquery .[843] Otherwise:[844] Let target be request 's current url 's pathquery .[901] Let host header be request 's current url 's hostport .[900] Append Host
/host header to request 's header list .[905] Append Connection
/keep-alive
to request 's
header list .[840] Send an HTTP request over connection .HTTP request 要求メソッド request 's method 要求対象 target ヘッダーリスト request 's header list 本体 request 's body mode request 's mode
[839] Any notification msg from connection is processed as follows,
switched by msg 's type:要求の本体の一部の送信の通知 Process transmitted as follows:Increase
request 's
body stream's transmitted bytes
要求の送信完了の通知 Set
request 's
body stream's done flag
応答のヘッダー受信完了の通知 Process http response and
WebSocket connection established as follows:[856] If connection 's transport 's
request mode is not HTTP proxy and
http response 's 状態符号 is 407
:[857] Set response to a network error .[858] Otherwise:[841] Set response to a response :Response status http response 's 状態符号 status message http response 's 理由句 header list http response 's ヘッダーリスト HTTPS state connection 's transport 's
HTTPS state WebSocket connection established WebSocket connection established [892] If connection 's transport 's
protocol is
tls
and connection 's transport 's
has alert is false :[893] Process the HSTS header of response , if any.[894] Process the PKP headers of response , if any.[842] Now headers are transmitted . Return response . datastart
の通知Process data type as follows:[537] If request 's mode is websocket
:[1360] Set websocket data type to data type .[1349] If data type is Text :[538] Set websocket data to the empty string .[1352] Otherwise:[1353] Set websocket data to the empty byte string . data
の通知Process data as follows:[1354] If request 's mode is websocket
:[1356] Append data to websocket data .[1355] Otherwise:Write
data to
response 's
body stream
dataend
の通知[1357] If request 's mode is websocket
:[1359] A WebSocket Message Has Been Received with:type websocket data type data websocket data [1358] Otherwise:Set
response 's
body stream's done flag
wsclosing
の通知
The WebSocket Closing Handshake Is Started . 完了の通知 Process http response and exit status as follows:[851] If exit status 's 失敗 is true:[852] If headers are transmitted :[855] Mutate response into a network error whose
exit status is exit status .[257] Otherwise, if not retryable is false ,
exit status 's can retry is true , and
the user agent wants to retry the request:[882] Let connection be the result of
obtaining a connection , given request 's
current url 's origin and credentials .[883] If connection is a failure , return a network error
and abort these steps.[884] Return the result of recursively making an HTTP request
over connection using request ,
with credentials flag, with not retryable flag set.[854] Otherwise:[853] Return a network error whose exit status
is exit status .
TLS client certificate dialog
[1375] A request has following additional field:acceptSslCerts
A boolean . Initially, false .
[1347] A response has following additional fields:exit status
An exit status or null
. Initially, null
. incomplete message flag
A boolean . Initially, false . WebSocket connection established flag
A boolean . Initially, false .
Hosts and ports [323] An IP address is an IPv4 address or IPv6 address .
[365] A port is a 16-bit unsigned integer.
Verification of service identity [943] The service identity verification steps for host and
certificate are these steps:[947] Let domains be a list of the dNSName
values in certificate 's
subjectAltName
extension , if any.[948] Let addresses be a list of the iPAddress
values in certificate 's
subjectAltName
extension , if any.[949] If all of these conditions are true :[967] Let cn be certificate 's subject
field has
the first CN
value.[968] Otherwise:[969] Let cn be null .[944] If host is a domain :[958] For each domain in domains :[957] If host certificate-domain-pattern matches domain :[959] Return true and abort these steps.[970] If cn is not null and
host certificate-domain-pattern matches cn :[971] Return true and abort these steps.[945] Otherwise, if host is an IPv4 address :[954] For each address in addresses :[955] If address represents the same IPv4 address as host :[956] Return true and abort these steps.[963] If cn is the result of applying IPv4 serializer to host :[972] Return true and abort these steps.[946] Otherwise, if host is an IPv6 address :[950] For each address in addresses :[951] If address represents the same IPv6 address as host :[952] Return true and abort these steps.[953] Return false .
[960] Whether a domain domain certificate-domain-pattern matches
a string pattern or not is the value returned by the following steps:[962] If the last character of pattern , if any, is a .
character:[973] Return false and abort these steps.[975] Let canonicalized pattern be pattern , converted to ASCII lowercase .[974] If domain is canonicalized pattern , optionally followed by
a .
character:[976] Return true and abort these steps.[977] If the first two characters of canonicalized pattern , if any, is *.
:[979] Remove the first two characters from canonicalized pattern .[980] If canonicalized pattern does not contain any .
character,
or canonicalized pattern is an ICANN public suffix :[982] Return false and abort these steps.[983] If domain is one or more characters,
followed by canonicalized pattern , optionally followed by a .
character:[984] Return true and abort these steps.[978] Return false .
[1327] A string string is an ICANN public suffix if
the public suffix of string is string
when only ICANN domains are taken into account.
[1314] A user agent user agent has get proxies steps,
which are invoked with user agent and URL record url .
The get proxies steps must return a list of zero or more proxy configuration
objects.
[612] A proxy configuration has protocol , which is one of:
tcp
,
unix
,
http
,
https
,
socks4
, and
socks5
.
[613] A proxy configuration whose protocol is
http
, https
, socks4
, or socks5
has
host , whose value is a host , and
port , whose value is an integer or null .
The initial value of the port is null .
[543] A proxy configuration whose protocol is
http
or https
has username ,
whose value is a string ,
and password , whose value is a string or null .
The initial value of the username is the empty string .
The initial value of the password is null .
[614] A proxy configuration whose protocol is
unix
has path , whose value is a byte string .
[1315] The get proxies steps are implementation dependent. Following
subsections include examples of such steps.
[1043] This subsection applies to a user agent that supports environment variable
based proxy configurations.
[1317] A user agent has following states:HTTP proxy A proxy configuration or null . HTTPS proxy A proxy configuration or null . FTP proxy A proxy configuration or null . no proxy hosts A list of host s.
[836] Upon initialization, a user agent MUST run these steps:[1021] Set user agent 's HTTP proxy to the result of
parsing environment variable http_proxy
.[1022] Set user agent 's HTTPS proxy to the result of
parsing environment variable https_proxy
.[1023] Set user agent 's FTP proxy to the result of
parsing environment variable ftp_proxy
.[1037] Let no_proxy be the result of
getting the environment variable no_proxy
.[1038] If no_proxy value is not null and is not the empty string :[1039] For each substring value obtained by splitting no_proxy value
by a ,
character:[1040] Remove any leading and trailing C0 controls and space characters
from value .[1041] Let host be the result of applying the host parser to value .[1042] If host is not an error,
append host to user agent 's no proxy hosts .
[1024] To parse an environment variable whose name is name ,
run these steps:[1025] Let value be the result of
getting the environment variable name .[1026] If value is null or the empty string :[1027] Return null and abort these steps.[1055] Let url be the result of applying the proxy environment variable parser
to value .[1030] If url 's scheme is http
or https
:[1031] Return a proxy configuration .Proxy configuration protocol url 's scheme host url 's host port url 's port username url 's username password url 's password [1032] Otherwise, if url 's scheme is socks4
or socks5
and url
's host is not null :[1033] Return a proxy configuration .Proxy configuration protocol url 's scheme host url 's host port url 's port [1034] Otherwise:[1035] The user agent MAY report an error and MAY
terminate the user agent .[1036] Return null .
[1045] To get an environment variable with string name , run these steps:[1047] Let value be the value of the user agent 's process 's
environment variable whose name is name , if any, or the empty string .[1290] Let uc name be name , converted to ASCII uppercase .[1373] Let uc value be the value of the user agent 's process 's
environment variable whose name is uc name , if any, or the empty string .[1046] If value is not the empty string and value is not uc value :[1049] Let encoding be the encoding of the platform .[1048] Return the result of decoding value in encoding .[1050] Otherwise:[1051] Return null
.
[1374] For security, uppercase environment variable HTTP_PROXY
cannot be used.
[1000] The get proxies steps for url are these steps:[1018] For each host host in user agent 's no proxy hosts :[1019] If host equals url 's host :[1020] Return a list whose only member is a proxy configuration
whose protocol is tcp
and abort these steps.[611] If url 's scheme is http
and
user agent 's HTTP proxy is not null :[1012] Return a list whose only member is user agent 's HTTP proxy
and abort these steps.[1013] If url 's scheme is https
and
user agent 's HTTPS proxy is not null :[1014] Return a list whose only member is user agent 's HTTPS proxy
and abort these steps.[1015] If url 's scheme is ftp
and
user agent 's FTP proxy is not null :[1016] Return a list whose only member is user agent 's FTP proxy
and abort these steps.[546] Return a list whose only member is a proxy configuration
whose protocol is tcp
.
[640] A transport has following states:
[408] Transport protocol
One of
tcp
,
unix
,
http1connect
,
http2connect
,
tls
,
socks4
, and
socks5
. endpoint type
Either client
or server
. http protocol
Either http1
, http2
, or ftp
.
The default is http1
. proxy configuration A proxy configuration . 送信閉じ済みフラグ 初期状態では未設定。 受信閉じ済みフラグ 初期状態では未設定。 送信待ちバッファー 初期状態では空のリスト。 request mode
The value is either default or HTTP proxy .
If the 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 . HTTPS state
An HTTPS state value. Either none
, deprecated
, or modern
.
The default is none
. [38] An exit status has following states:
[469] Exit status リセット 真 か偽 。既定値は偽 。失敗 真 か偽 。WebSocket cleanly真 か偽 か null。既定値は null。WebSocket 状態符号 整数 か null。既定値は null。WebSocket 理由文字列 か null。既定値は null。can retry A boolean . The default is false . [1054] To create a transport for a proxy configuration proxy
with a URL record url and optional ws and skip DNS cache
flags in user agent ,
run rhese steps:[549] If user agent does not support proxy 's protocol :[550] Return a failure and abort these steps.[551] Switch by proxy 's protocol :tcp
[552] Set effective port be the effective port of url .[553] Set addr to the result of applying name resolution steps
to url 's host with skip DNS cache in user agent .[554] If addr is an error :[555] Return a failure and abort these steps.[557] Wait for other connections of
addr , port , and ws in user agent in user agent .[558] Return the result of
establishing a TCP transport
to addr and effective port .unix
[559] Return the result of
establishing a UNIX socket domain transport
with proxy 's path , url 's host ,
and url 's effective port .http
or https
[560] Wait for other connections of
url 's host , port , and ws in user agent .[561] Let proxy port be proxy 's port .[562] If proxy port is null :[563] If proxy 's protocol is http
, set proxy port to 80 .[564] If proxy 's protocol is https
, set proxy port to 443 .[565] Let proxy addr be the result of applying name resolution steps
to proxy 's host in user agent .[566] If proxy addr is an error :[567] Return a failure and abort these steps.[568] Let transport be the result of
establishing a TCP transport
to proxy addr and proxy port .[570] If proxy 's protocol is https
:[571] Set transport to the result of running the TLS steps for
transport and proxy 's host .[556] If transport is a failure :[569] Return a failure and abort these steps.[572] If url 's scheme is https
:[577] Let http be an HTTP connection :HTTP connection endpoint type client
transport transport [578] Set transport to the result of
establishing an HTTP CONNECT
transport
with http and url .credentials flag and proxy credentials
[579] If transport is a failure whose HTTP response's status is
407
:Show proxy auth dialog
[580] Otherwise:[581] Set transport 's request mode to HTTP proxy .[548] Return transport .socks4
[582] Let effective port be the effective port of url .[583] Set addr to the result of applying name resolution steps
to url 's host with skip DNS cache in user agent .[584] If addr is not an IPv4 address :[585] Return a failure and abort these steps.[587] Wait for other connections of
addr , port , and ws in user agent .[588] Let proxy port be proxy 's port .[589] If proxy port is null , set proxy port to 1080 .[590] Let proxy addr be the result of applying name resolution steps
to proxy 's host in user agent .[591] Let transport be the result of
establishing a TCP connection
to proxy addr and proxy port .[592] Return the result of
establishing a SOCKS4 connection
with transport , addr , and effective port .socks5
[593] Let effective port be the effective port of url .[594] Wait for other connections of
url 's host , port , and ws in user agent .[595] Let proxy port be proxy 's port .[597] If proxy port is null , set proxy port to 1080 .[596] Let proxy addr be the result of applying name resolution steps
to proxy 's host in user agent .[598] Let transport be the result of
establishing a TCP transport
to proxy addr and proxy port .[599] Return the result of
establishing a SOCKS5 transport
with transport , url 's host , and effective port .
[542] To establish a transport for URL record s request url and
server url
and a user agent user agent , optionally with credentials , ws ,
acceptSslCerts
,
and skip DNS cache flags, run these steps:
[936] Assert: request url 's scheme is a network scheme .[909] Assert: Either server url 's scheme is http
or server url is request url .[1009] Let proxies be the result of getting proxies for
server url in user agent .[547] For each proxy in proxies , in order, run these substeps:[1053] Set transport to the result of
creating a transport for proxy
proxy with server url , ws , and skip DNS cache .[600] If transport is not a failure :[601] If request url 's scheme is https
:[602] Set transport to the result of running the TLS steps for
transport , request url 's host , credentials flag, ws flag,
and acceptSslCerts
flag, in user agent .[603] Otherwise, if transport 's request mode is not HTTP proxy and
request url 's scheme is ftp
:[929] Set transport 's http protocol to ftp
.[927] If transport is not a failure :[1182] Set transport 's proxy configuration
to proxy .[605] Return transport and abort these steps.[606] Return a failure .[642] アプリケーション は、 transport に次の指示を行えます。バイト の送信の指示正常終了の送信の指示 中断の指示 credentials の送信の指示
[643] バイト の送信の指示は、送信するバイト (0-255 のいずれかの値)と、
緊急データ か否かのフラグ (既定値は未設定。)
を引数 とし、次のように処理します。[644] 送信閉じ済みフラグ が設定されていれば、例外 を投げて停止します。[645] 送信待ちバッファー が満杯なら、例外 を投げて停止します。[646] 緊急データ フラグが設定されていて、
transport の種類が緊急データ に対応していないものなら、
例外 を投げて停止します。[647] 送信待ちバッファー の末尾に、
引数のバイト 、
引数の緊急データ か否かのフラグ、
約束 の組を追加します。[648] 追加した約束 を返します。
[650] バイト列 を送信するとは、当該バイト列 について先頭のバイト から順にバイト の送信の指示を行い、最後のバイト が返した約束 を返す
(空バイト列なら解決 済みの約束 を返す) ことをいいます。
[651] 正常終了の送信の指示は、次のように処理します。[652] 送信閉じ済みフラグ が設定されていれば、例外 を投げて停止します。[653] 送信閉じ済みフラグ を設定します。[654] transport の種類に応じた処理を行います。
[655] 中断の指示は、次のように処理します。[656] 送信閉じ済みフラグ と受信閉じ済みフラグ の両方が設定されていれば、
例外 を投げて停止します。[657] 送信閉じ済みフラグ を設定します。[658] 受信閉じ済みフラグ を設定します。[659] 送信待ちバッファー の先頭の項目から順に、
約束 を拒絶 していきます。[660] transport の種類に応じた処理を行います。[661] 中断の通知を行います。リセットフラグを設定します。
[662] credentials の送信の指示は、
transport の種類に応じた処理を実行します。そのようなものがなければ、
例外 を投げます。
なお引数として、transport の種類に応じた credentials を受け取ります。
[663] transport は、アプリケーション に対して次の通知を行います。
[669] transport の種類に依存した方法で次のバイト を送信可能であると判断したら、
次のようにします。[670] 送信待ちバッファー が空なら、ここで停止します。[671] 送信待ちバッファー の先頭の項目を取得し、バッファーからは削除します。[672] transport の種類に依存した方法で取得した項目のバイト を送信します。
(あれば) 緊急データ フラグを引渡します。[673] 取得した項目の約束 を解決 します。
[1435] A transport whose protocol is
tcp
has following additional states:
remote host A host . remote port A port . local host A host . local port A port . tcp connection A TCP connection . [742] To TCP connect to host host and port port ,
establish a connection to host and port as described in TCP
specifications and asynchronously returns a new TCP connection
representing the connection if the connection is established,
or failure if the connection cannot be established.
A TCP connection has
local address , which is an IP address ,
and local port , which is a port .
[1437] To set TCP options of TCP connection tcp ,
run these steps:
[420] Disable the SO_OOBINLINE
option of tcp .[424] Enable the SO_NODELAY
option of tcp .[437] Run the implementation dependent steps for setting TCP keep alive options, e.g.:[635] Enable the SO_KEEPALIVE
option of tcp .[636] Set TCP_KEEPIDLE
option of tcp to 45 seconds.[637] Set TCP_KEEPINTVL
option of tcp to 45 seconds.[627] To establish a TCP transport to IP address addr and
port port , run these steps:
[1416] If addr is 127.0.53.53
:[1417] Return a failure and abort these steps.[628] Let tcp be the result of invoking
TCP connect with addr and port .[629] If tcp is failure :[782] Return failure and abort these steps.[674] Let transport be a new transport :[406] Transport protocol tcp
endpoint type client
remote host addr remote port port local host tcp 's local address local port tcp 's local port tcp connection tcp [641] Set TCP options of tcp .[818] Return transport .[411] Whenever it accepts a TCP connection tcp from
IP address remote addr and port remote port ,
a TCP server listening IP address addr and port port
MUST run the TCP after accept steps with
tcp ,
addr , port , remote addr , and remote port .
[524] The TCP after accept steps with
TCP connection tcp ,
IP address addr ,
port port ,
IP address remote addr , and
port remote port are:
[414] Let transport be a new transport representing the
TCP connection , with following states:[417] Transport protocol tcp
endpoint type server
remote host remote addr remote port remote port local host addr local port port tcp connection tcp [1436] Set TCP options of tcp .[460] Optionally, run implementation dependent steps (e.g. DoS protection).[446] Return transport .[676] TCP のセグメント を受信したら、次のようにします。[677] TCP に従い処理し、不適切と判断すればここで停止します。[678] RST
フラグが設定されていれば、[679] 送信閉じ済みフラグ を設定します。[680] 受信閉じ済みフラグ を設定します。[681] 中断を通知します。リセットフラグを設定します。[682] データの各バイト について、順に、[683] バイト の受信を通知します。当該バイト の値を渡します。
緊急ポインター が本バイト を指していれば、緊急データ フラグも設定します。[684] FIN
フラグが設定されていれば、[685] 受信閉じ済みフラグ を設定します。[686] 正常終了の受信を通知します。
[687] タイムアウト その他の理由でtransport が利用できないことを検知したら、
次のようにします。[688] 送信閉じ済みフラグ を設定します。[689] 受信閉じ済みフラグ を設定します。[690] 中断を通知します。
[691] バイト を送信できるかどうかは、フロー制御 、輻輳制御 その他の状況により決定します。
[692] バイト の送信は、次のようにします。[693] 緊急データ フラグが設定されていれば、[694] 指定されたバイト をデータとして含み、緊急ポインター が当該バイト を指すセグメント を送信することにします。[695] それ以外なら、[696] 指定されたバイト をデータとして含むセグメント を送信することにします。
[698] 緊急データ に対応しています。
[699] 正常終了の送信の指示があれば、次のようにします。[700] FIN
フラグが設定されたセグメント を送信することにします。
[701] 中断の指示があれば、次のようにします。[702] 必要に応じて FIN
フラグが設定されたセグメント を送信することにします。[703] TCP で受信したデータの処理を以後行わないことにします。
Unix domain sockets [805] To establish a Unix domain socket connection for byte string path
with host host and integer port , run these steps:
[807] ソケットAPI を使って新たに接続します。アドレス族 AF_UNIX
パス名 path ソケット型 SOCK_STREAM
[806] If failed, return a failure and abort these steps.[820] Return a new transport representing the socket,
with following states:[631] Transport protocol unix
endpoint type client
[604] A Unix domain socket server, whenever it accepts a connection,
MUST run the Unix domain socket after accept steps .
[586] The Unix domain socket after accept steps are:
[608] Let transport be a new transport representing the
Unix domain socket connection, with following states:[620] Transport protocol unix
endpoint type server
[675] Return transport .[810] バイトが送信可能かどうかは、 send
によりバイト列を送信できるかどうかとします。
[811] バイトの送信は、 send
によります。
[812] 正常終了の送信の指示があれば、 shutdown
SHUT_WR
を実行します。
[813] 中断の指示があれば、 shutdown
SHUT_RDWR
を実行します。
[814] recv
によりバイト列を受信したら、
各バイトを順に、バイトの受信を通知します。
[815] recv
で何も受信しなくなれば、
送信閉じ済みフラグ を設定し、正常終了の受信を通知します。
[816] send
や recv
でエラーが発生したら、
送信閉じ済みフラグ と受信閉じ済みフラグ を設定し、
中断を通知します。
[877] A transport whose protocol is
tls
has following additional states:is ev A boolean .
The default is false . remote certificates A list of certificates . has alert A boolean .
The default is false .
[638] The TLS steps for transport , url , and credentials ,
with optional ws and acceptSslCerts
flags,
in user agent are as follows:credentials
[878] If ws is true:[879] Set alpn protocols to (http/1.1
).[880] Otherwise:[881] Set alpn protocols to (h2
, http/1.1
).If switched from HTTP/2 to HTTP/1.1
[356] Initiate TLS handshake .Minimum TLS version 1.0
Underlying transport transport Compression Disabled TLS session cacheuser agent 's TLS session cacheSNI host
If url 's host is a domain , url 's host .
Otherwise, null . Use OCSP stapling request true ALPN protocol names alpn protocols Certificate database user agent 's certificate database Additional verification for server certificate cert
Return the result of running the service identity verification steps with
url 's host and cert . [861] If failed, return a failure and abort these steps.[865] Let alpn be the ALPN protocol name obtained by the TLS handshake.[872] Let version be the TLS protocol version in use.[873] Let cipher be the cipher suite and parameters in use.[866] If alpn is null or http/1.1
:[867] Set protocol to http1
.[868] Otherwise, if alpn is h2
:[869] Set protocol to http2
.[885] If one of the following conditions is met:[886] Return a failure and abort these steps.[870] Otherwise:[871] Return a failure and abort these steps.[874] Let certs be the received certificates .[876] Let ev be whether certs contain a valid EV certificate or not.[985] Let ocsp be the OCSP stapling response, if any, or null .[993] For each cert in certs 's CA certificates :[994] If the result of running the certificate revocation verification steps
with certificate set to cert , certificate type set to CA certificate ,
and ocsp set to null , is false :[704] Return a failure and abort these steps.[862] If the result of running the certificate revocation verification steps
with certificate set to certs 's end entity certificate ,
certificate type set to end entity , and ocsp , is false :[704] Return a failure and abort these steps.[705] Apply PKP verification for certs and url 's host
in user agent .[860] Let tls transport be a new transport that represents the TLS connection ,
with following states:[1423] Transport protocol tls
endpoint type client
http protocol protocol is ev ev remote certificates certs [859] Set tls transport 's HTTPS state
to modern
or deprecated
, as determined by an implementation dependent
algorithm whose inputs are version , cipher , certs ,
and whether there are TLS warnings or not.[906] Return tls transport .
[895] The certificate revocation verification steps for
certificate (a certificate ),
certificate type (CA certificate or end entity certificate ), and
ocsp (an OCSP response or null ) are these steps:[864] If the user agent 's certificate database knows whether
cert has been revoked or not:[875] Return true if cert has been revoked,
or false otherwise, and abort these steps.[937] If ocsp is a valid OCSP response:[999] Return true if cert has been revoked according to ocsp ,
or false otherwise, and abort these steps.[989] Otherwise, if cert has the OCSP must-staple option enabled:[940] Return false and abort these steps.[990] Let duration be cert 's notAfter
timestamp -
cert 's notBefore
timestamp.[991] If duration is less than 10 days (i.e. cert is a short-lived certificate ):[992] Return true and abort these steps.[863] Let ocsp url be cert 's OCSP URL .[995] If ocsp url is not null ,
the implementation MAY run these substeps:[996] Send an OCSP request for cert to ocsp url .
Set ocsp to the result.[997] If ocsp is a valid OCSP response:[986] Let result be true if cert has been revoked according to ocsp ,
or false otherwise.[998] Optionally , save result to the user agent 's
certificate database as the cached verification result for cert .[988] Return result and abort these steps.unset EV flag (and set HTTPS state to deprecated?)
[987] Return true .
[384] A user agent has TLS session cache and
certificate database .
[923] A TLS server, whenever its underlying transport accepts a connection,
MUST run these steps:
[928] Assert: The underlying transport protocol is
TCP or Unix domain socket.[925] Let transport be the result of running
TCP after accept steps , if the underlying transport protocol is TCP, or
Unix domain socket after accept steps , otherwise.[1424] Start TLS over transport .[706] Optionally, perform implementation dependent verification of the client certificates.OCSP stapling
If failed, ...
[1433] Let protocol be http/1.1
.ALPN: H2
[1431] Let certs be the received certificates .[1426] Let tls transport be a new transport that represents the
TLS connection , with following states:[1430] Transport protocol tls
endpoint type server
http protocol protocol remote certificates certs Verify TLS version and cipher suites.
[1434] Return transport .[707] transport からバイトを受信したら、バイト と緊急データ フラグを TLS に従い処理します。
[708] closure alert を受信したら、次のようにします。[709] 正常終了の受信を通知します。
[710] error alert を受信したら、次のようにします。[891] Set connection 's has alert to true .[711] alert level が警告 and user agent does not have
HSTS policy or pin for url 's host :[712] 警告を通知します。[713] それ以外なら、[714] 送信閉じ済みフラグ を設定します。[715] 受信閉じ済みフラグ を設定します。[716] 中断を通知します。リセットフラグを設定します。
[717] transport から正常終了を受信したら、次のようにします。[718] 受信閉じ済みフラグ が設定されていなければ、[719] 受信閉じ済みフラグ を設定します。[720] 正常終了の受信を通知します。
[721] transport から中断を受信したら、次のようにします。[722] 受信閉じ済みフラグ と送信閉じ済みフラグ のどちらかが未設定なら、[723] 送信閉じ済みフラグ を設定します。[724] 受信閉じ済みフラグ を設定します。[725] 中断を通知します。
[726] バイトの送信は、 TLS に従い処理します。
[727] バイトを送信できるかどうかは、新たなバイトを入力として TLS
で処理できるかどうかとします。
[728] 正常終了の送信の指示があれば、次のようにします。[729] closure alert を送信します。[730] transport に正常終了の送信を指示します。
[731] 中断の指示があれば、transport に中断を指示します。
[732] TLS の処理によりバイト列を送信するべきときは、
transport で指定されたバイト列を送信します。
[889] TLS renegotiation:
If protocol is http2 and after preface, connection error PROTOCOL_ERROR
[733] TLS の最初の handshake
または再折衝 によりクライアント証明書 を要求された時は、
次のようにします。[734] challenge の受信を通知します。transport transport challenge (サーバーなら) ClientHello
や (クライアントなら) CertificateRequest
に含まれる情報のうち必要なもの。
[735] credentials の送信は、次のようにします。[736] TLS が credentials を受け付ける状態でなければ、例外を投げて停止します。[737] そうでなければ、与えられた credentials を TLS の処理に引渡します。
[355] An HTTP connection has following states:endpoint type client
or server
.transport A transport .
[34] An HTTP connection whose protocol is http1
has following additional states:
状態 後述の状態遷移における状態のいずれか。初期値は「初期」。 write mode
One of null
, "raw", "websocket", or "sent". Initially, null
. to be closed
A boolean . Initially, false . 要求 要求 か null。初期値は null です。応答 応答 か null。初期値は null です。一時バッファー バイト列。初期値は空。 最後のヘッダー ヘッダーか null 残り長さ 非負整数 か null か「chunked」かエラー。response received
A boolean . Initially, true . 要求の転送済 非負整数 。初期値は 0。要求の処理完了 Promise か null。初期値は null。WebSocket key A byte string or null
. Initially, null
. WebSocket接続の状態 CONNECTING
、OPEN
、
CLOSING
、null のいずれか。初期値は null。フレーム WebSocketフレーム または null。初期値は null。WebSocket data type Text , Binary , or null
.
Initially, null
.decoder A TextDecoder
or null
.
Initially, null
. exit status An exit status or null .
Initially, null . 切断タイマー タイマー。 stream request method A byte string or null
. Initially, null
. stream WebSocket subprotocols An ordered set of zero or more byte strings.
Initially, an empty set. stream received A boolean . Initially, false . stream sent A boolean . Initially, false . [314] タイマーは、初期状態では動作していません。時間と動作が設定されると、
指定時間経過後に指定の動作が実行されます。既に設定された動作は取り消され、実行されません。
[62] 要求 は、次のようなデータ構造です。要求 要求メソッド バイト列。 要求対象 バイト列。 プロトコルの版 1.1
。ヘッダーリスト 0個以上のヘッダー のリスト。 本体 バイト列。初期値は空。 mode A mode value. WebSocket subprotocols An ordered set of zero or more byte strings.
Initially, an empty list.
[63] 応答 は、次のようなデータ構造です。応答 プロトコルの版 0.9
, 1.0
, 1.1
のいずれか。初期値は 0.9
。状態符号 非負整数 。初期値は 200
。理由句 バイト列 。初期値は OK
。ヘッダーリスト 0個以上のヘッダー のリスト。初期値は空。 incomplete message
A boolean . Initially, false .
[42] 要求の送信は、次のようにします。この処理は、
connection and 要求 である送信する要求 を入力として受け取ります。
[90] Assert: The following conditions have to be true :[61] 要求 を、送信する要求 に設定します。[135] Set connection 's stream request method to 送信する要求 's 要求メソッド .[64] 応答 を、新しい応答 に設定します。[60] 一時バッファー を、空バイト列に設定します。[59] 状態 を、「応答前」に設定します。[77] 要求 に Connection:
ヘッダー があって
close
(ASCII大文字・小文字不区別 ) 接続オプション が指定されていれば、[78] Set connection 's to be closed flag to true .[98] If 要求 's mode is websocket
:[258] Set connection 's WebSocket接続の状態 to CONNECTING
.[1331] Set connection 's WebSocket key be a nonce consisting of a randomly selected 16-byte value that has been forgiving-base64 encode d.[265] Append
`Sec-WebSocket-Key
`/connection 's WebSocket key
to 要求 's header list .[266] Append `Sec-WebSocket-Version
`/`13
`
to 要求 's header list .[1332] For each protocol in 要求 's WebSocket subprotocols ,
combine `Sec-WebSocket-Protocol
`/protocol
in 要求 's header list .[264] Let
permessageDeflate be a user-agent defined "
permessage-deflate
"
extension header value.
[1333] Append
`Sec-WebSocket-Extensions
`/permessageDeflate to
要求 's header list .[57] Set connection 's write mode to "websocket".[241] Set connection 's stream WebSocket subprotocols to 要求 's
WebSocket subprotocols .[491] Otherwise, if connection 's stream request method is CONNECT
:[498] Set connection 's write mode to "before tunnel data".[35] Otherwise:[57] Set connection 's write mode to "raw".[45] 要求の処理完了 を、新しい Promise に設定します。[48] 要求の処理完了 を返します。[46] 並列に 、要求 のバイト列の送信を行います。[25] ここで要求 のバイト列の送信は、次のようにします。
[47] HTTP/1.1 に従い要求 のヘッダー部 (空行の CRLF
まで)
を表すバイト列 の各バイト を順に、connection 's transport でバイト の送信を指示します。エラーが返されたら、ここで停止します。 [1] 要求 のメッセージ本体 が存在する場合、各バイト を順に、connection 's transport でバイト の送信を指示します。エラーが返されたら、ここで停止します。 要求の転送済 を、1だけ大きな値に設定します。要求 について要求の本体の一部の送信を通知して構いません。[75] Run the sent steps for connection .[259] WebSocket メッセージ送信は、次のようにします。
この処理は、バイト列 であるデータ と、テキスト またはバイナリー のいずれかの種別 を引数として受け取ります。[278] 前提として、次の条件を満たす必要があります。[271] WebSocket接続の状態 が OPEN
でなければ、
エラーを返して停止します。[268] WebSocketフレーム を作成します。FIN 1 RSV1 0 RSV2 0 RSV3 0 opcode 種別 がテキストなら 1、バイナリーなら 2mask 1 長さ データ のバイト数マスクキー 無作為に決定した4バイトのバイト列 データ データ [269] 作成した WebSocketフレーム のデータの各バイト について、
先頭から i バイト目 (先頭が0バイト) であれば、
マスクキー の i mod 4 バイト目 (先頭が0バイト)
と XOR した結果に差し替えます。[270] connection 's transport で WebSocketフレーム のバイト列を送信することとします。
[260] ping 送信は、次のようにします。
この処理は、バイト列であるデータ と、応答 フラグを受け取ります。[287] 前提として、次の条件を満たす必要があります。[272] WebSocket接続の状態 が OPEN
でなければ、
エラーを返して停止します。[273] WebSocketフレーム を作成します。FIN 1 RSV1 0 RSV2 0 RSV3 0 opcode 応答 フラグが設定されていれば 10、されていなければ 9mask 1 長さ データのバイト数 マスクキー 無作為に決定した4バイトのバイト列 データ 指定されたバイト列 [274] 作成した WebSocketフレーム のデータの各バイト について、
先頭から i バイト目 (先頭が0バイト) であれば、
マスクキー の i mod 4 バイト目 (先頭が0バイト)
と XOR した結果に差し替えます。[275] connection 's transport で WebSocketフレーム のバイト列を送信することとします。
[107] If a request whose method is CONNECT
has been sent and
a response whose status is 200
has been received, and
the connection is not yet closed,
one or more bytes can be sent over the connection.
That is, to send a byte string bytes over tunnel connection connection ,
run these steps:
[335] Assert:In CONNECT mode
[109] connection 's transport で
bytes の送信を指示します。[110] エラーが返されたら、ここで停止します。[1443] To close a tunnel connection connection , run these steps:
[1444] Run the sent steps for connection with close flag set to true .[50] WebSocket connection の正常終了は、次のようにします。引数として非負整数 または null
である状態符号 と、
バイト列 である理由 を受け取ります。
[286] Assert:[49] If WebSocket接続の状態 is CLOSING
:[277] Abort these steps.[281] WebSocketフレーム を作成します。FIN 1 RSV1 0 RSV2 0 RSV3 0 opcode 8 mask 1 長さ データのバイト数 マスクキー 無作為に決定した4バイトのバイト列 データ 状態符号 が null なら空、
そうでなければ、状態符号 を表す16ビット符号無し整数 (ネットワークバイト順 ) と、
それに続けて理由 [282] 作成した WebSocketフレーム のデータの各バイト について、
先頭から i バイト目 (先頭が0バイト) であれば、
マスクキー の i mod 4 バイト目 (先頭が0バイト)
と XOR した結果に差し替えます。[297] WebSocket接続の状態 を、 CLOSING
に設定します。[174] 要求 について、 wsclosing
を通知します。[284] connection 's transport で、作成した WebSocketフレーム のバイト列を送信することとします。[315] 切断タイマー により20s後に次の要求に進むことにします。[73] To close connection connection , run these steps:
[108] Assert: Not sending a body, CONNECT, or WS mode
[72] Set connection 's to be closed flag to true .[66] 状態 が「初期」か「要求待ち」なら、[55] connection 's transport で正常終了の送信を指示します。[52] 接続 の中断は、次のようにします。
[39] Set the connection 's exit status to a new
exit status whose 失敗 is true .Abort the writable stream
[44] Run the sent steps for connection with close flag set to true .Cancel the readable stream
[11] 状態機械 は、要求 について次の通知を行います。
それぞれ、次に示す引数 (あれば) 付きで通知されます。
[15] 各要求 について、2種類の送信の通知と3種類の受信の通知をそれぞれこの順序で行うか、
その途中で失敗の通知で中断するかのいずれかです。
送信の通知と受信の通知はどちらもそれぞれ進行し、相互の順序は不定です。
送信の完了は通知されないことがあります (失敗の場合)。
data
の通知は、0回以上の任意の回数行います。
data
の通知のかわりに 0回以上の ping の通知がある場合があります。
トンネル では最初に datastart
の通知、最後に dataend
の通知があります。
完了の通知の前に、 wsclosing
の通知があるかもしれません。
initial 要求の送信 v >> 3 -> reqbody -> reqeof -> headers -> rerror -> reset reqbody 本体一部送信 -> reqbody -> reqeof v >> 2 -> rerror -> reset reqeof 送信完了 v >> 1 -> reset headers ヘッダー受信 v >> 3 -> body -> complete -> reset body 受信 v >> 4 -> complete -> body -> reset complete 完了 (成功) v >> 3 reset 完了 (失敗) >> 5 [17] 入力を、 0x0D や 0x0A で区切られた行 に分割します。
行 には区切りの 0x0D, 0x0A は含めません。
[3] 最初の行を (あれば) 次のようにします。
先頭が /
なら、その次がASCII数字 列なら、これを十進整数 として解釈します。
ただし先導0 があるときは、 0 とみなします。 その次が .
なら、その次が ASCII数字 列なら、これを十進整数 として解釈します。 [19] 最初の整数 が2以上 か、
最初の整数 が1と等しく次の整数 が1以上 なら、応答 のプロトコルの版 を、 1.1 に設定します。 次が1個以上の SP
であれば、すべて無視します。 [21] 次にASCII数字 列があれば、応答 の状態符号 をその十進整数 値に設定します。[9] 次の1個以上の SP
があれば、[4] 応答 の理由句 を、行 のそれより後の部分に設定します。[5] それ以外なら、[31] 応答 の理由句 を、空文字列 に設定します。 先頭が1個以上 の SP
列なら、[20] 次にASCII数字 列があれば、応答 の状態符号 をその十進整数 値に設定します。[10] 次の1個以上の SP
があれば、[22] 応答 の理由句 を、行 のそれより後の部分に設定します。[29] それ以外なら、[30] 応答 の理由句 を、空文字列 に設定します。 [23] 更に、次のようにします。最後のヘッダー を、 null に設定します。残りの各行について順番に、先頭の文字が 0x20 か 0x09 なら、最後のヘッダー が null 以外なら、行の先頭から 0x20 と 0x09 をすべて除去します。 最後のヘッダー の値の末尾に、 0x20 と行の内容を追加します。 先頭の文字が 0x3A でなく、 0x3A が含まれるなら、最後のヘッダー を、 0x3A より前の部分を名前、 0x3A より後の部分を値とするヘッダーに設定します。応答 のヘッダーリスト の末尾に、最後のヘッダー を追加します。 それ以外なら、最後のヘッダー を、 null に設定します。 応答 のヘッダーリスト の各ヘッダーについて、名前の末尾から 0x20 と 0x09 をすべて除去します。 値の先頭から 0x20 と 0x09 をすべて除去します。 値の末尾から 0x20 と 0x09 をすべて除去します。
FTP support is to be removed from the Web.
[639] An FTP connection has following states:endpoint type client
transport A transport . read buffer A byte string .
Initially, an empty byte string . state Initially, connected state . username A string . password A string . established promise A promise .
Initially, an unresolved promise . path A byte string or null .
Initially, null . object type Either unknown ,
file , or directory . Initially, unknown . file length Either an integer or
null . Initially, null . data length An integer . data transport A transport or null .
Initially, null . data state
Either initial state , data state , or exit state . data connected promise A promise . is unauthorized A boolean .
Initially, false .
[1227] An FTP connection has similar notification hooks as HTTP connection .
[573] To initiate an FTP connection with
a transport transport ,
a string username , and a string password ,
run these steps:[575] Let ftp be a FTP connection .FTP connection endpoint type client
transport transport username username password password [1067] Let current code be null .[1066] Let current text be an empty byte string .[911] Configure transport to run these substeps whenever
it notifies of バイト の受信 with byte and urgent data flag :[912] If urgent data flag is set, abort these substeps.[1062] Append byte to ftp 's read buffer .[1094] Optionally, abort these substeps.[1063] If byte contains a 0x0A
byte:[1064] Split ftp 's read buffer
into two substrings at the first 0x0A
byte.
Set line to the first substring and ftp 's
read buffer to the second substring,
not including the 0x0A
separator.[1065] Remove the 0x0D
byte at the end of line , if any.[1075] If line has three 0x30
-0x39
bytes followed by
a 0x20
or 0x2D
byte at the beginning:[1076] Let code be the first three bytes of line .[1069] Let continue be whether the fourth byte of line is 0x2D
or not.[1077] Remove first four bytes from line .[1078] If current code is null :[1079] Set current code to code .[1081] Set current text to line followed by 0x0D
0x0A
.[1082] Otherwise, current code is code :[1083] Append line followed by 0x0D
0x0A
to current text .[1084] Otherwise:[1085] Set current code to an error .[1086] If current code is not an error :[1087] Let reply be an FTP reply :code A string obtained by replacing bytes
in current code by code point s with same values. text current text [1091] Run the FTP client state machine with ftp and reply .[1070] Otherwise:[1072] Set current code be null .[1071] Set current text be an empty byte string .[913] Configure transport to run these substeps whenever
it notifies of 正常終了の受信 or 中断 with reset flag :[1060] Set is abort be whether the notification is about 中断 or not.[1090] Let exit be
[1272] Run the FTP client state machine with ftp and null .[1088] Return ftp .
[1104] To send FTP command command with argument text over ftp ,
run these steps:[1105] If text is null :[1106] Send text followed by 0x0D
0x0A
over ftp .[1107] Otherwise:[1108] Send text followed by text followed by 0x0D
0x0A
over ftp .
[1244] To switch to passive mode with ftp , run these steps:[1137] [1139] Otherwise:[1132] Set FTP state of ftp to EPSV
reply state .[1136] Send FTP command `PASV
` with null
over ftp .
[1068] An FTP reply has following states:FTP reply code A string . text A byte string .
[1110] The FTP reply 's first code is its code 's
first character.
[1061] To set FTP state of FTP connection ftp to state ,
run these steps:[1096] If ftp 's read buffer is not empty:[1097] Abort FTP connection ftp .[1098] Otherwise:[1095] Set ftp 's state to state .
[1092] The FTP client state machine of FTP connection ftp
run these steps with FTP reply reply ,
switched by ftp 's state :Connected state [1099] If reply is not null :[1209] If reply 's code is 421
or 521
:[1253] Abort FTP connection ftp .[1254] Otherwise:[1100] Set FTP state of ftp to USER
reply state .[1103] Send FTP command `USER
` and
UTF-8 encoded ftp 's username
over ftp .[1101] Otherwise:[1102] Abort FTP connection ftp .USER
reply state[1109] If reply is not null :[1111] If reply 's first code is 2
:[1157] Set FTP state of ftp to authenticated state .[1126] Resolve ftp 's established promise .[1112] Otherwise, reply 's first code is 3
:[1118] Set FTP state of ftp to before PASS
reply state .[1119] Send FTP command `PASS
` with
UTF-8 encoded ftp 's password
over ftp .[1113] Otherwise:[1116] Request FTP authentication for ftp .[1114] Otherwise:[1115] Request FTP authentication for ftp .PASS
reply state[1120] If reply is not null :[1121] If reply 's first code is 2
:[1127] Set FTP state of ftp to authenticated state .[1158] Resolve ftp 's established promise .[1122] Otherwise:[1123] Request FTP authentication for ftp .[1124] Otherwise:[1125] Request FTP authentication for ftp .TYPE
reply state[1130] If reply is not null and
reply 's first code is 2
:[1073] Switch to passive mode with ftp .[1134] Otherwise:[1135] Abort FTP connection ftp .PASV
reply state[1141] If reply is not null and
reply 's first code is 2
:[1131] If reply 's text matches to the pattern
0x28 digits 0x2C digits 0x2C digits 0x2C digits 0x2C digits 0x2C digits 0x29
,
where digits represents one or more bytes in range [0x30, 0x39]:[1133] Let p1 and p2 be the first such match's last two
digits substrings, respectively, interpreted as decimal integers encoded in UTF-8 .[1143] Let port be p1 × 256 + p2 .[1144]
Establish an FTP data connection for ftp and
and port .[1154] Otherwise:[1155] Abort FTP connection ftp .[1142] Otherwise:[1145] Abort FTP connection ftp .EPSV
reply state[1146] If reply is not null and
reply 's first code is 2
:[1147] If reply 's text matches to the pattern
0x28 0x7C 0x7C 0x7C digits 0x7C 0x29
,
where digits represents one or more bytes in range [0x30, 0x39]:[1148] Let port be the first such match's digits substring,
interpreted as a decimal integer encoded in UTF-8 .[1149]
Establish an FTP data connection for
ftp and port .[1152] Otherwise:[1153] Abort FTP connection ftp .[1150] Otherwise:[1151] Abort FTP connection ftp .Authenticated state
Abort FTP connection ftp . TYPE
reply state[1172] If reply is not null and
reply 's first code is 2
:[1175] If ftp 's object type is directory :[1214] Set FTP state of ftp to CWD
reply state .[1215] Send FTP command `CWD
` with ftp 's
path over ftp .[1176] Otherwise:[1177] Set FTP state of ftp to SIZE
reply state .[1178] Send FTP command `SIZE
` with ftp 's
path over ftp .[1173] Otherwise:[1174] Abort FTP connection ftp .SIZE
reply state[1170] If reply 's first code is 2
and
reply 's text is one or more bytes in range [0x30, 0x39]:[1171] Set ftp 's file length to
reply 's text , interpreted as a decimal integer
encoded in UTF-8 .[1179] Set FTP state of ftp to RETR
reply state .[1206] If ftp 's data connection is null or
ftp 's data state is not initial state :[1207] Abort FTP connection ftp .[1208] Otherwise:[1228] Schedule to run the data connected steps with ftp when ftp 's
data connected promise is resolved.[1180] Send FTP command `RETR
` with ftp 's
path over ftp .RETR
reply state[1181] If reply 's first code is not 1
or 2
:[1246] If reply 's code is 421
, 425
,
or 426
,
or if ftp 's object type is file :[1183] Abort FTP connection ftp .[1210] Otherwise:[1245] If ftp 's data transport is not null :[1251] ftp 's data transport 's 中断の指示.[1252] Set ftp 's data transport to null .[1248] Set ftp 's object type to directory .[1247] Switch to passive mode with ftp .[1249] Otherwise:[1213] Set FTP state of ftp to CWD
reply state .[1212] Send FTP command `CWD
` with ftp 's
path over ftp .CWD
reply state[1216] If reply is not null and
reply 's first code is 2
:[1257] Set ftp 's file length to null .[1258] Set FTP state of ftp to LIST
reply state .[1219] If ftp 's data connection is null or
ftp 's data state is not initial state :[1259] Abort FTP connection ftp .[1260] Otherwise:[1261] Schedule to run the data connected steps with ftp when ftp 's
data connected promise is resolved.[1262] Send FTP command `LIST
` with null .[1217] Otherwise:[1218] Abort FTP connection ftp .RETR
reply state[1225] If reply 's first code is not 1
or 2
:[1226] Abort FTP connection ftp .
[1074] To send an FTP request request over ftp ,
run these steps:[1288] If ftp 's is unauthorized is true :Return a response and abort these steps:Response status 401
status text Unauthorized
header list WWW-Authenticate
Basic realm =""
[1159] Assertion: ftp 's state has to be
authenticated state .[1165] Let type be `I
`.[1160] Let path be concatenation of request 's url 's
path 's items, separated with /
, in order. This can be the empty string .[1161] If path contains a ;
character:[1162] Let param be the first ;
character and the following characters
in path . Remove them from path .[1163] Switch by param :;type=a
Set ftp 's object type to file .
Set type to `A
`. ;type=i
Set ftp 's object type to file . ;type=d
Set ftp 's object type to directory . [1166] Set path be the result of applying UTF-8 encode to path .[1167] Set path be the result of applying percent decode to path .[1168] If the last byte of path , if any, is 0x2F:[1169] Set ftp 's object type to directory .[1164] Set ftp 's path to path .[1128] Set FTP state of ftp to TYPE
reply state .[1129] Send FTP command `TYPE
` with type over
ftp .
XXX
[1378] To prepare metavariables for an request request ,
a transport transport , and
a string or null
scheme key name , run these steps:[1391] Let url be request 's target url .[1409] Set request version to the appropriate value
by request 's version :0.9
HTTP/0.9
1.0
HTTP/1.0
1.1
HTTP/1.1
2.0
HTTP/2.0
[1379] Let vars be a map with following name/value pairs:CONTENT_LENGTH
request 's body length ,
serialized .PATH_INFO
url 's path ,
UTF-8 encoded and percent-decoded REQUEST_METHOD
request 's method SCRIPT_NAME
The empty string SERVER_PROTOCOL
request version [1411] If scheme key name is not null
:[1412] Set vars ' scheme key name to http
.[1382] If transport 's protocol is tls
:[1383] Set transport to transport 's transport .[1388] If url 's scheme is https
:[1386] Set vars ' HTTPS
to ON
.[1413] If scheme key name is not null
:[1414] Set vars ' scheme key name to https
.[1384] If transport 's protocol is tcp
:[1385] Set vars ' REMOTE_ADDR
to transport 's
remote host ,
serialized .[1407] Set vars ' SERVER_NAME
to transport 's
local host ,
serialized .[1408] Set vars ' SERVER_PORT
to transport 's
local port , serialized .[1404] Otherwise:[1405] Set vars 's REMOTE_ADDR
to 127.0.0.1
.[1406] Set vars 's SERVER_NAME
to 127.0.0.1
.[1395] Set vars 's SERVER_PORT
to 0
.[1392] If url 's query is not null
:[1393] Set vars ' QUERY_STRING
to url 's query , UTF-8 encoded .[1396] For each header name in vars ' header list ,
without any duplicate:[1397] If header name is a string of one or more ASCII alphanumeric and/or
-
characters and not ASCII case-insensitively
equal to Content-Length
:[1398] Let key be header name , converted to ASCII uppercase .[1399] Replace any -
in header name by _
.[1400] If header name is not CONTENT_TYPE
:[1394] Prepend HTTP_
to header name .[1401] Let value be the header values in vars 's
header list whose name is
ASCII case-insensitively equal to header name , in order,
combined .[1402] Set vars ' key to value .[1410] Let host be vars ' HTTP_HOST
's value, if any, or null
.[1387] If url 's scheme is HTTP(S) scheme and
url 's hostport , UTF-8 encoded , is host :[1403] Set vars ' REQUEST_URI
to url , serialized and UTF-8 encoded .[1389] Otherwise:[1390] Set vars ' REQUEST_URI
to request 's
target url 's pathquery and UTF-8 encoded .[1381] Return vars .
[242] This specification depends on the Infra Standard .
The terms
forgiving-base64 encode ,
ordered set , empty , contains ,
and
pair
are defined in the Infra Standard .
[1044] The terms
encoding , UTF-8 , UTF-8 encode ,
decode ,
TextDecoder
,
encoding ,
error mode ,
ignore BOM flag ,
decode
,
TextDecodeOptions
, and
stream
are defined in the Encoding Standard .
[621] The terms
C0 controls and space ,
serialize an integer ,
IPv4 address ,
IPv4 serializer ,
IPv6 address , domain ,
host , host parser , equals ,
host serializer ,
percent decode ,
scheme , network scheme ,
URL parser , URL serializer ,
URL record ,
scheme , host , port , and
query
are defined by URL Standard .
[981] The terms Public Suffix and
ICANN DOMAINS is defined by Public Suffix List .
[1341] Status codes 101
and 200
and
URL scheme s http
and https
are defined by HTTP .
[1330] HTTP headers
`Sec-WebSocket-Accept
`,
`Sec-WebSocket-Extensions
`,
`Sec-WebSocket-Key
`,
`Sec-WebSocket-Protocol
`,
`Sec-WebSocket-Version
`
URL scheme s ws
and wss
, and
the terms
The WebSocket Connection is Established ,
Extensions In Use , Subprotocol In Use
A WebSocket Message Has Been Received ,
The WebSocket Closing Handshake Is Started ,
The WebSocket Connection Is Closed ,
The WebSocket Connection Close Code ,
The WebSocket Connection Close Reason , and
Fail The WebSocket Connection
are defined by RFC 6455 .
[354] The terms
bad ports ,
append , combine
request ,
url ,
current url ,
method ,
header list ,
body ,
client ,
skip-service-worker flag ,
synchronous flag ,
mode , credentials mode , cache mode ,
redirect mode ,
response ,
status ,
status message ,
body ,
header list ,
HTTPS state ,
network error ,
connection ,
obtain a connection ,
obtain a WebSocket connection ,
basic fetch , HTTP fetch , HTTP-network-or-cache fetch ,
HTTP-network fetch ,
process response , process response done , and
establish a WebSocket connection
are defined in the Fetch Standard .
[961] The terms
converted to ASCII lowercase and
converted to ASCII uppercase
are defined in the DOM Standard .
[942] SNI is specified in RFC 6066 .
[1007] WPAD is defined by the Internet Draft .
[1008] PAC is defined by https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Necko/Proxy_Auto-Configuration_(PAC)_file
and https://bugzilla.mozilla.org/show_bug.cgi?id=78176 .
[1298] The term Strip url for use as a referrer
is defined in the Referrer Policy .
[610] This document does not support QUIC at this stage, which is supported by Chrome .
[1010] This document does not support VMS -style path syntax in FTP ,
which is supported by Firefox and Chrome .
[1323] This document does not support persistent FTP control connection,
which is supported by Firefox and IE .
[914] Test data: