1. 序論
~INFORMATIVE`XMLHttpRequest$I ~objは、`~fetching$用の~APIである。 ◎ The XMLHttpRequest object is an API for fetching resources.
`XMLHttpRequest$I という名前は歴史的なものであり、 【 “XML” の部分は】 その機能性と何ら関わりは無い。 ◎ The name XMLHttpRequest is historical and has no bearing on its functionality.
~network越しに~fetchされた~XML文書の~dataに対し何かを行う,単純な~code: ◎ Some simple code to do something with data from an XML document fetched over the network:
function processData(%data) { /* ~dataを~~処理する ◎ taking care of data */ } function handler() { if(this.status == 200 && this.responseXML != null && this.responseXML.getElementById('test').textContent) { /* 成功! ◎ success! */ processData(this.responseXML.getElementById('test').textContent); } else { /* 何らかの不具合が生じている ◎ something went wrong */ … } } var %client = new XMLHttpRequest(); %client.onload = handler; %client.open("GET", "unicorn.xml"); %client.send();
単に~serverに~messageを残す: ◎ If you just want to log a message to the server:
function log(%message) { var %client = new XMLHttpRequest(); %client.open("POST", "/log"); %client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); %client.send(%message); }
あるいは、~serverにある文書の状態sを調べる: ◎ Or if you want to check the status of a document on the server:
function fetchStatus(%address) {
var %client = new XMLHttpRequest();
%client.onload = function() {
/*
~network~errorが生じている場合、依拠-可能な結果は得られないであろう。
◎
in case of network errors this might not give reliable results
*/
returnStatus(this.status);
}
%client.open("HEAD", %address);
%client.send();
}
1.1. 仕様の歴史
`XMLHttpRequest$I ~objは、当初は WHATWG による, HTML の(何年も前の、 Microsoft による実装に基づく)成果として定義された。 それは 2006 年には W3C に移管された。 `XMLHttpRequest$I に対する拡張(すなわち、進捗~event, 非同一-生成元( cross-origin )要請)は、 2011 年の終わりまでは別の草案( XMLHttpRequest Level 2 )の下で開発されていたが、その時点でこの 2 つの草案は `XMLHttpRequest$I に併合され,標準の観点から再び一つになった。 2012 年の終わりに,また WHATWG の下に移管されることとなった。 ◎ The XMLHttpRequest object was initially defined as part of the WHATWG’s HTML effort. (Based on Microsoft’s implementation many years prior.) It moved to the W3C in 2006. Extensions (e.g., progress events and cross-origin requests) to XMLHttpRequest were developed in a separate draft (XMLHttpRequest Level 2) until end of 2011, at which point the two drafts were merged and XMLHttpRequest became a single entity again from a standards perspective. End of 2012 it moved back to the WHATWG.
現在の草案までに至る経緯は、次のメーリングリストにて見られる: ◎ Discussion that led to the current draft can be found in the following mailing list archives:
2. 各種用語
この仕様は、 `INFRA$r に依存する。 ◎ This specification depends on the Infra Standard. [INFRA]
この仕様は、次に挙げる仕様による各種用語を利用する ⇒ `DOM$r `DOM-PARSING$r `ENCODING$r `FEATURE-POLICY$r `FETCH$r `FILEAPI$r `HTML$r `URL$r `WEBIDL$r `XML$r `XML-NAMES$r ◎ This specification uses terminology from DOM, DOM Parsing and Serialization, Encoding, Feature Policy, Fetch, File API, HTML, URL, Web IDL, and XML. ◎ [DOM] [DOM-PARSING] [ENCODING] [FEATURE-POLICY] [FETCH] [FILEAPI] [HTML] [URL] [WEBIDL] [XML] [XML-NAMES]
【この訳に特有な表記規約】
この訳の,~algoや定義の記述に利用されている各種記号( ~LET, コレ, ~IF, ~THROW, 等々)の意味や定義の詳細は、~SYMBOL_DEF_REFを~~参照されたし。
3. ~interface `XMLHttpRequest^I
[`Exposed$=(Window,DedicatedWorker,SharedWorker)] interface `XMLHttpRequestEventTarget@I : `EventTarget$I { // ~event~handler attribute `EventHandler$I `onloadstart$m; attribute `EventHandler$I `onprogress$m; attribute `EventHandler$I `onabort$m; attribute `EventHandler$I `onerror$m; attribute `EventHandler$I `onload$m; attribute `EventHandler$I `ontimeout$m; attribute `EventHandler$I `onloadend$m; }; [`Exposed$=(Window,DedicatedWorker,SharedWorker)] interface `XMLHttpRequestUpload@I : `XMLHttpRequestEventTarget$I { }; enum `XMLHttpRequestResponseType@I { "", `arraybuffer@l, `blob@l, `document@l, `json@l, `text@l }; [`Exposed$=(Window,DedicatedWorker,SharedWorker)] interface `XMLHttpRequest@I : `XMLHttpRequestEventTarget$I { `XMLHttpRequest$mc(); // ~event~handler attribute `EventHandler$I `onreadystatechange$m; // 状態 const `unsigned short$ `UNSENT$m = 0; const `unsigned short$ `OPENED$m = 1; const `unsigned short$ `HEADERS_RECEIVED$m = 2; const `unsigned short$ `LOADING$m = 3; const `unsigned short$ `DONE$m = 4; readonly attribute `unsigned short$ `readyState$m; // 要請 `undefined$ `open$m(`ByteString$ %method, `USVString$ %url); `undefined$ `~open_async$m( `ByteString$ %method, `USVString$ %url, `boolean$ %async, optional `USVString$? %username = null, optional `USVString$? %password = null ); `undefined$ `setRequestHeader$m(`ByteString$ %name, `ByteString$ %value); attribute `unsigned long$ `timeout$m; attribute `boolean$ `withCredentials$m; [`SameObject$] readonly attribute `XMLHttpRequestUpload$I `upload$m; `undefined$ `send$m(optional (`Document$I or `XMLHttpRequestBodyInit$I)? %body = null); `undefined$ `abort$m(); // 応答 readonly attribute `USVString$ `responseURL$m; readonly attribute `unsigned short$ `status$m; readonly attribute `ByteString$ `statusText$m; `ByteString$? `getResponseHeader$m(`ByteString$ %name); `ByteString$ `getAllResponseHeaders$m(); `undefined$ `overrideMimeType$m(`DOMString$ %mime); attribute `XMLHttpRequestResponseType$I `responseType$m; readonly attribute `any$ `response$m; readonly attribute `USVString$ `responseText$m; [`Exposed$=Window] readonly attribute `Document$I? `responseXML$m; };
各 `XMLHttpRequest$I ~objには、次に挙げるものが結付けられる: ◎ An XMLHttpRequest object has an associated:
- `~upload~obj@xhr ◎ upload object
- `XMLHttpRequestUpload$I ~obj。 ◎ An XMLHttpRequestUpload object.
- `状態@xhr ◎ state
- 次に挙げるいずれか — 初期~時には `未送信^i とする ⇒# `未送信^i / `~openした^i / `全~headerを受信した^i / `読込n中^i / `済み^i ◎ One of unsent, opened, headers received, loading, and done; initially unsent.
- `~send_~flag@xhr ◎ send() flag
- 真偽値 — 初期~時には ~F とする。 ◎ A flag, initially unset.
- `制限時間@xhr ◎ timeout
- 無符号~整数【~milli秒~~単位】 — 初期~時には 0 とする。 ◎ An unsigned integer, initially 0.
- `非同一-生成元~向け資格証あり?@xhr ◎ cross-origin credentials
- 真偽値 — 初期~時には ~F とする。 ◎ A boolean, initially false.
- `要請~method@xhr ◎ request method
- `~method$ ◎ A method.
- `要請~URL@xhr ◎ request URL
- `~URL$。 ◎ A URL.
- `作者~要請~header~list@xhr ◎ author request headers
- `~header~list$ — 初期~時には空とする。 ◎ A header list, initially empty.
- `要請~本体@xhr ◎ request body
- 初期~時には~NULL とする。 ◎ Initially null.
- `同期~flag@xhr ◎ synchronous flag
- 真偽値 — 初期~時には ~F とする。 ◎ A flag, initially unset.
- `~upload完了-~flag@xhr ◎ upload complete flag
- 真偽値 — 初期~時には ~F とする。 ◎ A flag, initially unset.
- `~upload~listener~flag@xhr ◎ upload listener flag
- 真偽値 — 初期~時には ~F とする。 ◎ A flag, initially unset.
- `時間切れ~flag@xhr ◎ timed out flag
- 真偽値 — 初期~時には ~F とする。 ◎ A flag, initially unset.
- `応答@xhr ◎ response
- `応答$ — 初期~時には`~network~error$とする。 ◎ A response, initially a network error.
- `受信した~byte列@xhr ◎ received bytes
- `~byte列$ — 初期~時には空~byte列とする。 ◎ A byte sequence, initially the empty byte sequence.
- `応答~種別@xhr ◎ response type
- 次に挙げるいずれか — 初期~時には空~文字列とする ⇒# 空~文字列 / `arraybuffer^l / `blob^l / `document^l / `json^l / `text^l ◎ One of the empty string, "arraybuffer", "blob", "document", "json", and "text"; initially the empty string.
- `応答~obj@xhr ◎ response object
- 次に挙げるいずれか — 初期~時には ~NULL とする ⇒# ~obj【これは、`応答$xhrの本体~dataを表現する】/ `失敗^i / ~NULL ◎ An object, failure, or null, initially null.
- `上書き~MIME型@xhr ◎ override MIME type
- `~MIME型$または ~NULL — 初期~時には ~NULL とする。 ◎ A MIME type or null, initially null.\
- 注記: `overrideMimeType()$m を呼出したときに,非 ~NULL にされ得る。 ◎ Can get a value when overrideMimeType() is invoked.
3.1. 構築子
- %client = `new XMLHttpRequest()$m
- 新たな `XMLHttpRequest$I ~objを返す。 ◎ Returns a new XMLHttpRequest object.
3.2. ~garbage収集
`XMLHttpRequest$I ~objは、次をいずれも満たしている間は,~garbage収集しないモノトスル: ◎ An XMLHttpRequest object must not be garbage collected if\
-
次のいずれかを満たしている:
- [ `状態$xhr ~EQ `~openした^i ]~AND[ `~send_~flag$xhr ~EQ ~T ]
- `状態$xhr ~IN { `全~headerを受信した^i, `読込n中^i }
- 次に挙げるいずれかの型の~event用に`~event~listener$が登録されている ⇒ `readystatechange$et, `progress$et, `abort$et, `error$et, `load$et, `timeout$et, `loadend$et ◎ and it has one or more event listeners registered whose type is one of readystatechange, progress, abort, error, load, timeout, and loadend.
`XMLHttpRequest$I ~objが,その接続がまだ開いているにも関わらず~garbage収集された場合、~UAは,~objが演算している進行中の`~fetchを終了-$させるモノトスル。 ◎ If an XMLHttpRequest object is garbage collected while its connection is still open, the user agent must terminate the ongoing fetch operated by the XMLHttpRequest object.
3.3. ~event~handler
`XMLHttpRequestEventTarget$I を継承する~interfaceを実装する~objは、次の`~event~handler$(およびそれらに対応する`~event~handler ~event型$)を属性として~supportするモノトスル。 ◎ The following are the event handlers (and their corresponding event handler event types) that must be supported on objects implementing an interface that inherits from XMLHttpRequestEventTarget as attributes:
`~event~handler$ ◎ event handler | `~event~handler ~event型$ ◎ event handler event type |
---|---|
`onloadstart@m | `loadstart$et |
`onprogress@m | `progress$et |
`onabort@m | `abort$et |
`onerror@m | `error$et |
`onload@m | `load$et |
`ontimeout@m | `timeout$et |
`onloadend@m | `loadend$et |
`XMLHttpRequest$I ~objにおいては、次の`~event~handler$(および対応する `~event~handler ~event型$)も属性として~supportするモノトスル: ◎ The following is the event handler (and its corresponding event handler event type) that must be supported as attribute solely by the XMLHttpRequest object:
`~event~handler$ ◎ event handler | `~event~handler ~event型$ ◎ event handler event type |
---|---|
`onreadystatechange@m | `readystatechange$et |
3.4. 状態
- %client . `readyState$m
- `状態$xhrを返す。 ◎ Returns client’s state.
`readyState@m 取得子~手続きは ⇒ ~RET コレの`状態$xhrが下の表の 1 列目のいずれであるかに応じて,同じ行の 2 列目に示される値: ◎ The readyState getter steps are to return the value from the table below in the cell of the second column, from the row where the value in the cell in the first column is this’s state:
`状態$xhr | 値( 数量-値 ) | 記述 |
---|---|---|
`未送信^i | `UNSENT@m ( 0 ) | ~objは構築-済みである。 ◎ The object has been constructed. |
`~openした^i | `OPENED@m ( 1 ) | `open()$m ~methodは成功裡に呼出された。 この状態~下では、 `setRequestHeader$m を利用して要請~headerを設定でき, `send$m ~methodを利用して~fetchを起動できる。 ◎ The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the fetch can be initiated using the send() method. |
`全~headerを受信した^i | `HEADERS_RECEIVED@m ( 2 ) | すべての~redirect(もしあれば)は追従-済みであり,かつ 応答のすべての~headerは受信-済みである。 ◎ All redirects (if any) have been followed and all headers of a response have been received. |
`読込n中^i | `LOADING@m ( 3 ) | 応答~本体を受信-中にある。 ◎ The response body is being received. |
`済み^i | `DONE@m ( 4 ) | ~data転送が完了しているか, または転送~中に何らかの不具合が生じた(例えば,際限のない~redirect)。 ◎ The data transfer has been completed or something went wrong during the transfer (e.g., infinite redirects). |
3.5. 要請
注記: `XMLHttpRequestUpload$I ~obj上に 1 個~以上の~event~listenerを登録すると,`~CORS予行~要請$が発行されることになる。 (~event~listenerが登録されると`~upload~listener~flag$xhrは ~T になり,それにより`~CORS予行~利用~flag$rqも ~T になるので。) ◎ Registering one or more event listeners on an XMLHttpRequestUpload object will result in a CORS-preflight request. (That is because registering an event listener causes the upload listener flag to be set, which in turn causes the use-CORS-preflight flag to be set.)
3.5.1. `open()^m ~method
- %client . `open$m(%method, %url [, %async = true [, %username = null [, %password = null]]])
- [ `要請~method$xhr, `要請~URL$xhr, `同期~flag$xhr ]を設定する。 ◎ Sets the request method, request URL, and synchronous flag.
- 次のいずれかに該当する場合、 `SyntaxError$E 例外が投出される ⇒# %method は妥当な~methodでない/ %url を構文解析できない ◎ Throws a "SyntaxError" DOMException if either method is not a valid method or url cannot be parsed.
- 次に該当する場合、 `SecurityError$E 例外が投出される ⇒ %method は次のいずれかに文字大小無視で合致する ⇒ `CONNECT^h / `TRACE^h / `TRACK^h ◎ Throws a "SecurityError" DOMException if method is a case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`.
-
次のすべてが満たされている下では、 `InvalidAccessError$E 例外が投出される:
- %async ~EQ ~F
- `現在の大域~obj$は `Window$I ~objである
- [ `timeout$m 属性 ~NEQ 0 ]~OR[ `responseType$m 属性 ~NEQ 空~文字列 ]
~worker以外での同期的 `XMLHttpRequest$I は、末端利用者をひどく待たせることになりかねないので, Web ~platformから除去されつつある過程にある(何年もかかるであろう)。 開発者は、[ `現在の大域~obj$は `Window$I ~objである ]場合には, %async 引数に ~F を渡してはナラナイ。 ~UA には、開発者~用~toolにおいて,その種の用法に対し警告することが強く奨励される — それが生じたときに, `InvalidAccessError$E 例外を投出するように、試験的に実装してもよい。 ◎ Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user’s experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when current global object is a Window object. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an "InvalidAccessError" DOMException when it occurs.
`open(method, url)@m / `~open_async(method, url, async, username, password)@m ~method手続きは: ◎ The open(method, url) and open(method, url, async, username, password) method steps are:
- %設定群~obj ~LET コレに`関連な設定群~obj$ ◎ Let settingsObject be this’s relevant settings object.
- ~IF[ %設定群~obj には`担当の文書$enVがあって,それは`全部的に作動中$ではない ] ⇒ ~THROW `InvalidStateError$E ◎ If settingsObject has a responsible document and it is not fully active, then throw an "InvalidStateError" DOMException.
- ~IF[ %method は`~method$でない ] ⇒ ~THROW `SyntaxError$E ◎ If method is not a method, then throw a "SyntaxError" DOMException.
- ~IF[ %method は`禁止~method$である ] ⇒ ~THROW `SecurityError$E ◎ If method is a forbidden method, then throw a "SecurityError" DOMException.
- %method ~SET `~methodを正規化する$( %method ) ◎ Normalize method.
- %構文解析した~URL ~LET `~URL構文解析する$( %url, %設定群~obj の`~API用~URL文字~符号化法$enV ) ◎ Let parsedURL be the result of parsing url with settingsObject’s API base URL and settingsObject’s API URL character encoding.
- ~IF[ %構文解析した~URL ~EQ `失敗^i ] ⇒ ~THROW `SyntaxError$E ◎ If parsedURL is failure, then throw a "SyntaxError" DOMException.
-
~IF[ %async ~EQ ε ] ⇒ ( %async, %username, %password ) ~SET ( true, ~NULL, ~NULL ) ◎ If the async argument is omitted, set async to true, and set username and password to null.
注記: あいにく,旧来の内容と~~互換性を得るため、 %async 引数に `undefined^c が渡された場合と省略された場合とを,同じに扱うわけにはいかない。 ◎ Unfortunately legacy content prevents treating the async argument being undefined identical from it being omitted.
-
~IF[ %構文解析した~URL の`~host$url ~NEQ ~NULL ]: ◎ If parsedURL’s host is non-null, then:
- ~IF[ %username ~NEQ ~NULL ] ⇒ `~URLの~usernameを設定する$( %構文解析した~URL, %username ) ◎ If the username argument is not null, set the username given parsedURL and username.
- ~IF[ %password ~NEQ ~NULL ] ⇒ `~URLの~passwordを設定する$( %構文解析した~URL, %password ) ◎ If the password argument is not null, set the password given parsedURL and password.
-
~IF[ 次がいずれも満たされる ]…:
- %async ~EQ ~F
- `現在の大域~obj$は `Window$I ~objである
- [ コレの`制限時間$xhr ~NEQ 0 ]~OR[ コレの`応答~種別$xhr ~NEQ 空~文字列 ]
…ならば ⇒ ~THROW `InvalidAccessError$E
◎ If async is false, the current global object is a Window object, and either this’s timeout is not 0 or this’s response type is not the empty string, then throw an "InvalidAccessError" DOMException. -
コレが演算している進行中の`~fetchを終了させる$ ◎ Terminate the ongoing fetch operated by the XMLHttpRequest object.
注記: この時点から,`~fetching$は進行中になり得るようになる。 ◎ A fetch can be ongoing at this point.
-
コレの ⇒# `~send_~flag$xhr ~SET ~F, `~upload~listener~flag$xhr ~SET ~F, `要請~method$xhr ~SET %method, `要請~URL$xhr ~SET %構文解析した~URL, `同期~flag$xhr ~SET [ %async ~EQ ~F ならば ~T / ~ELSE_ ~F ], `応答$xhr ~SET `~network~error$, `受信した~byte列$xhr ~SET 空~byte列, `応答~obj$xhr ~SET ~NULL ◎ Set variables associated with the object as follows: • Unset this’s send() flag. • Unset this’s upload listener flag. • Set this’s request method to method. • Set this’s request URL to parsedURL. • Set this’s synchronous flag if async is false; otherwise unset this’s synchronous flag. • Empty this’s author request headers. • Set this’s response to a network error. • Set this’s received bytes to the empty byte sequence. • Set this’s response object to null.
注記: `上書き~MIME型$xhrは、ここでは上書きされない — `open()^m ~methodより前に `overrideMimeType()$m ~methodが呼出されることもあるので。 ◎ Override MIME type is not overridden here as the overrideMimeType() method can be invoked before the open() method.
- コレの`作者~要請~header~list$xhrを空にする ◎ ↑
-
~IF[ コレの`状態$xhr ~NEQ `~openした^i ]: ◎ If this’s state is not opened, then:
- コレの`状態$xhr ~SET `~openした^i ◎ Set this’s state to opened.
- コレに向けて,名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange at this.
◎ (和訳には不要なメタ情報) The reason there are two open() methods defined is due to a limitation of the editing software used to write the XMLHttpRequest Standard.
3.5.2. `setRequestHeader()^m ~method
- %client . `setRequestHeader(name, value)$m
-
`作者~要請~header~list$xhrの中で,所与の %name の`~header$に %value を結合する ◎ Combines a header in author request headers.
- 次のいずれかが満たされる場合、 `InvalidStateError$E 例外が投出される ⇒# `状態$xhr ~NEQ `~openした^i / `~send_~flag$xhr ~EQ ~T ◎ Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
- 次のいずれかが満たされる場合、 `SyntaxError$E 例外が投出される ⇒# %name は~header名でない/ %value は~header値でない ◎ Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value.
`setRequestHeader(name, value)@m ~method手続きは: ◎ The setRequestHeader(name, value) method must run these steps:
- ~IF[ コレの`状態$xhr ~NEQ `~openした^i ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s state is not opened, then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`~send_~flag$xhr ~EQ ~T ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s send() flag is set, then throw an "InvalidStateError" DOMException.
- %value ~SET `値を正規化する$( %value ) ◎ Normalize value.
-
~IF[ %name は`名前$hdでない ]~OR[ %value は`値$hdでない ] ⇒ ~THROW `SyntaxError$E ◎ If name is not a name or value is not a value, then throw a "SyntaxError" DOMException.
注記: 空~byte列は空な`~header$ `値$hdを表現する。 ◎ An empty byte sequence represents an empty header value.
- ~IF[ %name は`禁止~header名$である ] ⇒ ~RET ◎ If name is a forbidden header name, then return.
- コレの`作者~要請~header~list$xhr内で`~headerを結合する$( %name / %value ) ◎ Combine name/value in this’s author request headers.
同じ~headerを重ねて設定した場合に何が起こるかデモるための,単純な~code: ◎ Some simple code demonstrating what happens when setting the same header twice: ◎ // The following script:
var %client = new XMLHttpRequest(); %client.open('GET', 'demo.cgi'); %client.setRequestHeader('X-Test', 'one'); %client.setRequestHeader('X-Test', 'two'); %client.send();
この~scriptによる結果、次の~headerが送信される: ◎ // …results in the following header being sent:
X-Test: one, two
3.5.3. `timeout^m 取得子/設定子
- %client . `timeout$m
- 時間を~milli秒~~単位で設定できる。 0 でない値に設定された場合、所与の時間が経過した時点で,`~fetching$は終了させられる。 その時点で要請がまだ完了していない場合、コレの`同期~flag$xhrが[ ~F ならば `timeout$et ~eventが`配送-$される/ ~T ならば `TimeoutError$E 例外が投出される ]ことになる( `send()$m ~methodに対して)。 ◎ Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and this’s synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method).
- 設定子は、次が満たされている下では, `InvalidAccessError$E 例外を投出する ⇒ [ `同期~flag$xhr ~EQ ~T ]~AND[ `現在の大域~obj$は `Window$I ~objである ] ◎ When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
`timeout$m 設定子~手続きは: ◎ The timeout setter steps are:
- ~IF[ `現在の大域~obj$は `Window$I ~objである ]~AND[ コレの`同期~flag$xhr ~EQ ~T ] ⇒ ~THROW `InvalidAccessError$E ◎ If the current global object is a Window object and this’s synchronous flag is set, then throw an "InvalidAccessError" DOMException.
- コレの`制限時間$xhr ~SET 所与の値 ◎ Set this’s timeout to the given value.
注記: これにより,`~fetching$が進捗~中にある間でも、 `timeout$m 属性を設定-可能になる。 設定しても、計測の起点( `~fetching$が開始された時点)が改められることはない。 ◎ This implies that the timeout attribute can be set while fetching is in progress. If that occurs it will still be measured relative to the start of fetching.
3.5.4. `withCredentials^m 取得子/設定子
- %client . `withCredentials$m
- `資格証$が非同一-生成元~要請に含められることになるときは ~T。 非同一-生成元~要請から除外され,その応答における~cookieは無視されることになるときは ~F。 初期~時は ~F 。 ◎ True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false.
- 設定子は、次のいずれかが満たされる下では, `InvalidStateError$E 例外を投出する ⇒# `状態$xhr ~NIN { `未送信^i, `~openした^i } / `~send_~flag$xhr ~EQ ~T ◎ When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set.
`withCredentials$m 設定子~手続きは: ◎ The withCredentials setter steps are:
- ~IF[ コレの`状態$xhr ~NIN { `未送信^i, `~openした^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s state is not unsent or opened, then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`~send_~flag$xhr ~EQ ~T ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s send() flag is set, then throw an "InvalidStateError" DOMException.
- コレの`非同一-生成元~向け資格証あり?$xhr ~SET 所与の値 ◎ Set this’s cross-origin credentials to the given value.
3.5.5. `upload^m 取得子
- %client . `upload$m
- 結付けられている `XMLHttpRequestUpload$I ~objを返す。 これを利用すれば、~serverへ向けて~dataが転送されるときに,伝送~情報を集めることができる。 ◎ Returns the associated XMLHttpRequestUpload object. It can be used to gather transmission information when data is transferred to a server.
3.5.6. `send()^m ~method
- %client . `send$m([%body = null])
- 要請を起動させる。 %body 引数は、`要請~本体$xhrを供する(もしあれば)。 `要請~method$xhrが `GET$hm や `HEAD$hm の場合、この引数は無視される。 ◎ Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD.
- 次のいずれかが満たされている下では、 `InvalidStateError$E 例外が投出される ⇒# `状態$xhr ~NEQ `~openした^i / `~send_~flag$xhr ~EQ ~T ◎ Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
`send(body)@m ~method手続きは: ◎ The send(body) method steps are:
- ~IF[ コレの`状態$xhr ~NEQ `~openした^i ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s state is not opened, then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`~send_~flag$xhr ~EQ ~T ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s send() flag is set, then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`要請~method$xhr ~IN { `GET$hm, `HEAD$hm } ] ⇒ %body ~SET ~NULL ◎ If this’s request method is `GET` or `HEAD`, then set body to null.
-
~IF[ %body ~NEQ ~NULL ]: ◎ If body is not null, then:
- %抽出された内容~型 ~LET ~NULL ◎ Let extractedContentType be null.
- ~IF[ %body は `Document$I である ] ⇒ コレの`要請~本体$xhr ~SET `~UTF-8符号化する$( `~scalar値~文字列に変換する$( `素片を直列化する$( %body ) ) ) ◎ If body is a Document, then set this’s request body to body, serialized, converted, and UTF-8 encoded.
- ~ELSE ⇒ ( コレの`要請~本体$xhr, %抽出された内容~型 ) ~SET `本体と内容~型を安全に抽出する$( %body ) ◎ Otherwise, set this’s request body and extractedContentType to the result of safely extracting body.
- %元の作者~内容~型 ~LET `~header~listから値を取得する$( コレの`作者~要請~header~list$xhr, `Content-Type^h ) ◎ Let originalAuthorContentType be the result of getting `Content-Type` from this’s author request headers.
-
~IF[ %元の作者~内容~型 ~NEQ ~NULL ]: ◎ If originalAuthorContentType is non-null, then:
-
~IF[ %body は[ `Document$I / `USVString$I ]である ]: ◎ If body is a Document or a USVString, then:
- %内容~型~record ~LET `~byte列から~MIME型を構文解析する$( %元の作者~内容~型 の`値$hd ) ◎ Let contentTypeRecord be the result of parsing originalAuthorContentType.
-
~IF[ %内容~型~record ~NEQ 失敗 ]: ◎ If contentTypeRecord is not failure,\
- %~parameters ~LET %内容~型~record の`~parameters$ ◎ ↓
-
~IF[ %~parameters[ `charset^l ] ~NEQ ε ]~AND[ %~parameters[ `charset^l ] は`~ASCII大小無視$で `UTF-8^l に合致しない ]: ◎ contentTypeRecord’s parameters["charset"] exists, and parameters["charset"] is not an ASCII case-insensitive match for "UTF-8", then:
- %~parameters[ `charset^l ] ~SET `UTF-8^l ◎ Set contentTypeRecord’s parameters["charset"] to "UTF-8".
- `作者~要請~header~list$xhr内で`~headerを設定する$( `Content-Type^h / `~MIME型を~byte列に直列化する$( %内容~型~record ) ) ◎ Let newContentTypeSerialized be the result of serializing contentTypeRecord. ◎ Set `Content-Type`/newContentTypeSerialized in this’s author request headers.
-
-
~ELSE ◎ Otherwise:
- %内容~型 ~LET %body に応じて ⇒# `~HTML文書$であるならば `text/html;charset=UTF-8^bl / `~XML文書$であるならば `application/xml;charset=UTF-8^bl / ~ELSE_ %抽出された内容~型 ◎ If body is an HTML document, set `Content-Type`/`text/html;charset=UTF-8` in this’s author request headers. ◎ Otherwise, if body is an XML document, set `Content-Type`/`application/xml;charset=UTF-8` in this’s author request headers. ◎ Otherwise, if extractedContentType is not null, set `Content-Type`/extractedContentType in this’s author request headers.
- ~IF[ %内容~型 ~NEQ ~NULL ] ⇒ コレの`作者~要請~header~list$xhr内で`~headerを設定する$( `Content-Type^h / %内容~型 ) ◎ ↑
- ~IF[ コレの`~upload~obj$xhrに登録されている~event~listenerは在る ] ⇒ コレの`~upload~listener~flag$xhr ~SET ~T ◎ If one or more event listeners are registered on this’s upload object, then set this’s upload listener flag.
-
%要請 ~LET 次に従って初期化された新たな`要請$: ◎ Let req be a new request, initialized as follows:
- `~method$rq~SET コレの`要請~method$xhr ◎ method • This’s request method.
- `~URL$rq ~SET コレの`要請~URL$xhr ◎ URL • This’s request URL.
- `~header~list$rq ~SET コレの`作者~要請~header~list$xhr ◎ header list • This’s author request headers.
- `非安全~要請~flag$rq ~SET ~T ◎ unsafe-request flag • Set.
- `本体$rq ~SET コレの`要請~本体$xhr ◎ body • This’s request body.
- `~client$rq ~SET コレに`関連な設定群~obj$ ◎ client • This’s relevant settings object.
- `~mode$rq ~SET `cors^l ◎ mode • "cors".
- `~CORS予行~利用~flag$rq ~SET コレの`~upload~listener~flag$xhr ◎ use-CORS-preflight flag • Set if this’s upload listener flag is set.
- `資格証~mode$rq ~SET コレの`非同一-生成元~向け資格証あり?$xhrに応じて ⇒# ~T ならば `include^l / ~F ならば `same-origin^l ◎ credentials mode • If this’s cross-origin credentials is true, then "include"; otherwise "same-origin".
- `~URL資格証~利用~flag$rq ~SET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ コレの`要請~URL$xhrは`資格証を含む$ ◎ use-URL-credentials flag • Set if this’s request URL includes credentials.
- コレの`~upload完了-~flag$xhr ~SET %要請 の`本体$rqに応じて ⇒ ~NULL ならば ~T / ~ELSE_ ~F ◎ Unset this’s upload complete flag. ◎ Unset this’s timed out flag. ◎ If req’s body is null, then set this’s upload complete flag.
- コレの`時間切れ~flag$xhr ~SET ~F ◎ ↑
- コレの`~send_~flag$xhr ~SET ~T ◎ Set this’s send() flag.
-
~IF[ コレの`同期~flag$xhr ~EQ ~F ]: ◎ If this’s synchronous flag is unset, then:
- コレに向けて名前 `loadstart$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadstart at this with 0 and 0.
- ~IF[ コレの`~upload完了-~flag$xhr ~EQ ~F ]~AND[ コレの`~upload~listener~flag$xhr ~EQ ~T ] ⇒ コレの`~upload~obj$xhrに向けて,名前 `loadstart$et の`進捗~eventを発火する$( 0, %要請 の`本体$rqの`総~byte数$bd ) ◎ If this’s upload complete flag is unset and this’s upload listener flag is set, then fire a progress event named loadstart at this’s upload object with 0 and req’s body’s total bytes.
- ~IF[ コレの`状態$xhr ~NEQ `~openした^i ]~OR[ コレの`~send_~flag$xhr ~EQ ~F ] ⇒ ~RET ◎ If this’s state is not opened or this’s send() flag is unset, then return.
- %~upload済み~byte列~長さ ~LET 0 ◎ Let uploadedBytesLength be 0.
-
%要請の本体を処理する ~LET 所与の ( %~byte列~長さ ) に対し,次を走らす手続き: ◎ Let processRequestBody, given a bytesLength, be these steps:
- %~upload済み~byte列~長さ ~INCBY %~byte列~長さ ◎ Increase uploadedBytesLength by bytesLength.
- ~IF[ この手続きが最後に呼出されたときから,まだ およそ 50ms 以上 経過していない ] ⇒ ~RET ◎ If not roughly 50ms have passed since these steps were last invoked, then return.
- ~IF[ コレの`~upload~listener~flag$xhr ~EQ ~T ] ⇒ コレの`~upload~obj$xhrに向けて,名前 `progress$et の`進捗~eventを発火する$( %~upload済み~byte列~長さ, %要請 の`本体$rqの`総~byte数$bd ) ◎ If this’s upload listener flag is set, then fire a progress event named progress at this’s upload object with uploadedBytesLength and req’s body’s total bytes.
注記: この手続きは、新たな~byteが伝送されたときに限り,呼出される。 ◎ These steps are only invoked when new bytes are transmitted.
-
%要請の本体の終端を処理する ~LET 次を走らす手続き: ◎ Let processRequestEndOfBody be these steps:
- コレの`~upload完了-~flag$xhr ~SET ~T ◎ Set this’s upload complete flag.
- ~IF[ コレの`~upload~listener~flag$xhr ~EQ ~T ] ⇒ ~RET ◎ If this’s upload listener flag is unset, then return.
- %長さ ~LET %要請 の`本体$rqの`総~byte数$bd ◎ Let length be req’s body’s total bytes.
- コレの`~upload~obj$xhrに向けて,名前 `progress$et の`進捗~eventを発火する$( %~upload済み~byte列~長さ, %長さ ) ◎ Fire a progress event named progress at this’s upload object with uploadedBytesLength and length.
- コレの`~upload~obj$xhrに向けて,名前 `load$et の`進捗~eventを発火する$( %~upload済み~byte列~長さ, %長さ ) ◎ Fire a progress event named load at this’s upload object with uploadedBytesLength and length.
- コレの`~upload~obj$xhrに向けて,名前 `loadend$et の`進捗~eventを発火する$( %~upload済み~byte列~長さ, %長さ ) ◎ Fire a progress event named loadend at this’s upload object with uploadedBytesLength and length.
-
%応答を処理する ~LET 所与の ( %応答 ) に対し,次を走らす手続き: ◎ Let processResponse, given a response, be these steps:
- コレの`応答$xhr ~SET %応答 ◎ Set this’s response to response.
- `~errorを取扱う$( コレ, %応答 ) ◎ Handle errors for this and this’s response.
- ~IF[ コレの`応答$xhr は`~network~error$である ] ⇒ ~RET ◎ If this’s response is a network error, then return.
- コレの`状態$xhr ~SET `全~headerを受信した^i ◎ Set this’s state to headers received.
- コレに向けて名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange at this.
- ~IF[ コレの`状態$xhr ~NEQ `全~headerを受信した^i ] ⇒ ~RET ◎ If this’s state is not headers received, then return.
- %本体 ~LET %応答 の`本体$rs ◎ ↓
- ~IF[ %本体 ~EQ ~NULL ] ⇒# `本体の終端を取扱う$( コレ, %応答 ); ~RET ◎ If this’s response’s body is null, then run handle response end-of-body for this and this’s response, and then return.
-
%本体~chunkを処理する ~LET 所与の ( %~byte列 ) に対し,次を走らす手続き: ◎ Let processBodyChunk given bytes be these steps:
- コレの`受信した~byte列$xhrに %~byte列 を付加する ◎ Append bytes to this’s received bytes.
- ~IF[ この手続きが前回に呼出されたときから,まだ およそ 50ms 以上 経過していない ] ⇒ ~RET ◎ If not roughly 50ms have passed since these steps were last invoked, then return.
- ~IF[ コレの`状態$xhr ~EQ `全~headerを受信した^i ] ⇒ コレの`状態$xhr ~SET `読込n中^i ◎ If this’s state is headers received, then set this’s state to loading.
-
コレに向けて名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange at this.
注記: コレの`状態$xhrが変化しなくても, `readystatechange$et が余分に発火されるのは、~Web互換性の理由による。 ◎ Web compatibility is the reason readystatechange fires more often than this’s state changes.
- %本体 ~LET コレの`応答$xhrの`本体$rs ◎ ↓
- コレに向けて名前 `progress$et の`進捗~eventを発火する$( コレの`受信した~byte列$xhrの`長さ$byte, %本体 の`総~byte数$bd ) ◎ Fire a progress event named progress at this with this’s received bytes’s length and this’s response’s body’s total bytes.
- %本体の終端を処理する ~LET 次を走らす手続き ⇒ `本体の終端を取扱う$( コレ, コレの`応答$xhr ) ◎ Let processEndOfBody be this step: run handle response end-of-body for this and this’s response.
- %本体~errorを処理する ~LET 次を走らす手続き ⇒ `~errorを取扱う$( コレ, コレの`応答$xhr ) ◎ Let processBodyError be this step: run handle errors for this and this’s response.
- `本体を増分的に読取る$( コレの`応答$xhrの`本体$rs, %本体~chunkを処理する, %本体の終端を処理する, %本体~errorを処理する, コレに`関連な大域~obj$ ) ◎ Incrementally read this’s response’s body, given processBodyChunk, processEndOfBody, processBodyError, and this’s relevant global object.
- %要請 を`~fetchする$ — 次を与える下で ⇒# `要請の本体を処理する$i ~SET %要請の本体を処理する, `要請の本体の終端を処理する$i ~SET %要請の本体の終端を処理する, `応答を処理する$i ~SET %応答を処理する ◎ Fetch req with processRequestBody set to processRequestBody, processRequestEndOfBody set to processRequestEndOfBody, and processResponse set to processResponse.
- %今 ~LET 現時刻 ◎ Let now be the present time.
-
この段は`並列的$に走らす: ◎ Run these steps in parallel:
-
次のいずれかが満たされるまで待機する: ◎ Wait until either\
- %要請 の`~done~flag$rq ~EQ ~T ◎ req’s done flag is set or\
- [ コレの`制限時間$xhr ~NEQ 0 ]~AND[ %今 からコレの`制限時間$xhr ~milli秒~以上~経過した ] ◎ this’s timeout is not 0 and this’s timeout milliseconds have passed since now.
- ~IF[ %要請 の`~done~flag$rq ~EQ ~F ] ⇒# コレの`時間切れ~flag$xhr ~SET ~T; この`~fetchを終了させる$ ◎ If req’s done flag is unset, then set this’s timed out flag and terminate fetching.
-
-
~ELSE ( コレの`同期~flag$xhr ~EQ ~T ): ◎ Otherwise, if this’s synchronous flag is set:
- ~IF[ コレに`関連な設定群~obj$には`担当の文書$enVがあって,それには `sync-xhr$l `特能の利用は許容されて$いない ] ⇒# `本体の終端を取扱う$( コレ, `~network~error$ ); ~RET ◎ If this’s relevant settings object has a responsible document which is not allowed to use the "sync-xhr" feature, then run handle response end-of-body for this and a network error, and then return.
- %応答 ~LET `~network~error$ ◎ Let response be a network error.
- %応答は処理した? ~LET ~F ◎ Let processedResponse be false.
-
%応答の本体の終端を処理する ~LET 所与の ( %~fetch応答, %~NULLまたは失敗または~byte列 ) に対し,次を走らす手続き: ◎ Let processResponseEndOfBody, given a fetchResponse and nullOrFailureOrBytes, be these steps:
- %応答 ~SET %~fetch応答 ◎ Set response to fetchResponse.
- ~IF[ %~NULLまたは失敗または~byte列 は`~byte列$である ] ⇒ コレの`受信した~byte列$xhrに %~NULLまたは失敗または~byte列 を付加する ◎ If nullOrFailureOrBytes is a byte sequence, then append nullOrFailureOrBytes to this’s received bytes.
- %応答は処理した? ~SET ~T ◎ Set processedResponse to true.
- %要請 を`~fetchする$ — 次を与える下で ⇒# `応答の本体の終端を処理する$i ~SET %応答の本体の終端を処理する, `並列~queueを利用する?$i ~SET ~T ◎ Fetch req with processResponseEndOfBody set to processResponseEndOfBody and useParallelQueue set to true.
- %今 ~LET 現時刻 ◎ Let now be the present time.
-
次のいずれかが満たされるまで`静止する$: ◎ Pause until either\
- %応答は処理した? ~EQ ~T ◎ processedResponse is true or\
- [ コレの`制限時間$xhr ~NEQ 0 ]~AND[ %今 からコレの`制限時間$xhr ~milli秒~以上~経過した ] ◎ this’s timeout is not 0 and this’s timeout milliseconds have passed since now.
- ~IF[ %応答は処理した? ~EQ ~F ] ⇒# コレの`時間切れ~flag$xhr ~SET ~T; この`~fetchを終了させる$ ◎ If processedResponse is false, then set this’s timed out flag and terminate fetching.
- `本体の終端を取扱う$( コレ, %応答 ) ◎ Run handle response end-of-body for this and response.
`本体の終端を取扱う@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr, `応答$ %応答 ) に対し,次を走らす: ◎ To handle response end-of-body for an XMLHttpRequest object xhr and a response response, run these steps:
- ~IF[ %xhr の`同期~flag$xhr ~EQ ~T ] ⇒ %xhr の`応答$xhr ~SET %応答 ◎ If xhr’s synchronous flag is set, then set xhr’s response to response.
- `~errorを取扱う$( %xhr, %応答 ) ◎ Handle errors for xhr and response.
- ~IF[ %xhr の`応答$xhrは`~network~error$である ] ⇒ ~RET ◎ If xhr’s response is a network error, then return.
- ~IF[ %xhr の`同期~flag$xhr ~EQ ~F ] ⇒ %応答 を利用して %xhr の`応答$xhrの`本体$rsを更新する ◎ If xhr’s synchronous flag is unset, then update xhr’s response’s body using response.
- %伝送量 ~LET %xhr の`受信した~byte列$xhrの`長さ$byte ◎ Let transmitted be xhr’s received bytes’s length.
- %長さ ~LET %応答 の`本体$rsの`総~byte数$bd ◎ Let length be response’s body’s total bytes.
- ~IF[ %xhr の`同期~flag$xhr ~EQ ~F ] ⇒ %xhr に向けて名前 `progress$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ If xhr’s synchronous flag is unset, then fire a progress event named progress at xhr with transmitted and length.
- %xhr の`状態$xhr ~SET `済み^i ◎ Set xhr’s state to done.
- %xhr の`~send_~flag$xhr ~SET ~F ◎ Unset xhr’s send() flag.
- %xhr に向けて名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange at xhr.
- %xhr に向けて名前 `load$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named load at xhr with transmitted and length.
- %xhr に向けて名前 `loadend$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named loadend at xhr with transmitted and length.
`~errorを取扱う@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr, `応答$ %応答 ) に対し,次を走らす: ◎ To handle errors for an XMLHttpRequest object xhr and a response response, run these steps:
- ~IF[ %xhr の`~send_~flag$xhr ~EQ ~F ] ⇒ ~RET ◎ If xhr’s send() flag is unset, then return.
- ~IF[ %xhr の`時間切れ~flag$xhr ~EQ ~T ] ⇒ `要請~error手続きを走らす$( %xhr, `timeout$et, `TimeoutError$E 例外 ) ◎ If xhr’s timed out flag is set, then run the request error steps for xhr, timeout, and "TimeoutError" DOMException.
- ~IF[ %応答 は`~network~error$である ] ⇒ `要請~error手続きを走らす$( %xhr, `error$et, `NetworkError$E 例外 ) ◎ If response is a network error, then run the request error steps for xhr, error, and "NetworkError" DOMException.
-
~ELIF[ %応答 の`本体$rsの`~stream$bdは`~errorした$RS ]: ◎ Otherwise, if response’s body’s stream is errored, then:
- %xhr の`状態$xhr ~SET `済み^i ◎ Set xhr’s state to done.
- %xhr の`~send_~flag$xhr ~SET ~F ◎ Unset xhr’s send() flag.
- %xhr の`応答$xhr ~SET `~network~error$ ◎ Set xhr’s response to a network error.
- ~ELIF[ %xhr の`応答$xhrの`中止~flag$rs ~EQ ~T ] ⇒ `要請~error手続きを走らす$( %xhr, `abort$et, `AbortError$E 例外 ) ◎ Otherwise, if xhr’s response’s aborted flag is set, then run the request error steps for xhr, abort, and "AbortError" DOMException.
`要請~error手続きを走らす@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr, %~event型, %例外(省略時は ε )) に対し,次を走らす: ◎ The request error steps for an XMLHttpRequest object xhr, event, and optionally exception are:
- %xhr の`状態$xhr ~SET `済み^i ◎ Set xhr’s state to done.
- %xhr の`~send_~flag$xhr ~SET ~F ◎ Unset xhr’s send() flag.
- %xhr の`応答$xhr ~SET `~network~error$ ◎ Set xhr’s response to a network error.
-
~IF[ %xhr の`同期~flag$xhr ~EQ ~T ]:
- ~Assert: %例外 ~NEQ ε 【この段は、この訳による補完。】
- ~THROW %例外
-
%xhr に向けて名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange at xhr.
注記: この時点で明らかに %xhr の`同期~flag$xhr ~EQ ~F ◎ At this point it is clear that xhr’s synchronous flag is unset.
-
~IF[ %xhr の`~upload完了-~flag$xhr ~EQ ~F ]: ◎ If xhr’s upload complete flag is unset, then:
- %xhr の`~upload完了-~flag$xhr ~SET ~T ◎ Set xhr’s upload complete flag.
-
~IF[ %xhr の`~upload~listener~flag$xhr ~EQ ~T ]: ◎ If xhr’s upload listener flag is set, then:
- %xhr の`~upload~obj$xhrに向けて,名前 %~event型 の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named event at xhr’s upload object with 0 and 0.
- %xhr の`~upload~obj$xhrに向けて,名前 `loadend$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadend at xhr’s upload object with 0 and 0.
- %xhr に向けて名前 %~event型 の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named event at xhr with 0 and 0.
- %xhr に向けて名前 `loadend$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadend at xhr with 0 and 0.
3.5.7. `abort()^m ~method
- %client . `abort()$m
- ~network活動をすべて取消す。 ◎ Cancels any network activity.
`abort()@m ~method手続きは: ◎ The abort() method steps are:
- 進行中の`~fetchを終了させる$( `中止する^i ) ◎ Terminate the ongoing fetch with the aborted flag set.
- ~IF[[ コレの`状態$xhr ~EQ `~openした^i ]~AND[ コレの`~send_~flag$xhr ~EQ ~T ]]~OR[ コレの`状態$xhr ~IN { `全~headerを受信した^i, `読込n中^i } ] ⇒ `要請~error手続きを走らす$( コレ, `abort$et ) ◎ If this’s state is opened with this’s send() flag set, headers received, or loading, then run the request error steps for this and abort.
-
~IF[ コレの`状態$xhr ~EQ `済み^i ] ⇒ コレの`状態$xhr ~SET `未送信^i; コレの`応答$xhr ~SET `~network~error$ ◎ If this’s state is done, then set this’s state to unsent and this’s response to a network error.
注記: `readystatechange$et ~eventは配送されない。 ◎ No readystatechange event is dispatched.
3.6. 応答
3.6.1. `responseURL^m 取得子
`responseURL@m 取得子~手続きは:
- %url ~LET `応答$xhrの`~URL$rs
- ~IF[ %url ~EQ ~NULL ] ⇒ ~RET 空~文字列
- ~RET `~URLを直列化する$( %url, `素片は除外する^i )
3.6.2. `status^m 取得子
3.6.3. `statusText^m 取得子
3.6.4. `getResponseHeader()^m ~method
`getResponseHeader(name)@m ~method手続きは ⇒ ~RET `~header~listから値を取得する$( コレの`応答$xhrの`~header~list$rs, %name ) ◎ The getResponseHeader(name) method steps are to return the result of getting name from this’s response’s header list.
注記: コレの`応答$xhrに公開される`~header~list$rsは、 Fetch 標準に従って,絞込まれる。 `FETCH$r ◎ The Fetch Standard filters this’s response’s header list. [FETCH]
次の~scriptにおいては: ◎ For the following script:
var %client = new XMLHttpRequest(); %client.open("GET", "unicorns-are-awesome.txt", true); %client.send(); %client.onreadystatechange = function() { if(this.readyState == this.HEADERS_RECEIVED) { print(%client.getResponseHeader("Content-Type")); } }
`print()^c 関数は、次と同様の結果を得ることになる: ◎ The print() function will get to process something like:
text/plain; charset=UTF-8
3.6.5. `getAllResponseHeaders()^m ~method
`getAllResponseHeaders()@m ~method手続きは: ◎ ↓↓A byte sequence a is legacy-uppercased-byte less than a byte sequence b if the following steps return true: • Let A be a, byte-uppercased. • Let B be b, byte-uppercased. • Return A is byte less than B. ◎ The getAllResponseHeaders() method steps are:
- %出力 ~LET 空~byte列 ◎ Let output be an empty byte sequence.
- %初期~header~list ~LET `~header~listを~sortして結合する$( コレの`応答$xhrの`~header~list$rs ) ◎ Let initialHeaders be the result of running sort and combine with this’s response’s header list.
-
%~header~list ~LET `~listを昇順に~sortする$( %初期~header~list, 次に与える`小なり~algo$ ) ⇒ 小なり~algoは、所与の 2 つの~header ( %a, %b ) に対し ⇒ ~RET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ `~byte大文字~化する$( %a の`名前$hd ) は `~byte大文字~化する$( %b の`名前$hd ) `未満の~byte列$である ◎ Let headers be the result of sorting initialHeaders in ascending order,\ with a being less than b if a’s name is legacy-uppercased-byte less than b’s name.
注記: あいにく,この段は、配備-済み内容との互換性を得るため必要になる。 ◎ Unfortunately, this is needed for compatibility with deployed content.
-
%~header~list 内の~EACH( %~header ) に対し ⇒ %出力 に次を順に付加する ⇒# %~header の`名前$hd, ~byte対 `3A^X `20^X, %~header の`値$hd, ~byte対 `0D^X `0A^X ◎ For each header in headers, append header’s name, followed by a 0x3A 0x20 byte pair, followed by header’s value, followed by a 0x0D 0x0A byte pair, to output.
- ~RET %出力 ◎ Return output.
注記: コレの`応答$xhrに公開される`~header~list$rsは、 Fetch 標準に従って,絞込まれる。 `FETCH$r ◎ The Fetch Standard filters this’s response’s header list. [FETCH]
次の~scriptに対し: ◎ For the following script:
var %client = new XMLHttpRequest(); %client.open("GET", "narwhals-too.txt", true); %client.send(); %client.onreadystatechange = function() { if(this.readyState == this.HEADERS_RECEIVED) { print(this.getAllResponseHeaders()); } }
`print()^c 関数は、次と同類の結果を得ることになる: ◎ The print() function will get to process something like:
connection: Keep-Alive content-type: text/plain; charset=utf-8 date: Sun, 24 Oct 2004 04:58:38 GMT keep-alive: timeout=15, max=99 server: Apache/1.3.31 (Unix) transfer-encoding: chunked
3.6.6. 応答~本体
`応答~MIME型を取得する@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr ) に対し,次を走らす: ◎ To get a response MIME type for an XMLHttpRequest object xhr, run these steps:
- %~MIME型 ~LET `~header~listから~MIME型を抽出する$( %xhr の`応答$xhrの`~header~list$rs ) ◎ Let mimeType be the result of extracting a MIME type from xhr’s response’s header list.
- ~IF[ %~MIME型 ~EQ `失敗^i ] ⇒ %~MIME型 ~SET `text/xml^c 【 `~MIME型を構文解析する$( `text/xml^l ) 】 ◎ If mimeType is failure, then set mimeType to text/xml.
- ~RET %~MIME型 ◎ Return mimeType.
`最終-~MIME型を取得する@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr ) に対し,次を走らす: ◎ To get a final MIME type for an XMLHttpRequest object xhr, run these steps:
- %上書き~MIME型 ~LET %xhr の`上書き~MIME型$xhr ◎ ↓
- ~IF[ %上書き~MIME型 ~EQ ~NULL ] ⇒ ~RET `応答~MIME型を取得する$( %xhr ) ◎ If xhr’s override MIME type is null, return the result of get a response MIME type for xhr.
- ~RET %上書き~MIME型 ◎ Return xhr’s override MIME type.
`最終-符号化法を取得する@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr ) に対し,次を走らす: ◎ To get a final encoding for an XMLHttpRequest object xhr, run these steps:
- %~label ~LET ε ◎ Let label be null.
- ~IF[ %xhr の`上書き~MIME型$xhr ~NEQ ~NULL ] ⇒ %~label ~SET %xhr の`上書き~MIME型$xhrの`~parameters$[ `charset^l ] ◎ ↓
- ~IF[ %~label ~EQ ε ] ⇒ %~label ~SET 次の結果の`~parameters$[ `charset^l ] ⇒ `応答~MIME型を取得する$( %xhr ) ◎ Let responseMIME be the result of get a response MIME type for xhr. ◎ If responseMIME’s parameters["charset"] exists, then set label to it. ◎ If xhr’s override MIME type’s parameters["charset"] exists, then set label to it.
- ~IF[ %~label ~EQ ε ] ⇒ ~RET ~NULL ◎ If label is null, then return null.
- %符号化法 ~LET `~labelから符号化法を取得する$( %~label ) ◎ Let encoding be the result of getting an encoding from label.
- ~RET %符号化法 に応じて ⇒# `失敗^i ならば ~NULL/ ~ELSE_ %符号化法 ◎ If encoding is failure, then return null. ◎ Return encoding.
注記: 上の手続きが`最終-~MIME型を取得する$を利用しないのは、意図的である — そうすると~web互換でなくなるので。 ◎ The above steps intentionally do not use the get a final MIME type as it would not be web compatible.
`文書~応答を設定する@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr ) に対し,次を走らす: ◎ To set a document response for an XMLHttpRequest object xhr, run these steps:
- ~IF[ %xhr の`応答$xhrの`本体$rs ~EQ ~NULL, ] ⇒ ~RET ◎ If xhr’s response’s body is null, then return.
- %charset ~LET ~NULL 【この段は、この訳による補完。】
- %最終-~MIME型 ~LET `最終-~MIME型を取得する$( %xhr ) ◎ Let finalMIME be the result of get a final MIME type for xhr.
-
%最終-~MIME型 に応じて: ◎ ↓↓If finalMIME is not an HTML MIME type or an XML MIME type, then return.
-
`~HTML~MIME型$である: ◎ ↓
-
~IF[ %xhr の`応答~種別$xhr ~EQ 空~文字列 ] ⇒ ~RET ◎ If xhr’s response type is the empty string and\ finalMIME is an HTML MIME type, then return.
注記: 旧来の内容を壊さないようにするため、 %xhr の`応答~種別$xhrは,ここでは `document^l に制約される。 ◎ This is restricted to xhr’s response type being "document" in order to prevent breaking legacy content.
- %charset ~SET `最終-符号化法を取得する$( %xhr ) ◎ ↑If finalMIME is an HTML MIME type, then: ◎ Let charset be the result of get a final encoding for xhr.
- ~IF[ %charset ~EQ ~NULL ] ⇒ ~IF[ %xhr の`受信した~byte列$xhrの最初の 1024 ~byteを 予走査して 成功裡に結果を得られた ] ⇒ %charset ~LET その結果 ◎ If charset is null, prescan the first 1024 bytes of xhr’s received bytes and if that does not terminate unsuccessfully then let charset be the return value.
- ~IF[ %charset ~EQ ~NULL ] ⇒ %charset ~SET `~UTF-8$ ◎ If charset is null, then set charset to UTF-8.
- %文書 ~LET 次の結果を表現する`文書$ ⇒ ~HTML標準の~HTML構文解析器に~~規定される規則に従って,[ ~scriptは不能化する, 既知かつ確定的な符号化法として %charset を与える ]下で, %xhr の`受信した~byte列$xhrを構文解析した結果 `HTML$r ◎ Let document be a document that represents the result parsing xhr’s received bytes following the rules set forth in the HTML Standard for an HTML parser with scripting disabled and a known definite encoding charset. [HTML]
- %文書 の`種別$doc ~SET `html^l ◎ Flag document as an HTML document.
-
-
`~XML~MIME型$である ⇒ %文書 ~LET 次の結果を表現する`文書$ ⇒ ~XML~scripting~supportを不能化する下で, %xhr の`受信した~byte列$xhrを ~XML構文解析器 にかけた結果 `HTML$r ⇒ ~IF[ 構文解析に失敗した(例:未~supportな文字~符号化法, 名前空間整形式~error, 等々) ] ⇒ ~RET ~NULL ◎ Otherwise, let document be a document that represents the result of running the XML parser with XML scripting support disabled on xhr’s received bytes. If that fails (unsupported character encoding, namespace well-formedness error, etc.), then return null. [HTML]
注記: 文書から参照されている資源は読込まれず,文書に結付けられている~XSLTは適用されない。 ◎ Resources referenced will not be loaded and no associated XSLT will be applied.
- その他~MIME型 ⇒ ~RET ◎ ↑↑
-
- ~IF[ %charset ~EQ ~NULL ] ⇒ %charset ~SET `~UTF-8$ ◎ If charset is null, then set charset to UTF-8.
- %文書 の ⇒# `符号化法$doc ~SET %charset, `内容~型$doc ~SET %最終-~MIME型, `~URL$doc ~SET %xhr の`応答$xhrの`~URL$rs, `生成元$doc ~SET %xhr に`関連な設定群~obj$の`生成元$enV ◎ Set document’s encoding to charset. ◎ Set document’s content type to finalMIME. ◎ Set document’s URL to xhr’s response’s URL. ◎ Set document’s origin to xhr’s relevant settings object’s origin.
- %xhr の`応答~obj$xhr ~SET %文書 ◎ Set xhr’s response object to document.
`~text応答を取得する@ ときは、所与の ( `XMLHttpRequest$I ~obj %xhr ) に対し,次を走らす: ◎ To get a text response for an XMLHttpRequest object xhr, run these steps:
- ~IF[ %xhr の`応答$xhrの`本体$rs ~EQ ~NULL ] ⇒ ~RET 空~文字列 ◎ If xhr’s response’s body is null, then return the empty string.
- %charset ~LET `最終-符号化法を取得する$( %xhr ) ◎ Let charset be the result of get a final encoding for xhr.
-
~IF[ %xhr の`応答~種別$xhr ~EQ 空~文字列 ]~AND[ %charset ~EQ ~NULL ]: ◎ If xhr’s response type is the empty string, charset is null,\
- %最終-~MIME型 ~LET `最終-~MIME型を取得する$( %xhr ) ◎ and the result of get a final MIME type for xhr\
- ~IF[ %最終-~MIME型 は`~XML~MIME型$である ] ⇒ %charset ~LET ~XML仕様に~~規定される規則に従って決定される符号化法 `XML$r `XML-NAMES$r ◎ is an XML MIME type, then use the rules set forth in the XML specifications to determine the encoding. Let charset be the determined encoding. [XML] [XML-NAMES]
注記: 旧来のものでない`応答~種別$xhr用の値 `text^l を単純なままに保つため、 %xhr の`応答~種別$xhrは,ここでは空~文字列に制約される。 ◎ This is restricted to xhr’s response type being the empty string to keep the non-legacy response type value "text" simple.
- ~IF[ %charset ~EQ ~NULL ] ⇒ %charset ~SET `~UTF-8$ ◎ If charset is null, then set charset to UTF-8.
- ~RET `~Unicodeに復号する$( %xhr の`受信した~byte列$xhr, %charset ) ◎ Return the result of running decode on xhr’s received bytes using fallback encoding charset.
注記: 作者には、資源を符号化する際には,常に`~UTF-8$を利用することが強く奨励される。 ◎ Authors are strongly encouraged to always encode their resources using UTF-8.
3.6.7. `overrideMimeType()^m ~method
- %client . `overrideMimeType(mime)$m
- 応答の `Content-Type$h ~header値が %mime であったかのように動作する(その~headerを変更することなく)。 ◎ Acts as if the `Content-Type` header value for a response is mime. (It does not change the header.)
- 次が満たされている下では、 `InvalidStateError$E 例外が投出される ⇒ `状態$xhr ~IN { `読込n中^i, `済み^i } ◎ Throws an "InvalidStateError" DOMException if state is loading or done.
`overrideMimeType(mime)@m ~method手続きは: ◎ The overrideMimeType(mime) method steps are:
- ~IF[ コレの`状態$xhr ~IN { `読込n中^i, `済み^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s state is loading or done, then throw an "InvalidStateError" DOMException.
- コレの`上書き~MIME型$xhr ~SET `~MIME型を構文解析する$( %mime ) ◎ Set this’s override MIME type to the result of parsing mime.
- ~IF[ コレの`上書き~MIME型$xhr ~EQ `失敗^i ] ⇒ コレの`上書き~MIME型$xhr ~SET `application/octet-stream^bl ◎ If this’s override MIME type is failure, then set this’s override MIME type to application/octet-stream.
3.6.8. `responseType^m 取得子/設定子
- %client . `responseType$m [ = %value ]
- 応答の種別を返す。 ◎ Returns the response type.
- 設定して、応答の種別を変更できる。 値は次のいずれか ⇒ 空~文字列 (既定), `arraybuffer^l, `blob^l, `document^l, `json^l, `text^l ◎ Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
-
設定子においては: ◎ ↓
- `現在の大域~obj$は `Window$I ~objでない場合、 `document^l に設定しても無視される。 ◎ When set: setting to "document" is ignored if current global object is not a Window object.
- 次が満たされている下では、 `InvalidStateError$E 例外が投出される ⇒ `状態$xhr ~IN { `読込n中^i, `済み^i } ◎ When set: throws an "InvalidStateError" DOMException if state is loading or done.
- 次が満たされている下では、 `InvalidAccessError$E 例外が投出される ⇒ [ `同期~flag$xhr ~EQ ~T ]~AND[ `現在の大域~obj$は `Window$I ~objである ] ◎ When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
`responseType$m 設定子~手続きは: ◎ The responseType setter steps are:
- %W ~LET [ `現在の大域~obj$は `Window$I ~objであるならば ~T / ~ELSE_ ~F ] ◎ ↓
- ~IF[ %W ~EQ ~F ]~AND[ 所与の値 ~EQ `document^l ] ⇒ ~RET ◎ If the current global object is not a Window object and the given value is "document", then return.
- ~IF[ コレの`状態$xhr ~IN { `読込n中^i, `済み^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s state is loading or done, then throw an "InvalidStateError" DOMException.
- ~IF[ %W ~EQ ~T ]~AND[ コレの`同期~flag$xhr ~EQ ~T ] ⇒ ~THROW `InvalidAccessError$E ◎ If the current global object is a Window object and this’s synchronous flag is set, then throw an "InvalidAccessError" DOMException.
- コレの`応答~種別$xhr ~SET 所与の値 ◎ Set this’s response type to the given value.
3.6.9. `response^m 取得子
- %client . `response$m
- 応答の本体を返す。 ◎ Returns the response body.
`response@m 取得子~手続きは: ◎ The response getter steps are:
-
~IF[ コレの`応答~種別$xhr ~IN { 空~文字列, `text^l } ]: ◎ If this’s response type is the empty string or "text", then:
- ~IF[ コレの`状態$xhr ~NIN { `読込n中^i, `済み^i } ] ⇒ ~RET 空~文字列 ◎ If this’s state is not loading or done, then return the empty string.
- ~RET `~text応答を取得する$( コレ ) ◎ Return the result of getting a text response for this.
- ~IF[ コレの`状態$xhr ~NEQ `済み^i ] ⇒ ~RET ~NULL ◎ If this’s state is not done, then return null.
- ~IF[ コレの`応答~obj$xhr ~EQ `失敗^i ] ⇒ ~RET ~NULL ◎ If this’s response object is failure, then return null.
- ~IF[ コレの`応答~obj$xhr ~NEQ ~NULL ] ⇒ ~RET コレの`応答~obj$xhr ◎ If this’s response object is non-null, then return it.
-
コレの`応答~種別$xhrに応じて: ◎ ↓
- `arraybuffer^l ◎ If this’s response type is "arraybuffer", then\
- コレの`応答~obj$xhr ~SET コレの`受信した~byte列$xhrを表現する,`新たな$ `ArrayBuffer$I ~obj ◎ set this’s response object to a new ArrayBuffer object representing this’s received bytes.\
- 例外が投出されたときは ⇒# コレの`応答~obj$xhr ~SET `失敗^i; ~RET ~NULL ◎ If this throws an exception, then set this’s response object to failure and return null.
- 注記: `ArrayBuffer$I ~objを割振ることの成功-は、保証されない。 `ECMASCRIPT$r ◎ Allocating an ArrayBuffer object is not guaranteed to succeed. [ECMASCRIPT]
- `blob^l ◎ Otherwise, if this’s response type is "blob",\
- コレの`応答~obj$xhr ~SET 次のようにされた,コレの`受信した~byte列$xhrを表現する`新たな$ `Blob$I ~obj ⇒ `~type0$m ~SET `最終-~MIME型を取得する$( コレ ) ◎ set this’s response object to a new Blob object representing this’s received bytes with type set to the result of get a final MIME type for this.
- `document^l ◎ Otherwise, if this’s response type is "document",\
- `文書~応答を設定する$( コレ ) ◎ set a document response for this.
- `json^l ◎ Otherwise: ◎ Assert: this’s response type is "json".
-
- ~IF[ コレの`応答$xhrの`本体$rs ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If this’s response’s body is null, then return null.
- %~JSON~obj ~LET `~JSON~byte列を~JS値に構文解析する$( コレの`受信した~byte列$xhr ) ⇒ 例外が投出されたときは ⇒ ~RET ~NULL ◎ Let jsonObject be the result of running parse JSON from bytes on this’s received bytes. If that threw an exception, then return null.
- コレの`応答~obj$xhr ~SET %~JSON~obj ◎ Set this’s response object to jsonObject.
- ~RET コレの`応答~obj$xhr ◎ Return this’s response object.
3.6.10. `responseText^m 取得子
- %client . `responseText$m
- 応答を~textとして返す。 ◎ Returns response as text.
- 次が満たされている下では、 `InvalidStateError$E 例外が投出される ⇒ `応答~種別$xhr【!`responseType$m】 ~NIN { 空~文字列, `text^l } ◎ Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text".
`responseText@m 取得子~手続きは: ◎ The responseText getter steps are:
- ~IF[ コレの`応答~種別$xhr ~NIN { 空~文字列, `text^l } ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s response type is not the empty string or "text", then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`状態$xhr ~NIN { `読込n中^i, `済み^i } ] ⇒ ~RET 空~文字列 ◎ If this’s state is not loading or done, then return the empty string.
- ~RET `~text応答を取得する$( コレ ) ◎ Return the result of getting a text response for this.
3.6.11. `responseXML^m 取得子
- %client . `responseXML$m
- 応答を文書として返す。 ◎ Returns the response as document.
- 次が満たされている下では、 `InvalidStateError$E 例外が投出される ⇒ `応答~種別$xhr【!`responseType$m】 ~NIN { 空~文字列, `document^l } ◎ Throws an "InvalidStateError" DOMException if responseType is not the empty string or "document".
`responseXML@m 取得子~手続きは: ◎ The responseXML getter steps are:
- ~IF[ コレの`応答~種別$xhr ~NIN { 空~文字列, `document^l } ] ⇒ ~THROW `InvalidStateError$E ◎ If this’s response type is not the empty string or "document", then throw an "InvalidStateError" DOMException.
- ~IF[ コレの`状態$xhr ~NEQ `済み^i ] ⇒ ~RET ~NULL ◎ If this’s state is not done, then return null.
- ~Assert: コレの`応答~obj$xhr ~NEQ `失敗^i ◎ Assert: this’s response object is not failure.
- ~IF[ コレの`応答~obj$xhr ~NEQ ~NULL ] ⇒ ~RET コレの`応答~obj$xhr ◎ If this’s response object is non-null, then return it.
- `文書~応答を設定する$( コレ ) ◎ Set a document response for this.
- ~RET コレの`応答~obj$xhr ◎ Return this’s response object.
3.7. ~event要覧
~INFORMATIVE以下の~eventが[ `XMLHttpRequest$I / `XMLHttpRequestUpload$I ]~objに向けて配送される: ◎ The following events are dispatched on XMLHttpRequest or XMLHttpRequestUpload objects:
~event名 ◎ Event name | ~interface ◎ Interface | 配送-時機 ◎ Dispatched when… |
---|---|---|
`readystatechange@et | `Event$I | `readyState$m 属性の値が変化したとき。 ただし, `UNSENT$m に変化したときは除く。 ◎ The readyState attribute changes value, except when it changes to UNSENT. |
`loadstart@et | `ProgressEvent$I | ~fetchが起動されたとき。 ◎ The fetch initiates. |
`progress@et | `ProgressEvent$I | ~dataを伝送-中のとき。 ◎ Transmitting data. |
`abort@et | `ProgressEvent$I | ~fetchが中止されたとき。 例えば, `abort()$m ~methodの呼出ngなど。 ◎ When the fetch has been aborted. For instance, by invoking the abort() method. |
`error@et | `ProgressEvent$I | ~fetchに失敗したとき。 ◎ The fetch failed. |
`load@et | `ProgressEvent$I | ~fetchに成功したとき。 ◎ The fetch succeeded. |
`timeout@et | `ProgressEvent$I | ~fetchが完了する前に `timeout$m に指定される時間を過ぎたとき。 ◎ The author specified timeout has passed before the fetch completed. |
`loadend@et | `ProgressEvent$I | ~fetchが完了したとき(成功, 失敗, いずれに関わらず)。 ◎ The fetch completed (success or failure). |
3.8. 許可~施策【!特能~施策】の統合
この仕様は、[ 文字列 `sync-xhr@l で識別される,`施策により制御される特能$ ]を定義する。 その`既定の許容list$は `*^c とする。 ◎ This specification defines a policy-controlled feature identified by the string "sync-xhr". Its default allowlist is *.
4. ~interface `FormData^I
typedef (`File$I or `USVString$) `FormDataEntryValue@I; [`Exposed$=(Window,Worker)] interface `FormData@I { `FormData$mc(optional `HTMLFormElement$I %form); `undefined$ `append$m(`USVString$ %name, `USVString$ %value); `undefined$ `append$m(`USVString$ %name, `Blob$I %value, optional `USVString$ %filename); `undefined$ `delete$m(`USVString$ %name); `FormDataEntryValue$I? `get$m(`USVString$ %name); `sequence$<`FormDataEntryValue$I> `getAll$m(`USVString$ %name); `boolean$ `has$m(`USVString$ %name); `undefined$ `set$m(`USVString$ %name, `USVString$ %value); `undefined$ `set$m(`USVString$ %name, `Blob$I %value, optional `USVString$ %filename); `iterable$m<`USVString$, `FormDataEntryValue$I>; };
各 `FormData$I ~objには、 `~entry~list@fe が結付けられる — それは、何個かの`~entry$feからなる`~list$であり,初期~時には空とする。 ◎ Each FormData object has an associated entry list (a list of entries). It is initially the empty list.
各 `~entry@fe は、 `名前@fe, `値@fe からなる。 ◎ An entry consists of a name and a value.
他の~algoとヤリトリする目的においては、`~entry$feの~filenameは[ `~entry$feの`値$feが `File$I ~objであるならば その `name$m 属性~値 / ~ELSE_ 空~文字列 ]とする。 ◎ For the purposes of interaction with other algorithms, an entry’s filename is the empty string if value is not a File object, and otherwise its filename is the value of entry’s value’s name attribute.
`~entryを作成する@ ときは、所与の ( %名前, %値, %~filename (省略-時は ε )) に対し,次を走らす: ◎ To create an entry for name, value, and optionally a filename, run these steps:
- %~entry ~LET 新たな`~entry$fe ◎ Let entry be a new entry.
- %~entry の`名前$fe ~SET %名前 ◎ Set entry’s name to name.
-
~IF[ %値 は `Blob$I ~objである ]~AND[[ %値 は `File$I ~objでない ]~OR[ %~filename ~NEQ ε ]]:
- %値 ~SET %値 と同じ~byte列を表現する新たな `File$I ~obj
- %値 の `name$m 属性~値 ~SET [ %~filename ~NEQ ε ならば %~filename / ~ELSE_ `blob^l ]
- %~entry の`値$fe ~SET %値 ◎ Set entry’s value to value.
- ~RET %~entry ◎ Return entry.
`new FormData(form)@m 構築子~手続きは: ◎ The new FormData(form) constructor steps are:
- ~IF[ %form ~EQ ε ] ⇒ ~RET ◎ If form is given, then:
- %~list ~LET `~entry~listを構築する$( %form ) ◎ Let list be the result of constructing the entry list for form.
- ~IF[ %~list ~EQ ~NULL ] ⇒ ~THROW `InvalidStateError$E ◎ If list is null, then throw an "InvalidStateError" DOMException.
- コレの`~entry~list$fe ~SET ~SET %~list ◎ Set this’s entry list to list.
`append(name, value, filename)@m ~method手続きは: ◎ The append(name, value) and append(name, blobValue, filename) method steps are: • Let value be value if given; otherwise blobValue.
- %~entry ~LET `~entryを作成する$( %name, %value, %filename ) — %filename は与えられていない場合は省略する ◎ Let entry be the result of creating an entry with name, value, and filename if given.
- コレの`~entry~list$feに %~entry を`付加する$ ◎ Append entry to this’s entry list.
◎ (和訳には不要なメタ情報) The reason there is an argument named value as well as blobValue is due to a limitation of the editing software used to write the XMLHttpRequest Standard.
`set(name, value, filename)@m ~method手続きは: ◎ The set(name, value) and set(name, blobValue, filename) method steps are: • Let value be value if given; otherwise blobValue.
- %~entry ~LET `~entryを作成する$( %name, %value, %filename ) — %filename は与えられていない場合は省略する ◎ Let entry be the result of creating an entry with name, value, and filename if given.
-
~IF[ コレの`~entry~list$fe内に次を満たす`~entry$feは在る ]… ⇒ `名前$fe ~EQ %name
…ならば ⇒ 該当する`~entry$feのうち ⇒# 最初のものは %~entry に`置換する$, 他のものはすべて`除去する$
◎ If there are entries in this’s entry list whose name is name, then replace the first such entry with entry and remove the others. - ~ELSE ⇒ コレの`~entry~list$feに %~entry を`付加する$ ◎ Otherwise, append entry to this’s entry list.
◎ (和訳には不要なメタ情報) The reason there is an argument named value as well as blobValue is due to a limitation of the editing software used to write the XMLHttpRequest Standard.
`iterable@m における`反復される値~pairたち$を成す各~pairを成す ( ~key, 値 ) は、コレの`~entry~list$feを成す各`~entry$feの ( `名前$fe, `値$fe ) で与えられるとする。 ◎ The value pairs to iterate over are this’s entry list’s entries with the key being the name and the value being the value.
5. ~interface `ProgressEvent^I
[`Exposed$=(Window,Worker)] interface `ProgressEvent@I : `Event$I { `ProgressEvent@mc(`DOMString$ %type, optional `ProgressEventInit$I %eventInitDict = {}); readonly attribute `boolean$ `lengthComputable$m; readonly attribute `unsigned long long$ `loaded$m; readonly attribute `unsigned long long$ `total$m; }; dictionary `ProgressEventInit@I : `EventInit$I { `boolean$ `lengthComputable@mb = false; `unsigned long long$ `loaded@mb = 0; `unsigned long long$ `total@mb = 0; };
`ProgressEvent$I ~interfaceを利用する`~event$は、何らかの進捗を指示する。 ◎ Events using the ProgressEvent interface indicate some kind of progression.
5.1. `ProgressEvent^I ~interfaceを利用する~eventの発火-法
%target に向けて,名前 %e の `進捗~eventを発火する@ ときは、所与の ( %伝送量, %長さ ) に対し ⇒ %target に向けて,名前 %e の`~eventを発火する$ — `ProgressEvent$I を利用し,次のように初期化して ⇒# `loaded$m 属性~値 ~SET %伝送量, `lengthComputable$m 属性~値 ~SET [ %長さ ~NEQ 0 ならば ~T / ~ELSE_ ~F ], `total$m 属性~値 ~SET %長さ ◎ To fire a progress event named e at target, given transmitted and length, means to fire an event named e at target, using ProgressEvent, with the loaded attribute initialized to transmitted, and if length is not 0, with the lengthComputable attribute initialized to true and the total attribute initialized to length.
5.2. `ProgressEvent^I ~interfaceを利用する~eventに示唆される名前
~INFORMATIVE`ProgressEvent$I ~interfaceを利用する`~event$に示唆される, `type$m 属性の値を、下の一覧に要約する。 仕様の編集者が,その仕様に固有の仔細に応じて~~調整することは自由であるが、~~問題に馴染みのある人達からの~~意見を汲むために,その用法について WHATWG ~communityにて論を交わすことが強く奨励される。 ◎ The suggested type attribute values for use with events using the ProgressEvent interface are summarized in the table below. Specification editors are free to tune the details to their specific scenarios, though are strongly encouraged to discuss their usage with the WHATWG community to ensure input from people familiar with the subject.
`type$m ◎ type attribute value | 記述 ◎ Description | 回数 ◎ Times | 時機 ◎ When |
---|---|---|---|
`loadstart$et | 進捗が~~開始された。 ◎ Progress has begun. | 1 回 ◎ Once. | 最初。 ◎ First. |
`progress$et | 進捗~中。 ◎ In progress. | 1 回以上 ◎ Once or more. | `loadstart$et が`配送-$された後。 ◎ After loadstart has been dispatched. |
`error$et | 進捗に失敗した。 ◎ Progression failed. |
高々 1 回 (排他的) ◎ Zero or once (mutually exclusive). | 最後の `progress$et が`配送-$された後。 ◎ After the last progress has been dispatched. |
`abort$et | 進捗は終了された。 ◎ Progression is terminated. | ||
`timeout$et | 進捗は時間~切れに因り終了された。 ◎ Progression is terminated due to preset time expiring. | ||
`load$et | 進捗は成功裡に終わった。 ◎ Progression is successful. | ||
`loadend$et | 進捗は停止された。 ◎ Progress has stopped. | 1 回 ◎ Once. | `error$et, `abort$et, `timeout$et, `load$et のいずれかが`配送-$された後。 ◎ After one of error, abort, timeout or load has been dispatched. |
~event型 `error$et, `abort$et, `timeout$et, `load$et は、互いに排他的である。 ◎ The error, abort, timeout, and load event types are mutually exclusive.
Web ~platform全般に渡り,~event型 `error$et, `abort$et, `timeout$et, `load$et の `bubbles$m および `cancelable$m 属性は、 ~F に初期化される。 従って,一貫性を保つため、 `ProgressEvent$I ~interfaceを利用するすべての`~event$も同様にすることが示唆される。 ◎ Throughout the web platform the error, abort, timeout and load event types have their bubbles and cancelable attributes initialized to false, so it is suggested that for consistency all events using the ProgressEvent interface do the same.
5.3. ~securityの考慮点
非同一-生成元~要請に対しては、例えば Fetch 標準にて定義される`~CORS~protocol$ などの,ある種の~opt-inが、 `ProgressEvent$I ~interfaceを利用する`~event$が`配送-$される前に利用される必要がある。 そうすると、他では得せない情報(例:~size)まで露呈されるので。 `FETCH$r ◎ For cross-origin requests some kind of opt-in, e.g., the CORS protocol defined in the Fetch Standard, has to be used before events using the ProgressEvent interface are dispatched as information (e.g., size) would be revealed that cannot be obtained otherwise. [FETCH]
5.4. 用例
次の例では、 `XMLHttpRequest$I に,前~節にて定義された概念が組合され、`~fetching$の過程の表示に~HTML `progress$e 要素が利用される。 ◎ In this example XMLHttpRequest, combined with concepts defined in the sections before, and the HTML progress element are used together to display the process of fetching a resource.
<!DOCTYPE html> <title>Waiting for Magical Unicorns</title> <progress id=p></progress> <script> var %progressBar = document.getElementById("p"), %client = new XMLHttpRequest() %client.open("GET", "magical-unicorns") %client.onprogress = function(%pe) { if(%pe.lengthComputable) { %progressBar.max = %pe.total %progressBar.value = %pe.loaded } } %client.onloadend = function(%pe) { %progressBar.value = %pe.loaded } %client.send() </script>
もちろん,全部的に~~機能する~codeは、より精巧かつ,~network~errorや末端利用者からの終了-要請など,より多くの局面に対応するものになるだろうが。 ◎ Fully working code would of course be more elaborate and deal with more scenarios, such as network errors or the end user terminating the request.
謝辞
この標準に貢献された、次の方々に感謝する:
`_acks1@Windows Internet Explorer にて初めて実装し, `XMLHttpRequest$I ~interfaceを最初に広めた Microsoft の開発者たちに特別な謝意を。 ◎ Special thanks to the Microsoft employees who first implemented the XMLHttpRequest interface, which was first widely deployed by the Windows Internet Explorer browser.
HTML Standard ( Web Applications 1.0 )にて、この仕様の初期~versionを草案~化された Ian Hickson 氏に特別な謝意を。 `HTML$r ◎ Special thanks to Ian Hickson for drafting an initial version of this specification in the HTML Standard (then Web Applications 1.0). [HTML]
SVG Micro DOM の一部として、元々の `ProgressEvent^I ~classの草案を作成した W3C SVG WG に特別な謝意を。 ◎ Special thanks to the W3C SVG WG for drafting the original ProgressEvent class as part of the SVG Micro DOM.
This standard is written by Anne van Kesteren (Mozilla, annevk@annevk.nl).