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にある文書の~statusを調べる: ◎ 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. 適合性
明示的に “規範的でない” と記された節に加え,この仕様~内のすべての 図式, 例, 注記は、規範的ではない。 他のすべては規範的である。 ◎ All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
この仕様における句: 「〜しなければ(〜しては)ならない」 = “MUST (NOT)”, 「〜すべきである(でない)」 = “SHOULD (NOT)”, 「〜してもよい」 = “MAY”, は、 RFC2119 に則って解釈されるものとする。 可読性のため、この仕様ではこれらの語が大文字~化されて出現することはない。 `RFC2119$r ◎ The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this specification are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. [RFC2119]
2.1. 拡張性
~UA, Working Group, その他の関心のある主体には、新たな特色機能について, WHATWG ~communityの場で論を交わすことが強く奨励される。 ◎ User agents, Working Groups, and other interested parties are strongly encouraged to discuss new features with the WHATWG community.
3. 各種用語
この仕様は、全体を通して,次に挙げる仕様による各種用語を利用し, リンク付きで引用する ⇒ `DOM$r `DOMPS$r `ENCODING$r `FEATURE-POLICY$r `FETCH$r `FILEAPI$r `HTML$r `HTTP$r `URL$r `WEBIDL$r `XML$r `XMLNS$r ◎ This specification uses terminology, cross-linked throughout, from DOM, DOM Parsing and Serialization, Encoding, Feature Policy, Fetch, File API, HTML, HTTP, URL, Web IDL, and XML. ◎ [DOM] [DOMPS] [ENCODING] [FEATURE-POLICY] [FETCH] [FILEAPI] [HTML] [HTTP] [URL] [WEBIDL] [XML] [XMLNS]
また、 `HTML$r と同じ typographic 規約を利用する。 ◎ It uses the typographic conventions from HTML. [HTML]
【この訳に固有の表記規約】
この訳の,~algoや定義の記述に利用されている各種記号( ~LET, 此れ, ~IF, ~THROW, 等々)の意味や定義の詳細は、~SYMBOL_DEF_REFを~~参照されたし。
~backtick( "`
" )で括られた~literalは、文字列ではなく,
~byte列を表現する。
4. ~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 }; [`XMLHttpRequest$mC, `Exposed$=(Window,DedicatedWorker,SharedWorker)] interface `XMLHttpRequest@I : `XMLHttpRequestEventTarget$I { // ~event~handler attribute `EventHandler$I `onreadystatechange$m; // `状態$ const ~US `UNSENT$m = 0; const ~US `OPENED$m = 1; const ~US `HEADERS_RECEIVED$m = 2; const ~US `LOADING$m = 3; const ~US `DONE$m = 4; ~RA ~US `readyState$m; // `要請$ void `open$m(`ByteString$ %method, `USVString$ %url); void `~open_async$m( `ByteString$ %method, `USVString$ %url, boolean %async, optional `USVString$? %username = null, optional `USVString$? %password = null ); void `setRequestHeader$m(`ByteString$ %name, `ByteString$ %value); attribute unsigned long `timeout$m; attribute boolean `withCredentials$m; [`SameObject$] ~RA `XMLHttpRequestUpload$I `upload$m; void `send$m(optional (`Document$I or `BodyInit$I)? %body = null); void `abort$m(); // `応答$ ~RA `USVString$ `responseURL$m; ~RA ~US `status$m; ~RA `ByteString$ `statusText$m; `ByteString$? `getResponseHeader$m(`ByteString$ %name); `ByteString$ `getAllResponseHeaders$m(); void `overrideMimeType$m(`DOMString$ %mime); attribute `XMLHttpRequestResponseType$I `responseType$m; ~RA any `response$m; ~RA `USVString$ `responseText$m; [`Exposed$=Window] ~RA `Document$I? `responseXML$m; };
各 `XMLHttpRequest$I ~objには、次のものが結付けられる: ◎ ↓
- `~upload~obj@
- `XMLHttpRequestUpload$I ~obj ◎ An XMLHttpRequest object has an associated XMLHttpRequestUpload object.
- 【 この用語は、~~参照を明確化するために,この訳に導入している(原文では、単に “`XMLHttpRequestUpload^I ~obj” ) 】
- `状態@
- 次のいずれか ⇒ `~unsent^i (初期~値), `~opened^i, `~headers-received^i, `~loading^i, `~done^i ◎ An XMLHttpRequest object has an associated state, which is one of unsent, opened, headers received, loading, and done. Unless stated otherwise it is unsent.
- `~send~flag@
- 他が言明されない限り, ~OFF をとる。 ◎ An XMLHttpRequest object has an associated send() flag. Unless stated otherwise it is unset.
4.1. 構築子
- %client = new `XMLHttpRequest()$m
- 新たな `XMLHttpRequest$I ~objを返す。 ◎ Returns a new XMLHttpRequest object.
- `XMLHttpRequest()@m
- この構築子は、新たな `XMLHttpRequest$I ~objを返さ~MUST。 ◎ The XMLHttpRequest() constructor, when invoked, must return a new XMLHttpRequest object.
4.2. ~garbage収集
`XMLHttpRequest$I ~objは、次をいずれも満たしている間は,~garbage収集されては~MUST_NOT:
-
次のいずれかを満たしている:
- [ `状態$ ~EQ `~opened^i ]~AND[ `~send~flag$ ~EQ ~ON ]
- `状態$ ~IN { `~headers-received^i, `~loading^i }
- 次に挙げるいずれかの~event型に対する`~event~listener$が登録されている ⇒ `readystatechange$et, `progress$et, `abort$et, `error$et, `load$et, `timeout$et, `loadend$et
`XMLHttpRequest$I ~objが,その接続がまだ開いているにも関わらず~garbage収集された場合、~UAは,~objが演算している進行中の`~fetchを終了-$させ~MUST。 ◎ 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.
4.3. ~event~handler
`XMLHttpRequestEventTarget$I を継承する~interfaceを実装する~objは、次の`~event~handler$(およびそれらに対応する`~event~handler ~event型$)を属性として~supportし~MUST。 ◎ 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し~MUST: ◎ 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 |
4.4. 状態
- %client . `readyState$m
- `状態$を返す。 ◎ Returns client’s state.
- `readyState@m
-
取得子は、此れの`状態$が下の表の 1 列目のいずれであるかに応じて,同じ行の 2 列目に示される値を返さ~MUST: ◎ The readyState attribute’s getter must 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 context object’s state:
`状態$ 値(数値) ~~説明 `~unsent^i `UNSENT@m ( 0 ) ~objは構築-済みである。 ◎ The object has been constructed. `~opened^i `OPENED@m ( 1 ) `open$m ~methは成功裡に呼出された。 この状態~下では、 `setRequestHeader$m を用いて要請~headerを設定することができ, `send$m ~methを用いて~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. `~headers-received^i `HEADERS_RECEIVED@m ( 2 ) すべての~redirect(もしあれば)は追跡~済みであり,かつ `応答$のすべての~HTTP~headerは受信-済みである。 ◎ All redirects (if any) have been followed and all HTTP headers of the response have been received. `~loading^i `LOADING@m ( 3 ) `応答$の`本体$rsの受信-中にある。 ◎ The response’s body is being received. `~done^i `DONE@m ( 4 ) ~data転送が完了しているか, または転送~中に何らかの不具合が生じた(例えば,際限のない~redirect)。 ◎ The data transfer has been completed or something went wrong during the transfer (e.g. infinite redirects).
4.5. 要請
各 `XMLHttpRequest$I ~objの要請には、次の概念が結付けられる(括弧内は初期~値):
- `要請~method@
- `要請~URL@
- `~header~list$である,`作者~要請~header~list@(空)
- `要請~本体@( ~NULL )
- `同期~flag@( ~OFF )
- `~upload完了-~flag@( ~OFF )
- `~upload~listener~flag@( ~OFF )
- `時間切れ~flag@( ~OFF )
注記: `XMLHttpRequestUpload$I ~obj上に 1 個~以上の~event~listenerを登録すると,`~CORS予行~要請$が発行されることになる。 (~event~listenerが登録されると`~upload~listener~flag$は ~ON になり,それにより`~CORS予行~利用~flag$rqも ~ON になるので。) ◎ 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.)
4.5.1. `open()^m ~meth
- %client . `open$m(%method, %url [, %async = true [, %username = null [, %password = null]]])
- `要請~method$, `要請~URL$, `同期~flag$ を設定する。 ◎ Sets the request method, request URL, and synchronous flag.
- %method が妥当な~HTTP~methodでない,あるいは %url を構文解析できない場合、 `SyntaxError$E 例外が投出される。 ◎ Throws a "SyntaxError" DOMException if either method is not a valid HTTP method or url cannot be parsed.
- %method が `CONNECT^h, `TRACE^h, `TRACK^h のいずれかに文字大小無視で合致する場合、 `SecurityError$E 例外が投出される。 ◎ 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 を渡しては~MUST_NOT。 ~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 ~methの被呼出時には、次を走らせ~MUST: ◎ The open(method, url) and open(method, url, async, username, password) methods, when invoked, must run these steps:
- %設定群~obj ~LET 此れに`関連する設定群~obj$ ◎ Let settingsObject be context object’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 引数は省略されている ] ⇒ ( %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$ ~NEQ ~NULL ]: ◎ If parsedURL’s host is non-null, run these substeps:
- ~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である
- [ `timeout$m 属性 ~NEQ 0 ]~OR[ `responseType$m 属性 ~NEQ 空~文字列 ]
…ならば ⇒ ~THROW `InvalidAccessError$E
◎ If async is false, current global object is a Window object, and the timeout attribute value is not zero or the responseType attribute value 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$ ~SET ~OFF, `~upload~listener~flag$ ~SET ~OFF, `要請~method$ ~SET %method, `要請~URL$ ~SET %解析済み~URL, `同期~flag$ ~SET [ %async ~EQ ~F ならば ~ON / ~ELSE_ ~OFF ], `応答$ ~SET `~network~error$, `受信-済み~byte列$ ~SET 空~byte列, `応答~obj$ ~SET ~NULL, `上書き~MIME型$ ~SET ~NULL ◎ Set variables associated with the object as follows: • Unset the send() flag and upload listener flag. • Set request method to method. • Set request URL to parsedURL. • Set the synchronous flag, if async is false, and unset the synchronous flag otherwise. • Empty author request headers. • Set response to a network error. • Set received bytes to the empty byte sequence. • Set response object to null. • Set override MIME type to null.
- 此れの`作者~要請~header~list$を空にする ◎ ↑
-
~IF[ 此れの`状態$ ~NEQ `~opened^i ]: ◎ If the state is not opened, run these substeps:
- 此れの`状態$ ~SET `~opened^i ◎ Set state to opened.
- 此れに向けて,名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange.
◎ The reason there are two open() methods defined is due to a limitation of the editing software used to write the XMLHttpRequest Standard.
4.5.2. `setRequestHeader()^m ~meth
- %client . `setRequestHeader(name, value)$m
-
`作者~要請~header~list$の中で,所与の %name の`~header$に %value を結合する ◎ Combines a header in author request headers.
- `状態$ ~NEQ `~opened^i, または `~send~flag$ ~EQ ~ON の場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
- %name が~header名でなかったり, %value が~header値でなかった場合、 `SyntaxError$E 例外が投出される。 ◎ Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value.
- `setRequestHeader(name, value)@m
-
被呼出時には、次を走らせ~MUST: ◎ The setRequestHeader(name, value) method must run these steps:
- ~IF[ `状態$ ~NEQ `~opened^i ] ⇒ ~THROW `InvalidStateError$E ◎ If state is not opened, then throw an "InvalidStateError" DOMException.
- ~IF[ `~send~flag$ ~EQ ~ON ] ⇒ ~THROW `InvalidStateError$E ◎ If the send() flag is set, then throw an "InvalidStateError" DOMException.
- %value ~SET `値を正規化する$( %value ) ◎ Normalize value.
-
~IF[ %name は`名前$でない ]~OR[ %value は`値$でない ] ⇒ ~THROW `SyntaxError$E ◎ If name is not a name or value is not a value, then throw a "SyntaxError" DOMException.
注記: 空~byte列は空の`~header$ `値$を表現する。 ◎ An empty byte sequence represents an empty header value.
- ~IF[ %name は`禁止~header名$である ] ⇒ ~RET ◎ Terminate these steps if name is a forbidden header name.
- `作者~要請~header~list$内で`~headerを結合する$( %name / %value ) ◎ Combine name/value in author request headers.
同じ~headerを重複して設定した場合の~~動作を示すための,単純な~code。 次の~script: ◎ 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();
による結果、次の~headerが送信される: ◎ // …results in the following header being sent:
X-Test: one, two
4.5.3. `timeout^m 属性
- %client . `timeout$m
- 時間を~milli秒~単位で設定できる。 0 でない値に設定された場合、所与の時間が経過した時点で,`~fetching$は終了させられる。 その時点で要請がまだ完了していない場合、`同期~flag$が ~OFF の下では, `timeout$et ~eventが`配送-$され、他の場合( ~ON の下での `send()$m ~methに対しては), `TimeoutError$E 例外が`投出$されることになる。 ◎ 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 the synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method).
- 設定子は、[ `同期~flag$ ~EQ ~ON ], かつ[ `現在の大域~obj$は `Window$I ~objである ]ならば, `InvalidAccessError$E 例外が投出される。 ◎ When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
- `timeout@m
- 取得子は、最後に設定された値を返さ~MUST。 初期~時には 0 に設定され~MUST。 ◎ The timeout attribute must return its value. Initially its value must be zero.
-
設定子は、次を走らせ~MUST: ◎ Setting the timeout attribute must run these steps:
- ~IF[ `現在の大域~obj$は `Window$I ~objである ]~AND[ `同期~flag$ ~EQ ~ON ] ⇒ ~THROW `InvalidAccessError$E ◎ If current global object is a Window object and the synchronous flag is set, then throw an "InvalidAccessError" DOMException.
- この属性の値 ~SET 新たな値 ◎ Set its value to the new 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.
4.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.
- 設定子は、`状態$が `~unsent^i でも `~opened^i でもない, または `~send~flag$ ~EQ ~ON ならば, `InvalidStateError$E 例外が投出される。 ◎ When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set.
- `withCredentials@m
- 取得子は、最後に設定された値を返さ~MUST。 初期~時には ~F に設定され~MUST。 ◎ The withCredentials attribute must return its value. Initially its value must be false.
-
設定子は、次を走らせ~MUST: ◎ Setting the withCredentials attribute must run these steps:
- ~IF[ `状態$ ~NIN { `~unsent^i, `~opened^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If state is not unsent or opened, then throw an "InvalidStateError" DOMException.
- ~IF[ `~send~flag$ ~EQ ~ON ] ⇒ ~THROW `InvalidStateError$E ◎ If the send() flag is set, then throw an "InvalidStateError" DOMException.
- この属性の値 ~SET 所与の値 ◎ Set the withCredentials attribute’s value to the given value.
注記: `withCredentials$m 属性は、`同一生成元$の`~fetching$においては、何の効果もない。 ◎ The withCredentials attribute has no effect when fetching same-origin resources.
4.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.
- `upload@m
- 取得子は、此れの`~upload~obj$を返さ~MUST。 ◎ The upload attribute must return the associated XMLHttpRequestUpload object. ◎ As indicated earlier, each XMLHttpRequest object has an associated XMLHttpRequestUpload object.
4.5.6. `send()^m ~meth
- %client . `send$m([%body = null])
- 要請を起動させる。 引数(省略可)は`要請~本体$を与える。 `要請~method$が `GET^c や `HEAD^c の場合、この引数は無視される。 ◎ Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD.
- `状態$ ~NEQ `~opened^i, または `~send~flag$ ~EQ ~ON の場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
`send(body)@m ~methの被呼出時には、次を走らせ~MUST: ◎ The send(body) method must run these steps:
- ~IF[ `状態$ ~NEQ `~opened^i ] ⇒ ~THROW `InvalidStateError$E ◎ If state is not opened, then throw an "InvalidStateError" DOMException.
- ~IF[ `~send~flag$ ~EQ ~ON ] ⇒ ~THROW `InvalidStateError$E ◎ If the send() flag is set, then throw an "InvalidStateError" DOMException.
- ~IF[ `要請~method$ ~IN { `GET^c, `HEAD^c } ] ⇒ %body ~SET ~NULL ◎ If the request method is GET or HEAD, set body to null.
-
~IF[ %body ~NEQ ~NULL ]: ◎ If body is not null, then:
- %抽出された内容~型 ~LET ~NULL ◎ Let extractedContentType be null.
- ~IF[ %body は `Document$I である ] ⇒ `要請~本体$ ~SET `~UTF-8符号化する$( `~Unicode~scalar値~列に変換する$( `素片を直列化する$( %body ) ) ) ◎ If body is a Document, then set request body to body, serialized, converted to Unicode, and UTF-8 encoded.
- ~ELSE ⇒ ( `要請~本体$, %抽出された内容~型 ) ~SET `本体と内容~型を抽出する$( %body ) ◎ Otherwise, set request body and extractedContentType to the result of extracting body.
- %作者~内容~型 ~LET `作者~要請~header~list$内に `Content-Type^h を`名前に持つ~header$は[ 在るならば それ/ 無いならば ~NULL ] ◎ ↓
-
~IF[ %作者~内容~型 ~NEQ ~NULL ]: ◎ If author request headers contains `Content-Type`, then:
-
~IF[ %body は[ `Document$I / `USVString$I ]である ]: ◎ If body is a Document or a USVString, then:
- %内容~型~record ~LET `~byte列から~MIME型を構文解析する$( %作者~内容~型 の`値$ ) ◎ Let originalAuthorContentType be the value of the header whose name is a byte-case-insensitive match for `Content-Type` in author request headers. ◎ Let contentTypeRecord be the result of parsing originalAuthorContentType.
-
~IF[ %内容~型~record ~NEQ 失敗 ]~AND[ %内容~型~record の`~parameter~map$[ `charset^l ] ~NEQ ε ]: ◎ If contentTypeRecord is not failure, and contentTypeRecord’s parameters["charset"] exists, then:
- %内容~型~record の`~parameter~map$[ `charset^l ] ~SET `UTF-8^l ◎ Set contentTypeRecord’s parameters["charset"] to "UTF-8".
- `作者~要請~header~list$内で`~headerを設定する$( `Content-Type^h / `~MIME型を~byte列に直列化する$( %内容~型~record ) ) ◎ Let newContentTypeSerialized be the result of serializing contentTypeRecord. ◎ Set `Content-Type`/newContentTypeSerialized in author request headers.
-
-
~ELSE ◎ Otherwise:
- %内容~型 ~LET 次で与えられる値 ⇒# %body は`~HTML文書$であるならば `text/html;charset=UTF-8^lb / ~ELSE_ %body は`~XML文書$であるならば `application/xml;charset=UTF-8^lb / ~ELSE_ %抽出された内容~型 ◎ If body is a HTML document, set `Content-Type`/`text/html;charset=UTF-8` in author request headers. ◎ Otherwise, if body is an XML document, set `Content-Type`/`application/xml;charset=UTF-8` in author request headers. ◎ Otherwise, if extractedContentType is not null, set `Content-Type`/extractedContentType in author request headers.
- ~IF[ %内容~型 ~NEQ ~NULL ] ⇒ `作者~要請~header~list$内で`~headerを設定する$( `Content-Type^h / %内容~型 ) ◎ ↑
- ~IF[ 此れの`~upload~obj$に登録されている~event~listenerは在る ] ⇒ `~upload~listener~flag$ ~SET ~ON ◎ If one or more event listeners are registered on the associated XMLHttpRequestUpload object, then set upload listener flag.
-
%要請 ~LET 次の様に初期化された新たな`要請$rq: ◎ Let req be a new request, initialized as follows:
- `~method$rq~SET `要請~method$ ◎ method • request method
- `url$rq ~SET `要請~URL$ ◎ url • request URL
- `~header~list$rq ~SET `作者~要請~header~list$ ◎ header list • author request headers
- `非安全~要請~flag$rq ~SET ~ON ◎ unsafe-request flag • Set.
- `本体$rq ~SET `要請~本体$ ◎ body • request body
- `~client$rq ~SET 此れに`関連する設定群~obj$ ◎ client • context object’s relevant settings object
- `同期~flag$rq ~SET `同期~flag$ ◎ synchronous flag • Set if the synchronous flag is set.
- `~mode$rq ~SET `cors^l ◎ mode • "cors"
- `~CORS予行~利用~flag$rq ~SET `~upload~listener~flag$ ◎ use-CORS-preflight flag • Set if upload listener flag is set.
- `資格証~mode$rq ~SET [ `withCredentials$m 属性 ~EQ ~T ならば `include^l / ~ELSE_ `same-origin^l ] ◎ credentials mode • If the withCredentials attribute value is true, "include", and "same-origin" otherwise.
- `~URL資格証~利用~flag$rq ~SET [ `要請~URL$は`資格証を含む$ならば ~ON / ~ELSE_ ~OFF ] ◎ use-URL-credentials flag • Set if either request URL’s username is not the empty string or request URL’s password is non-null.
- `~upload完了-~flag$ ~SET %要請 の`本体$rqに応じて ⇒ ~NULL ならば ~ON / ~ELSE_ ~OFF ◎ Unset the upload complete flag. ◎ Unset the timed out flag. ◎ If req’s body is null, set the upload complete flag.
- `時間切れ~flag$ ~SET ~OFF ◎ ↑
- `~send~flag$ ~SET ~ON ◎ Set the send() flag.
-
~IF[ `同期~flag$ ~EQ ~OFF ]: ◎ If the synchronous flag is unset, run these substeps:
- 名前 `loadstart$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadstart with 0 and 0.
- ~IF[ `~upload完了-~flag$ ~EQ ~OFF ]~AND[ `~upload~listener~flag$ ~EQ ~ON ] ⇒ `~upload~obj$に向けて,名前 `loadstart$et の`進捗~eventを発火する$( 0, %要請 の`本体$rqの`総~byte数$ ) ◎ If the upload complete flag is unset and upload listener flag is set, then fire a progress event named loadstart on the XMLHttpRequestUpload object with 0 and req’s body’s total bytes.
- ~IF[ `状態$ ~NEQ `~opened^i ]~OR[ `~send~flag$ ~EQ ~OFF ] ⇒ ~RET ◎ If state is not opened or the send() flag is unset, then return.
-
%要請 を用いて`~fetching$に取り掛かる — 以下に従って,`~network用~task源$から`~queueされ$た`~task$を取扱う ◎ Fetch req. Handle the tasks queued on the networking task source per below.
次の下位手続きを`並列的$に走らす: ◎ Run these subsubsteps in parallel:
-
次のいずれかが満たされるまで待機する: ◎ ↓
- %要請 の`~done~flag$rq ~EQ ~ON ◎ Wait until either req’s done flag is set or
- この下位手続きを開始してから経過した秒数 ~GT `timeout$m 属性~値 ~GT 0 ◎ the timeout attribute value number of milliseconds has passed since these subsubsteps started ◎ while timeout attribute value is not zero.
-
~IF[ %要請 の`~done~flag$rq ~EQ ~OFF ]:
- `時間切れ~flag$ ~SET ~ON
- この`~fetchを終了させる$
【以下に定義される各種 下位手続き( “〜を処理する” )は、`~fetching$の中で~queueされる~taskになる(これらは,非同期的に呼出される callback である)。】
%要請 上で`要請の本体を処理する$ときは、次の下位手続きを走らす: ◎ To process request body for request, run these subsubsteps:
- ~IF[ この手続きが最後に呼出されたときから,まだ およそ 50ms 以上 経過していない ] ⇒ ~RET ◎ If not roughly 50ms have passed since these subsubsteps were last invoked, terminate these subsubsteps.
- ~IF[ `~upload~listener~flag$ ~EQ ~ON ] ⇒ `~upload~obj$に向けて,名前 `progress$et の`進捗~eventを発火する$( %要請 の`本体$rqの`伝送-済み~byte数$, %要請 の`本体$rqの`総~byte数$ ) ◎ If upload listener flag is set, then fire a progress event named progress on the XMLHttpRequestUpload object with request’s body’s transmitted bytes and request’s body’s total bytes.
注記: この下位手続きは、新たな~byteが伝送されたときに限り,呼出される。 ◎ These subsubsteps are only invoked when new bytes are transmitted.
%要請 上で`要請の本体終端を処理する$ときは、次の下位手続きを走らす: ◎ To process request end-of-body for request, run these subsubsteps:
- `~upload完了-~flag$ ~SET ~ON ◎ Set the upload complete flag.
- ~IF[ `~upload~listener~flag$ ~EQ ~ON ] ⇒ ~RET ◎ If upload listener flag is unset, then terminate these subsubsteps.
- %伝送量 ~LET %要請 の`本体$rqの`伝送-済み~byte数$ ◎ Let transmitted be request’s body’s transmitted bytes.
- %長さ ~LET %要請 の`本体$rqの`総~byte数$ ◎ Let length be request’s body’s total bytes.
- `~upload~obj$に向けて,名前 `progress$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named progress on the XMLHttpRequestUpload object with transmitted and length.
- `~upload~obj$に向けて,名前 `load$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named load on the XMLHttpRequestUpload object with transmitted and length.
- `~upload~obj$に向けて,名前 `loadend$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named loadend on the XMLHttpRequestUpload object with transmitted and length.
%応答 上で`応答を処理する$ときは、次の下位手続きを走らす: ◎ To process response for response, run these subsubsteps:
- `応答$ ~SET %応答 ◎ Set response to response.
- %応答 に対し,`~errorを取扱う$ ◎ Handle errors for response.
- ~IF[ `応答$ は`~network~error$である ] ⇒ ~RET ◎ If response is a network error, return.
- `状態$ ~SET `~headers-received^i ◎ Set state to headers received.
- 名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange.
- ~IF[ `状態$ ~NEQ `~headers-received^i ] ⇒ ~RET ◎ If state is not headers received, then return.
- %本体 ~LET %応答 の`本体$rs ◎ ↓
-
~IF[ %本体 ~EQ ~NULL ]:
- %応答 の`本体終端を取扱う$
- ~RET
-
%読取器 ~LET `読取器を取得する$( %本体 の`~stream$ ) ◎ Let reader be the result of getting a reader from response’s body’s stream.
注記: この演算が例外を投出することはない。 ◎ This operation will not throw an exception.
-
%読取 ~LET %本体 の`~stream$から %読取器 で`~chunkを読取った$結果 ◎ Let read be the result of reading a chunk from response’s body’s stream with reader.
-
%読取 が次の両者を満たす~obj:
- `done^c ~prop ~EQ ~F
- `value^c ~propは `Uint8Array$I ~objである
で充足されたときは ⇒ 次の下位手続き(A) を走らせた上で、[ この,`応答を処理する$手続き ]を再度~走らす
◎ When read is fulfilled with an object whose done property is false and whose value property is a Uint8Array object, run these subsubsubsteps and then run the above subsubstep again:下位手続き(A):
- `受信-済み~byte列$に `value^c ~propを付加する ◎ Append the value property to received bytes.
- ~IF[ 下位手続き(A) が前回に呼出されたときから,まだ およそ 50ms 以上 経過していない ] ⇒ ~RET ◎ If not roughly 50ms have passed since these subsubsubsteps were last invoked, then terminate these subsubsubsteps.
- ~IF[ `状態$ ~EQ `~headers-received^i ] ⇒ `状態$ ~SET `~loading^i ◎ If state is headers received, then set state to loading.
-
名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange.
注記: `readystatechange$et が状態~変化なしでも余分に発火されるのは、 Web 互換性の理由による。 ◎ Web compatibility is the reason readystatechange fires more often than state changes.
- 名前 `progress$et の`進捗~eventを発火する$( %本体 の`伝送-済み~byte数$, %本体 の`総~byte数$ ) ◎ Fire a progress event named progress with response’s body’s transmitted bytes and response’s body’s total bytes.
注記: 下位手続き(A) は、新たな~byte列が伝送されたときに限り,呼出される。 ◎ These subsubsubsteps are only invoked when new bytes are transmitted.
- %読取 が[ `done^c ~prop ~EQ ~T ]なる~objで充足されたときは ⇒ %応答 の`本体終端を取扱う$ ◎ When read is fulfilled with an object whose done property is true, run handle response end-of-body for response.
- %読取 が例外で却下されたときは ⇒ %応答 の`~errorを取扱う$ ◎ When read is rejected with an exception, run handle errors for response.
-
-
-
~ELSE ( `同期~flag$ ~EQ ~ON ): ◎ Otherwise, if the synchronous flag is set, run these substeps:
-
~IF[ 此れに`関連する設定群~obj$には`担当の文書$enVがあって,それには `sync-xhr$l `特色機能の利用は許容されて$いない† ] ⇒# `~network~error$ の`本体終端を取扱う$; ~RET
【† この用語は,実際には内容~属性の名前に対し定義されているので、適切に解釈し直す必要がある。】 ◎ If context object’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 a network error and return. -
%応答 ~LET %要請 を用いて`~fetching$を遂行した結果 ◎ Let response be the result of fetching req.
~IF[ `timeout$m 属性~値 %timeout ~NEQ 0 ]~AND[ この`~fetching$は %timeout ~milli秒内に返らなかった ]:
- `時間切れ~flag$ ~SET ~ON
- この`~fetchを終了させる$
-
~IF[ %応答 の`本体$rs ~NEQ ~NULL ] ◎ If response’s body is null, then run handle response end-of-body and return.
-
%読取器 ~LET `読取器を取得する$( %応答 の`本体$rsの`~stream$ ) ◎ Let reader be the result of getting a reader from response’s body’s stream.
注記: この演算が例外を投出することはない。 ◎ This operation will not throw an exception.
- %promise ~LET [ %応答 の`本体$rsの`~stream$から, %読取器 を用いて`すべての~byte列を読取る$ ]ような~promise ◎ Let promise be the result of reading all bytes from response’s body’s stream with reader.
- %promise が充足されるか却下されるまで待機する ⇒ %promise が %~byte列 で充足されたときは ⇒ `受信-済み~byte列$に %~byte列 を付加する ◎ Wait for promise to be fulfilled or rejected. ◎ • If promise is fulfilled with bytes, then append bytes to received bytes.
-
- %応答 の`本体終端を取扱う$ ◎ Run handle response end-of-body for response.
-
%応答 の `本体終端を取扱う@ ときは、次を走らす: ◎ To handle response end-of-body for response, run these steps:
- ~IF[ `同期~flag$ ~EQ ~ON ] ⇒ `応答$ ~SET %応答 ◎ If the synchronous flag is set, set response to response.
- %応答 に対し,`~errorを取扱う$ ◎ Handle errors for response.
- ~IF[ `応答$ は`~network~error$である ] ⇒ ~RET ◎ If response is a network error, return.
- ~IF[ `同期~flag$ ~EQ ~OFF ] ⇒ %応答 を用いて`応答$の`本体$rsを更新する ◎ If the synchronous flag is unset, update response’s body using response.
- %伝送量 ~LET %応答 の`本体$rsの`伝送-済み~byte数$ ◎ Let transmitted be response’s body’s transmitted bytes.
- %長さ ~LET %応答 の`本体$rsの`総~byte数$ ◎ Let length be response’s body’s total bytes.
- ~IF[ `同期~flag$ ~EQ ~OFF ] ⇒ 名前 `progress$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ If the synchronous flag is unset, fire a progress event named progress with transmitted and length.
- `状態$ ~SET `~done^i ◎ Set state to done.
- `~send~flag$ ~SET ~OFF ◎ Unset the send() flag.
- 名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange.
- 名前 `load$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named load with transmitted and length.
- 名前 `loadend$et の`進捗~eventを発火する$( %伝送量, %長さ ) ◎ Fire a progress event named loadend with transmitted and length.
%応答 に対し, `~errorを取扱う@ ときは、次を走らす: ◎ To handle errors for response run these steps:
- ~IF[ `~send~flag$ ~EQ ~OFF ] ⇒ ~RET ◎ If the send() flag is unset, return.
- ~IF[ `時間切れ~flag$ ~EQ ~ON ] ⇒ `要請~error手続きを走らす$( `timeout$et, `TimeoutError$E ) ◎ If the timed out flag is set, then run the request error steps for event timeout and exception "TimeoutError" DOMException.
- ~IF[ %応答 は`~network~error$である ] ⇒ `要請~error手続きを走らす$( `error$et, `NetworkError$E ) ◎ If response is a network error, then run the request error steps for event error and exception "NetworkError" DOMException.
-
~ELIF[ %応答 の`本体$rsの`~stream$は`~errorした$ ]: ◎ Otherwise, if response’s body’s stream is errored, then:
- `状態$ ~SET `~done^i ◎ Set state to done.
- `~send~flag$ ~SET ~OFF ◎ Unset the send() flag.
- `応答$ ~SET `~network~error$ ◎ Set response to a network error.
- ~ELIF[ %応答 の`中止~flag$rs ~EQ ~ON ] ⇒ `要請~error手続きを走らす$( `abort$et, `AbortError$E ) ◎ Otherwise, if response’s aborted flag is set, then run the request error steps for event abort and exception "AbortError" DOMException.
`要請~error手続きを走らす@ ときは、所与の ( %~event名 , %例外 (省略可)) に対し,次を走らす: ◎ The request error steps for event event and optionally an exception exception are:
- `状態$ ~SET `~done^i ◎ Set state to done.
- `~send~flag$ ~SET ~OFF ◎ Unset the send() flag.
- `応答$ ~SET `~network~error$ ◎ Set response to a network error.
-
~IF[ `同期~flag$ ~EQ ~ON ] ⇒ ~THROW %例外 ◎ If the synchronous flag is set, throw an exception exception.
【 この場合に、 %例外 が省略されて呼出されることはない。 】
-
名前 `readystatechange$et の`~eventを発火する$ ◎ Fire an event named readystatechange.
注記: この時点で明らかに `同期~flag$ ~EQ ~OFF ◎ At this point it is clear that the synchronous flag is unset.
-
~IF[ `~upload完了-~flag$ ~EQ ~OFF ]: ◎ If the upload complete flag is unset, follow these substeps:
- `~upload完了-~flag$ ~SET ~ON ◎ Set the upload complete flag.
-
~IF[ `~upload~listener~flag$ ~EQ ~ON ]: ◎ If upload listener flag is unset, then terminate these substeps.
- `~upload~obj$に向けて,名前 %~event名 の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named event on the XMLHttpRequestUpload object with 0 and 0.
- `~upload~obj$に向けて,名前 `loadend$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadend on the XMLHttpRequestUpload object with 0 and 0.
- 名前 %~event名 の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named event with 0 and 0.
- 名前 `loadend$et の`進捗~eventを発火する$( 0, 0 ) ◎ Fire a progress event named loadend with 0 and 0.
4.5.7. `abort()^m ~meth
- %client . `abort()$m
- ~network活動をすべて取消す。 ◎ Cancels any network activity.
- `abort()@m
-
被呼出時には、次を走らせ~MUST: ◎ The abort() method, when invoked, must run these steps:
- 進行中の`~fetchを終了させる$( `中止~flag^i ~SET ~ON ) ◎ Terminate the ongoing fetch with the aborted flag set.
- ~IF[[ `状態$ ~EQ `~opened^i ]~AND[ `~send~flag$ ~EQ ~ON ]]~OR[ `状態$ ~IN { `~headers-received^i, `~loading^i } ] ⇒ `要請~error手続きを走らす$( `abort$et ) ◎ If state is either opened with the send() flag set, headers received, or loading, run the request error steps for event abort.
-
~IF[ `状態$ ~EQ `~done^i ]:
- `状態$ ~SET `~unsent^i
- `応答$ ~SET `~network~error$
注記: いかなる `readystatechange$et ~eventも配送されない。 ◎ No readystatechange event is dispatched.
4.6. 応答
各 `XMLHttpRequest$I には,次のものが結付けられる:
- `応答@
- `応答$rs。 他が言明されない限り,`~network~error$とする。 ◎ An XMLHttpRequest has an associated response. Unless stated otherwise it is a network error.
- `受信-済み~byte列@
- ~byte列。 他が言明されない限り,空~byte列とする。 ◎ An XMLHttpRequest also has an associated received bytes (a byte sequence). Unless stated otherwise it is the empty byte sequence.
4.6.1. `responseURL^m 属性
- `responseURL@m
- 取得子は、次を返さ~MUST ⇒# `応答$の`url$rs ~EQ ~NULL ならば空~文字列/ ~ELSE_ `~URLを直列化する$( `応答$の`url$rs, `素片は除外する^i ) ◎ The responseURL attribute must return the empty string if response’s url is null and its serialization with the exclude fragment flag set otherwise.
4.6.2. `status^m 属性
- `status@m
- 取得子は、`応答$の`~status$rsを返さ~MUST。 ◎ The status attribute must return the response’s status.
4.6.3. `statusText^m 属性
- `statusText@m
- 取得子は、`応答$の`~status~message$rsを返さ~MUST。 ◎ The statusText attribute must return the response’s status message.
4.6.4. `getResponseHeader()^m ~meth
- `getResponseHeader(name)@m
-
被呼出時には、次を走らせ~MUST: ◎ The getResponseHeader(name) method must run these steps:
- `応答$の`~header~list$rs内に[ %name を`名前に持つ~header$ ]はない ] ⇒ ~RET ~NULL ◎ If response’s header list does not contain name, then return null.
- ~RET `応答$の`~header~list$rs内の %名前 に対する`結合-済みの値$ ◎ Return the combined value given name and response’s header list.
注記: `応答$に公開される`~header~list$rsは、 Fetch 標準に従って,絞込まれる。 `FETCH$r ◎ The Fetch Standard filters response’s header list. [FETCH]
次の~scriptにおいては: ◎ For the following script:
var %client = new XMLHttpRequest(); %client.open("GET", "unicorns-are-teh-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
4.6.5. `getAllResponseHeaders()^m ~meth
- `getAllResponseHeaders()@m
-
被呼出時には、次を走らせ~MUST: ◎ The getAllResponseHeaders() method, when invoked, must run these steps:
- %出力 ~LET 空~byte列 ◎ Let output be an empty byte sequence.
- %~header~list ~LET 次の結果 ⇒ `応答$の`~header~list$rsを`整列して結合する$ ◎ Let headers be the result of running sort and combine with response’s header list.
-
%~header~list 内の~EACH( %~header ) に対し ⇒ %出力 に次を順に付加する ⇒# %~header の`名前$, ~byte対 0x3A 0x20, %~header の`値$, ~byte対 0x0D 0x0A ◎ 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.
注記: `応答$に公開される`~header~list$rsは、 Fetch 標準に従って,絞込まれる。 `FETCH$r ◎ The Fetch Standard filters 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
4.6.6. 応答~本体
`応答~MIME型@ は、次を走らせた結果で与えられる: ◎ The response MIME type is the result of running these steps:
- %~MIME型 ~LET `~MIME型を抽出する$( `応答$の`~header~list$rs ) ◎ Let mimeType be the result of extracting a MIME type from response’s header list.
- ~RET [ %~MIME型 ~NEQ 空~byte列 ならば %~MIME型 / ~ELSE_ `text/xml^lb ] ◎ If mimeType is the empty byte sequence, then set mimeType to `text/xml`. ◎ Return mimeType.
`上書き~MIME型@ は、初期~時は ~NULL とする — それは、 `overrideMimeType()$m を呼出したときに,値を取得し得る。 `最終~MIME型@ は、`上書き~MIME型$が[ 非 ~NULL ならばその値 / ~NULL ならば`応答~MIME型$ ]とする。 ◎ The override MIME type is initially null and can get a value when overrideMimeType() is invoked. The final MIME type is the override MIME type unless that is null in which case it is the response MIME type.
`最終~charset@ は、次の手続きが返す値である: ◎ The final charset is the return value of these steps:
- %~label ~LET [ `上書き~MIME型$の`~parameter~map$[ `charset^l ] ~NEQ ε ならば それ / ~ELSE_ `応答~MIME型$の`~parameter~map$[ `charset^l ] ] ◎ Let label be null. ◎ If response MIME type’s parameters["charset"] exists, then set label to it. ◎ If 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.
- ~IF[ %符号化法 ~EQ `失敗^i ] ⇒ ~RET ~NULL ◎ If encoding is failure, then return null.
- ~RET %符号化法 ◎ Return encoding.
注記: 上の手続きが`最終~MIME型$を利用しないのは、意図的である — そうすると間違った結果を得ることになるので。 ◎ The above steps intentionally do not use the final MIME type as it would yield the wrong result.
各 `XMLHttpRequest$I ~objには、 `応答~obj@ が結付けられる — それは、[ ~obj, `失敗^i, ~NULL ]のいずれかをとり,他が言明されない限り ~NULL とする。 ◎ An XMLHttpRequest object has an associated response object (an object, failure, or null). Unless stated otherwise it is null.
`~arraybuffer応答@ は、次の手続きが返す値である: ◎ An arraybuffer response is the return value of these steps:
-
`応答~obj$ ~SET `受信-済み~byte列$を表現する,新たな `ArrayBuffer$I ~obj — ただし、例外が投出された場合は:
- `応答~obj$ ~SET `失敗^i
- ~RET ~NULL
注記: `ArrayBuffer$I ~objを割り当てることの成功-は保障されない。 `ECMASCRIPT$r ◎ Allocating an ArrayBuffer object is not guaranteed to succeed. [ECMASCRIPT]
- ~RET `応答~obj$ ◎ Return response object.
`~blob応答@ は、次の手続きが返す値である: ◎ A blob response is the return value of these steps:
- `応答~obj$ ~SET `受信-済み~byte列$を表現する,次のようにされた新たな `Blob$I ~obj ⇒ `~type0$m ~SET `最終~MIME型$ ◎ Set response object to a new Blob object representing received bytes with type set to the final MIME type.
- ~RET `応答~obj$ ◎ Return response object.
`文書~応答@ は、次の手続きが返す値(`文書$, または ~NULL )である: ◎ A document response is the return value of these steps:
- ~IF[ `応答$の`本体$rs ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If response’s body is null, then return null.
- ~IF[ `最終~MIME型$は、`~HTML~MIME型$でも, `~XML~MIME型$でもない ] ⇒ ~RET ~NULL ◎ If the final MIME type is not an HTML MIME type or an XML MIME type, then return null.
-
~IF[ `responseType$m ~EQ 空~文字列 ]~AND[ `最終~MIME型$は`~HTML~MIME型$である ] ⇒ ~RET ~NULL ◎ If responseType is the empty string and the final MIME type is an HTML MIME type, then return null.
注記: 旧来~内容を壊さないようにするため、ここでは `responseType$m は `document^l に制約される。 ◎ This is restricted to responseType being "document" in order to prevent breaking legacy content.
-
~IF[ `最終~MIME型$は`~HTML~MIME型$である ]: ◎ If the final MIME type is an HTML MIME type, then:
- %charset ~LET [ `最終~charset$ ~NEQ ~NULL ならば それ / ~ELSE_ [ `受信-済み~byte列$の最初の 1024 ~byteを 予走査して 成功裡に結果を得られた ]ならば その結果 / ~ELSE_ `~UTF-8$ ] ◎ Let charset be the final charset. ◎ If charset is null, prescan the first 1024 bytes of received bytes and if that does not terminate unsuccessfully then let charset be the return value. ◎ If charset is null, then set charset to UTF-8.
- %文書 ~LET 次の結果を表現する`文書$ ⇒ ~HTML標準の~HTML構文解析に~~定められた規則に従って,[ ~scriptは不能化し, 既知の確定的な符号化法 %charset ]の下で,`受信-済み~byte列$を構文解析した結果 `HTML$r ◎ Let document be a document that represents the result parsing 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.
-
~ELSE:
- %文書 ~LET 次の結果を表現する`文書$ ⇒ XML ~script~supportを不能化-した下で,`受信-済み~byte列$を XML 構文解析器 にかけた結果 `HTML$r
- ~IF[ 前~段にて 構文解析に失敗した(未~supportの文字~符号化法, 名前空間整形式~error, 等々) ] ⇒ ~RET ~NULL
注記: 文書から参照されている資源は読込まれず, 文書に結付けられている XSLT は適用されない。 ◎ Resources referenced will not be loaded and no associated XSLT will be applied.
- ~IF[ %charset ~EQ ~NULL ] ⇒ %charset ~SET `~UTF-8$ ◎ If charset is null, then set charset to UTF-8.
- %文書 の ⇒# `符号化法$ ~SET %charset, `内容型$ ~SET `最終~MIME型$, `~URL$ ~SET `応答$の`url$rs, `生成元$doc ~SET 此れに`関連する設定群~obj$の`生成元$enV ◎ Set document’s encoding to charset. ◎ Set document’s content type to the final MIME type. ◎ Set document’s URL to response’s url. ◎ Set document’s origin to context object’s relevant settings object’s origin.
- `応答~obj$ ~SET %文書 ◎ Set response object to document and return it.
- ~RET %文書 ◎ ↑
`~JSON応答@ は、次の手続きが返す値である: ◎ A JSON response is the return value of these steps:
- ~IF[ `応答$の`本体$rs ~EQ ~NULL ] ⇒ ~RET ~NULL ◎ If response’s body is null, then return null.
-
%~JSON~obj ~LET `~byte列を~JSONとして構文解析する$( `受信-済み~byte列$ )
例外が投出されたときは ⇒ ~RET ~NULL
◎ Let jsonObject be the result of running parse JSON from bytes on received bytes. If that threw an exception, then return null. - `応答~obj$ ~SET %~JSON~obj ◎ Set response object to jsonObject and return it.
- ~RET %~JSON~obj ◎ ↑
`~text応答@ は、次の手続きが返す値である: ◎ A text response is the return value of these steps:
- ~IF[ `応答$の`本体$rs ~EQ ~NULL ] ⇒ ~RET 空~文字列 ◎ If response’s body is null, then return the empty string.
- %charset ~LET `最終~charset$ ◎ Let charset be the final charset.
-
~IF[ `responseType$m ~EQ 空~文字列 ]~AND[ %charset ~EQ ~NULL ]~AND[ `最終~MIME型$は`~XML~MIME型$である ] ⇒ %charset ~LET XML 仕様に規定される規則に従って決定される符号化法 `XML$r `XMLNS$r ◎ If responseType is the empty string, charset is null, and the final MIME type 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] [XMLNS]
注記: 非旧来 `responseType$m 値 `text^l を単純なままに保つため、ここでは `responseType$m は空~文字列に制約される。 ◎ This is restricted to responseType being the empty string to keep the non-legacy responseType value "text" simple.
- ~IF[ %charset ~EQ ~NULL ] ⇒ %charset ~SET `~UTF-8$ ◎ If charset is null, then set charset to UTF-8.
- ~RET `~Unicodeに復号する$( %charset, `受信-済み~byte列$ ) ◎ Return the result of running decode on received bytes using fallback encoding charset.
注記: 作者には、資源を符号化する際には,常に`~UTF-8$ を用いることが強く奨励される。 ◎ Authors are strongly encouraged to always encode their resources using UTF-8.
4.6.7. `overrideMimeType()^m ~meth
- %client . `overrideMimeType(mime)$m
- `応答$の `Content-Type$h ~header値が %mime であったかのように動作する。 (実際に~headerを変更するわけではないが。) ◎ Acts as if the `Content-Type` header value for response is mime. (It does not actually change the header though.)
- `状態$ ~IN { `~loading^i, `~done^i } の場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if state is loading or done.
- `overrideMimeType(mime)@m
-
被呼出時には、次を走らせ~MUST: ◎ The overrideMimeType(mime) method, when invoked, must run these steps:
- ~IF[ `状態$ ~IN { `~loading^i, `~done^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If state is loading or done, then throw an "InvalidStateError" DOMException.
- `上書き~MIME型$ ~SET `~MIME型を構文解析する$( %mime ) ◎ Set override MIME type to the result of parsing mime.
- ~IF[ `上書き~MIME型$ ~EQ `失敗^i ] ⇒ `上書き~MIME型$ ~SET `application/octet-stream^lb ◎ If override MIME type is failure, then set override MIME type to application/octet-stream.
4.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.
- `状態$ ~IN { `~loading^i, `~done^i } の場合、 `InvalidStateError$E 例外が投出される。 ◎ When set: throws an "InvalidStateError" DOMException if state is loading or done.
- `同期~flag$ ~EQ ~ON, かつ `現在の大域~obj$は `Window$I ~objである場合、 `InvalidAccessError$E 例外が投出される。 ◎ When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
- `responseType@m
- 取得子は、最後に設定された値を返さ~MUST。 初期~時には空~文字列に設定され~MUST。 ◎ The responseType attribute must return its value. Initially its value must be the empty string.
-
属性の設定子は、次を走らせ~MUST: ◎ Setting the responseType attribute must run these steps:
- %W ~LET [ `現在の大域~obj$は `Window$I ~objであるならば ~T / ~ELSE_ ~F ] ◎ ↓
- ~IF[ %W ~EQ ~F ]~AND[ 所与の値 ~EQ `document^l ] ⇒ ~RET ◎ If current global object is not a Window object and the given value is "document", terminate these steps.
- ~IF[ `状態$ ~IN { `~loading^i, `~done^i } ] ⇒ ~THROW `InvalidStateError$E ◎ If state is loading or done, then throw an "InvalidStateError" DOMException.
- ~IF[ %W ~EQ ~T ]~AND[ `同期~flag$ ~EQ ~ON ] ⇒ ~THROW `InvalidAccessError$E ◎ If current global object is a Window object and the synchronous flag is set, then throw an "InvalidAccessError" DOMException.
- この属性の値 ~SET 所与の値 ◎ Set the responseType attribute’s value to the given value.
4.6.9. `response^m 属性
- %client . `response$m
- `応答$の`本体$rsを返す。 ◎ Returns the response’s body.
- `response@m
-
取得子は、次を走らせ~MUST: ◎ The response attribute must return the result of running these steps:
- %応答~種別 ~LET 此れの `responseType$m の値 ◎ ↓
- ~IF[ %応答~種別 ~IN { 空~文字列, `text^l } ] ⇒ ~RET[ `状態$ ~NIN { `~loading^i, `~done^i } ならば空~文字列 / ~ELSE_ `~text応答$ ] ◎ If responseType is the empty string or "text" ◎ • If state is not loading or done, return the empty string. ◎ • Return the text response.
- ~IF[ `状態$ ~NEQ `~done^i ] ⇒ ~RET ~NULL ◎ Otherwise ◎ If state is not done, return null.
- ~IF[ `応答~obj$ ~EQ `失敗^i ] ⇒ ~RET ~NULL ◎ If response object is failure, then return null.
- ~IF[ `応答~obj$ ~NEQ ~NULL ] ⇒ ~RET `応答~obj$ ◎ If response object is non-null, then return it.
- ~RET %応答~種別 に応じて ⇒# `arraybuffer^l ならば`~arraybuffer応答$ / `blob^l ならば`~blob応答$ / `document^l ならば`文書~応答$ / `json^l ならば`~JSON応答$ ◎ If responseType is "arraybuffer" • Return the arraybuffer response. If responseType is "blob" • Return the blob response. If responseType is "document" • Return the document response. If responseType is "json" • Return the JSON response.
4.6.10. `responseText^m 属性
- %client . `responseText$m
- `~text応答$を返す。 ◎ Returns the text response.
- `responseType$m ~NEQ 空~文字列, かつ ~NEQ `text^l の場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text".
- `responseText@m
-
取得子は、次を走らせ~MUST: ◎ The responseText attribute must return the result of running these steps:
- ~IF[ 此れの `responseType$m の値 ~NIN { 空~文字列, `text^l } ] ⇒ ~THROW `InvalidStateError$E ◎ If responseType is not the empty string or "text", then throw an "InvalidStateError" DOMException.
- ~RET[ `状態$ ~NIN { `~loading^i, `~done^i } ならば空~文字列 / ~ELSE_ `~text応答$ ] ◎ If state is not loading or done, then return the empty string. ◎ Return the text response.
4.6.11. `responseXML^m 属性
- %client . `responseXML$m
- `文書~応答$ を返す。 ◎ Returns the document response.
- `responseType$m 値が 空~文字列でも `document^l でもない場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if responseType is not the empty string or "document".
- `responseXML@m
-
取得子は、次を走らせ~MUST: ◎ The responseXML attribute must return the result of running these steps:
- ~IF[ 此れの `responseType$m 値 ~NIN { 空~文字列, `document^l } ] ⇒ ~THROW `InvalidStateError$E ◎ If responseType is not the empty string or "document", then throw an "InvalidStateError" DOMException.
- ~IF[ `状態$ ~NEQ `~done^i ] ⇒ ~RET ~NULL ◎ If state is not done, return null.
- ~Assert: `応答~obj$ ~NEQ `失敗^i ◎ Assert: response object is not failure.
- ~IF[ `応答~obj$ ~NEQ ~NULL ] ⇒ ~RET `応答~obj$ ◎ If response object is non-null, then return it.
- ~RET `文書~応答$ ◎ Return the document response.
4.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 ~methの呼出しなど。 ◎ 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). |
4.8. 特色機能~施策の統合
この仕様は、[ 文字列 `sync-xhr@l で識別される,`施策により制御される特色機能$ ]を定義する。 その`既定の許容list$は `*^c とする。 ◎ This specification defines a policy-controlled feature identified by the string "sync-xhr". Its default allowlist is *.
5. ~interface `FormData^I
typedef (`File$I or `USVString$) `FormDataEntryValue@I; [`FormData$mC(optional `HTMLFormElement$I %form), `Exposed$=(Window,Worker)] interface `FormData@I { void `append$m(`USVString$ %name, `USVString$ %value); void `append$m(`USVString$ %name, `Blob$I %value, optional `USVString$ %filename); void `delete$m(`USVString$ %name); `FormDataEntryValue$I? `get$m(`USVString$ %name); sequence<`FormDataEntryValue$I> `getAll$m(`USVString$ %name); boolean `has$m(`USVString$ %name); void `set$m(`USVString$ %name, `USVString$ %value); void `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.
- `FormData(form)@m
-
この構築子は、次を走らせ~MUST: ◎ The FormData(form) constructor must run these steps:
- %fd ~LET 新たな `FormData$I ~obj ◎ Let fd be a new FormData object.
- ~IF[ %form 引数は与えられている ] ⇒ %fd の`~entry~list$fe ~SET `~entry~listを構築する$( %form ) ◎ If form is given, then set fd’s entry list to the result of constructing the entry list for form.
- ~RET %fd ◎ Return fd.
- `append(name, value, filename)@m
-
被呼出時には、次を走らせ~MUST: ◎ The append(name, value) and append(name, blobValue, filename) methods, when invoked, must run these steps: ◎ Let value be value if given, and blobValue otherwise.
- %~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 the context object’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.
- `delete(name)@m
- 被呼出時には、次を走らせ~MUST ⇒ 此れの`~entry~list$feから 次を満たす`~entry$feをすべて`除去する$ ⇒ `名前$fe ~EQ %name ◎ The delete(name) method, when invoked, must remove all entries whose name is name from the context object’s entry list.
- `get(name)@m
- 被呼出時には、次を走らせ~MUST ⇒ ~RET 此れの`~entry~list$fe内に 次を満たす`~entry$feは[ 在るならば それらのうち最初のものの`値$fe / 無いならば ~NULL ] ⇒ `名前$fe ~EQ %name ◎ The get(name) method, when invoked, must return the value of the first entry whose name is name from the context object’s entry list, and null otherwise.
- `getAll(name)@m
- 被呼出時には、次を走らせ~MUST ⇒ ~RET 此れの`~entry~list$fe内の[ 次を満たす`~entry$feすべての`値$fe ]からなる同順の~list(存在しなければ空~list) ⇒ `名前$fe ~EQ %name ◎ The getAll(name) method, when invoked, must return the values of all entries whose name is name, in order, from the context object’s entry list, and the empty list otherwise.
- `has(name)@m
- 被呼出時には、次を走らせ~MUST ⇒ ~RET 此れの`~entry~list$fe内に 次を満たす`~entry$feは[ 在るならば ~T / 無いならば ~F ] ⇒ `名前$fe ~EQ %name ◎ The has(name) method, when invoked, must return true if there is an entry whose name is name in the context object’s entry list, and false otherwise.
- `set(name, value, filename)@m
-
被呼出時には、次を走らせ~MUST: ◎ The set(name, value) and set(name, blobValue, filename) methods, when invoked, must run these steps: ◎ Let value be value if given, and blobValue otherwise.
- %~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 any entries in the context object’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 the context object’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$の ( ~key, 値 ) は、此れの`~entry~list$feを成す各`~entry$feの ( `名前$fe, `値$fe ) で与えられるとする。 ◎ The value pairs to iterate over are the context object’s entry list’s entries with the key being the name and the value the value.
6. ~interface `ProgressEvent^I
[`ProgressEvent@mC(`DOMString$ %type, optional `ProgressEventInit$I %eventInitDict), `Exposed$=(Window,DedicatedWorker,SharedWorker)] interface `ProgressEvent@I : `Event$I { ~RA boolean `lengthComputable$m; ~RA unsigned long long `loaded$m; ~RA 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.
- `lengthComputable@m
- `loaded@m
- `total@m
- これらのいずれも,取得子は、それぞれの初期化-時の値を返さ~MUST。 ◎ The lengthComputable, loaded, and total attributes must return the value they were initialized to.
6.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.
【 %target を省略してこの手続きを呼出している所では、暗黙的に,その文脈における `XMLHttpRequest$I ~objを与えていると見受けられる。 】
6.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.
6.3. 保安~上の考慮点
非同一生成元~要請に対しては、例えば 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]
6.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.
謝辞
この標準に協力された、次の方々に感謝する:
Thanks to Addison Phillips, Adrian Bateman, Ahmed Kamel, Alan Thomas, Alex Hopmann, Alex Vincent, Alexey Proskuryakov, Ali Alabbas, Andrea Marchesini, Asbjørn Ulsberg, Bertrand Guay-Paquet, Björn Höhrmann, Boris Zbarsky, Caitlin Potter, Cameron McCormack, Chris Marrin, Christophe Jolif, Charles McCathieNevile, Dan Winship, David Andersson, David Flanagan, David Håsäther, David Levin, Dean Jackson, Denis Sureau, Domenic Denicola, Dominik Röttsches, Doug Schepers, Douglas Livingstone, Elliott Sprehn, Elliotte Harold, Eric Lawrence, Eric Uhrhane, Erik Arvidsson, Erik Dahlström, Feras Moussa, Geoffrey Sneddon, Gideon Cohn, Glenn Adams, Gorm Haug Eriksen, Håkon Wium Lie, Hallvord R. M. Steen, Henri Sivonen, Hiroshige Hayashizaki, Huub Schaeks, Ian Clelland, Ian Davis, Ian Hickson, Ivan Herman, Jake Archibald, Jared Jacobs, Jarred Nicholls, Jeff Walden, Jens Lindström, Jim Deegan, Jim Ley, Joe Farro, Jonas Sicking, Julian Reschke, 송정기 (Jungkee Song), 呂康豪 (Kang-Hao Lu), Karl Dubost, Keith Yeung, 田村健人 (Kent TAMURA), Lachlan Hunt, Maciej Stachowiak, Magnus Kristiansen, Manish Goregaokar, Marc Hadley, Marcos Caceres, Mark Baker, Mark Birbeck, Mark Nottingham, Mark S. Miller, Martin Hassman, Mohamed Zergaoui, Ms2ger, Odin Hørthe Omdal, Olli Pettay, Pawel Glowacki, Peter Michaux, Philip Jägenstedt, Philip Taylor, Robin Berjon, Rune F. Halvorsen, Ruud Steltenpool, Ryo Onodera, Sergiu Dumitriu, Shivakumar Jagalur Matt, Sigbjørn Finne, Simon Pieters, Stewart Brodie, Sunava Dutta, Takeshi Kurosawa, Takeshi Yoshino, Thomas Roessler, Thomas Wisniewski, Tom Magliery, Travis Leithead, triple-underscore, Yehuda Katz, Youenn Fablet, and Zhenbin Xu for their contributions to this standard.
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] ◎ 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).
Copyright © 2018 WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a Creative Commons Attribution 4.0 International License.