Annotation of 2006/webapi/XMLHttpRequest/Overview.html, revision 1.305
1.1 avankest 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.2 avankest 2:
1.25 avankest 3: <html lang=en-US>
1.1 avankest 4: <head>
1.209 avankest 5: <title>XMLHttpRequest</title>
1.2 avankest 6:
1.20 avankest 7: <style type="text/css">
1.118 avankest 8: pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
1.20 avankest 9: pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
1.60 avankest 10: pre code { color:inherit; background:transparent }
1.20 avankest 11: div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
1.90 avankest 12: .note { margin-left:2em; font-weight:bold; font-style:italic; color:#008000 }
1.20 avankest 13: p.note::before { content:"Note: " }
1.205 avankest 14: .XXX { padding:.5em; border:solid #f00 }
15: p.XXX::before { content:"Issue: " }
1.120 avankest 16: dl.switch { padding-left:2em }
1.250 avankest 17: dl.switch > dt { text-indent:-1.5em }
18: dl.switch > dt:before { content:'\21AA'; padding:0 0.5em 0 0; display:inline-block; width:1em; text-align:right; line-height:0.5em }
1.274 avankest 19: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
20: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
21: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
22: dl.domintro dd p { margin: 0.5em 0; }
23: dl.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
1.232 avankest 24: em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
25: dfn { font-weight:bold; font-style:normal }
26: code { color:orangered }
27: code :link, code :visited { color:inherit }
28: hr:not(.top) { display:block; background:none; border:none; padding:0; margin:2em 0; height:auto }
29: table { border-collapse:collapse; border-style:hidden hidden none hidden }
30: table thead { border-bottom:solid }
31: table tbody th:first-child { border-left:solid }
32: table td, table th { border-left:solid; border-right:solid; border-bottom:solid thin; vertical-align:top; padding:0.2em }
33: </style>
1.296 avankest 34: <link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel=stylesheet>
1.2 avankest 35:
1.1 avankest 36: <body>
1.25 avankest 37: <div class=head>
38: <p><a href="http://www.w3.org/"><img alt=W3C height=48
39: src="http://www.w3.org/Icons/w3c_home" width=72></a></p>
1.2 avankest 40:
1.231 avankest 41: <h1 class=head id=the-xmlhttprequest-object>XMLHttpRequest</h1>
1.2 avankest 42:
1.303 avankest 43: <h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 26 August 2010</h2>
1.2 avankest 44:
1.1 avankest 45: <dl>
1.154 avankest 46: <dt>This Version:
1.2 avankest 47:
48: <dd><a
1.303 avankest 49: href="http://www.w3.org/TR/2010/ED-XMLHttpRequest-20100826/">http://www.w3.org/TR/2010/ED-XMLHttpRequest-20100826/</a>
1.2 avankest 50:
1.14 avankest 51: <dt>Latest Version:
1.2 avankest 52:
53: <dd><a
54: href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a>
55:
1.190 avankest 56: <dt>Latest Editor Version:
57:
58: <dd><a
59: href="http://dev.w3.org/2006/webapi/XMLHttpRequest/">http://dev.w3.org/2006/webapi/XMLHttpRequest/</a>
60:
1.14 avankest 61: <dt>Previous Versions:
1.2 avankest 62:
63: <dd><a
1.296 avankest 64: href="http://www.w3.org/TR/2010/CR-XMLHttpRequest-20100803/">http://www.w3.org/TR/2010/CR-XMLHttpRequest-20100803/</a>
65:
66: <dd><a
1.293 avankest 67: href="http://www.w3.org/TR/2009/WD-XMLHttpRequest-20091119/">http://www.w3.org/TR/2009/WD-XMLHttpRequest-20091119/</a>
68:
69: <dd><a
1.233 avankest 70: href="http://www.w3.org/TR/2009/WD-XMLHttpRequest-20090820/">http://www.w3.org/TR/2009/WD-XMLHttpRequest-20090820/</a>
71:
72: <dd><a
1.174 avankest 73: href="http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415/">http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415/</a>
74:
75: <dd><a
1.155 avankest 76: href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20071026/">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20071026/</a>
77:
78: <dd><a
1.134 avankest 79: href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070618/">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070618/</a>
80:
81: <dd><a
1.60 avankest 82: href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/</a>
83:
84: <dd><a
1.25 avankest 85: href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/</a>
86:
87: <dd><a
1.2 avankest 88: href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/</a>
89:
90: <dd><a
91: href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/</a>
92:
93: <dt>Editor:
94:
95: <dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a> (<a
96: href="http://www.opera.com/">Opera Software ASA</a>) <<a
97: href="mailto:annevk@opera.com">annevk@opera.com</a>>
1.1 avankest 98: </dl>
1.2 avankest 99:
1.25 avankest 100: <p class=copyright><a
1.2 avankest 101: href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
1.231 avankest 102: © 2009 <a href="http://www.w3.org/"><acronym title="World Wide Web
1.53 avankest 103: Consortium">W3C</acronym></a><sup>®</sup> (<a
104: href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute
105: of Technology">MIT</acronym></a>, <a
106: href="http://www.ercim.org/"><acronym title="European Research Consortium
107: for Informatics and Mathematics">ERCIM</acronym></a>, <a
1.2 avankest 108: href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
109: href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
110: <a
111: href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
112: and <a
113: href="http://www.w3.org/Consortium/Legal/copyright-documents">document
114: use</a> rules apply.</p>
1.1 avankest 115: </div>
1.2 avankest 116:
117: <hr>
118:
1.25 avankest 119: <h2 class="no-num no-toc" id=specabstract>Abstract</h2>
1.2 avankest 120:
1.231 avankest 121: <p>The XMLHttpRequest specification defines an API that provides scripted
122: client functionality for transferring data between a client and a server.
1.25 avankest 123:
124: <h2 class="no-num no-toc" id=sotd>Status of this Document</h2>
1.2 avankest 125:
126: <p><em>This section describes the status of this document at the time of
127: its publication. Other documents may supersede this document. A list of
128: current W3C publications and the latest revision of this technical report
129: can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
1.173 avankest 130: index</a> at http://www.w3.org/TR/.</em>
1.2 avankest 131:
1.303 avankest 132: <p>This is the 26 August 2010 <!--Last Call Working Draft-->Editor's Draft
1.296 avankest 133: of XMLHttpRequest. Please send comments to <a
1.250 avankest 134: href="mailto:public-webapps@w3.org?subject=[XHR]%20">public-webapps@w3.org</a>
135: (<a
1.209 avankest 136: href="http://lists.w3.org/Archives/Public/public-webapps/">archived</a>)
1.250 avankest 137: with <samp>[XHR]</samp> at the start of the subject line.
1.49 avankest 138:
1.292 avankest 139: <p>For the last Last Call Working Draft the Working Group has kept a <a
140: href="http://dev.w3.org/2006/webapi/XMLHttpRequest/disposition-of-comments-3">disposition
1.295 avankest 141: of comments</a> document. A <a
142: href="http://dev.w3.org/cvsweb/2006/webapi/XMLHttpRequest/Overview.src.html">list
143: of changes</a> is available via a Web view of CVS. (Due to the way the
144: document is edited certain commit messages have introduced negligible
145: changes to this document and are in fact only relevant for XMLHttpRequest
146: Level 2.)
1.292 avankest 147:
1.49 avankest 148: <p>This document is produced by the <a
1.209 avankest 149: href="http://www.w3.org/2008/webapps/">Web Applications</a> (WebApps)
1.250 avankest 150: Working Group. The WebApps Working Group is part of the <a
1.209 avankest 151: href="http://www.w3.org/2006/rwc/Activity">Rich Web Clients Activity</a>
152: in the W3C <a href="http://www.w3.org/Interaction/">Interaction
1.250 avankest 153: Domain</a>.
1.2 avankest 154:
155: <p>This document was produced by a group operating under the <a
156: href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
1.54 avankest 157: 2004 W3C Patent Policy</a>. W3C maintains a <a
1.209 avankest 158: href="http://www.w3.org/2004/01/pp-impl/42538/status"
1.25 avankest 159: rel=disclosure>public list of any patent disclosures</a> made in
1.2 avankest 160: connection with the deliverables of the group; that page also includes
161: instructions for disclosing a patent. An individual who has actual
162: knowledge of a patent which the individual believes contains <a
163: href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
164: Claim(s)</a> must disclose the information in accordance with <a
165: href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
166: 6 of the W3C Patent Policy</a>.
167:
1.296 avankest 168: <p>Publication as a Working Draft does not imply endorsement by the W3C
169: Membership. This is a draft document and may be updated, replaced or
170: obsoleted by other documents at any time. It is inappropriate to cite this
171: document as other than work in progress.
1.250 avankest 172:
1.273 avankest 173: <h3 class="no-num no-toc" id=crec>Candidate Recommendation Exit Criteria</h3>
174:
175: <p>To exit the Candidate Recommendation (CR) stage the following criteria
176: <em class=ct>must</em> have been met:
177:
178: <ol>
179: <li>There will be at least two interoperable implementations passing all
1.291 avankest 180: test cases in the <a
181: href="http://test.w3.org/webapps/tests/XMLHttpRequest/info.htm">test
182: suite</a> for this specification. An implementation is to be available
183: (i.e. for download), shipping (i.e. not private), and not experimental
184: (i.e. intended for a wide audience). The working group will decide when
1.295 avankest 185: the test suite is of sufficient quality to test interoperability and will
186: produce implementation reports (hosted together with the test suite).
1.273 avankest 187:
1.296 avankest 188: <li>A minimum of six months of the CR stage will have elapsed. This is to
189: ensure that enough time is given for any remaining major errors to be
190: caught. The CR period will be extended if implementations are slow to
191: appear.</li>
192: <!-- XXX need to add date -->
1.287 avankest 193:
1.288 avankest 194: <li>Text, which can be in a separate document, exists that explains the
195: security considerations for this specification. This may be done in a
196: generic manner as they are most likely applicable to various APIs. The
197: working group will decide whether the text is of sufficient quality.
1.273 avankest 198: </ol>
199:
1.25 avankest 200: <h2 class="no-num no-toc" id=toc>Table of Contents</h2>
1.2 avankest 201: <!--begin-toc-->
202:
1.25 avankest 203: <ul class=toc>
1.248 avankest 204: <li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
1.154 avankest 205:
1.250 avankest 206: <li><a href="#conformance"><span class=secno>2. </span>Conformance
207: Criteria</a>
1.25 avankest 208: <ul class=toc>
1.248 avankest 209: <li><a href="#dependencies"><span class=secno>2.1.
1.154 avankest 210: </span>Dependencies</a>
1.2 avankest 211:
1.248 avankest 212: <li><a href="#terminology"><span class=secno>2.2. </span>Terminology</a>
213:
1.81 avankest 214:
1.248 avankest 215: <li><a href="#extensibility"><span class=secno>2.3.
1.154 avankest 216: </span>Extensibility</a>
217: </ul>
1.81 avankest 218:
1.250 avankest 219: <li><a href="#the-xmlhttprequest-interface"><span class=secno>3.
1.248 avankest 220: </span>The <code title="">XMLHttpRequest</code> Interface</a>
1.25 avankest 221: <ul class=toc>
1.250 avankest 222: <li><a href="#origin-and-base-url"><span class=secno>3.1. </span>Origin
1.205 avankest 223: and Base URL</a>
1.33 avankest 224:
1.250 avankest 225: <li><a href="#task-sources"><span class=secno>3.2. </span>Task
1.205 avankest 226: Sources</a>
227:
1.250 avankest 228: <li><a href="#constructors"><span class=secno>3.3.
1.213 avankest 229: </span>Constructors</a>
1.205 avankest 230:
1.250 avankest 231: <li><a href="#event-handler-attributes"><span class=secno>3.4.
1.207 avankest 232: </span>Event Handler Attributes</a>
1.205 avankest 233:
1.250 avankest 234: <li><a href="#states"><span class=secno>3.5. </span>States</a>
1.205 avankest 235:
1.250 avankest 236: <li><a href="#request"><span class=secno>3.6. </span>Request</a>
1.205 avankest 237: <ul class=toc>
1.250 avankest 238: <li><a href="#the-open-method"><span class=secno>3.6.1. </span>The
1.205 avankest 239: <code title="">open()</code> method</a>
240:
1.250 avankest 241: <li><a href="#the-setrequestheader-method"><span class=secno>3.6.2.
1.205 avankest 242: </span>The <code title="">setRequestHeader()</code> method</a>
243:
1.250 avankest 244: <li><a href="#the-send-method"><span class=secno>3.6.3. </span>The
1.205 avankest 245: <code title="">send()</code> method</a>
246:
1.214 avankest 247: <li><a href="#infrastructure-for-the-send-method"><span
1.250 avankest 248: class=secno>3.6.4. </span>Infrastructure for the <code
1.214 avankest 249: title="">send()</code> method</a>
250:
1.250 avankest 251: <li><a href="#the-abort-method"><span class=secno>3.6.5. </span>The
1.205 avankest 252: <code title="">abort()</code> method</a>
253: </ul>
254:
1.250 avankest 255: <li><a href="#response"><span class=secno>3.7. </span>Response</a>
1.205 avankest 256: <ul class=toc>
1.250 avankest 257: <li><a href="#the-status-attribute"><span class=secno>3.7.1.
1.248 avankest 258: </span>The <code title="">status</code> attribute</a>
1.205 avankest 259:
1.250 avankest 260: <li><a href="#the-statustext-attribute"><span class=secno>3.7.2.
1.205 avankest 261: </span>The <code title="">statusText</code> attribute</a>
262:
1.250 avankest 263: <li><a href="#the-getresponseheader-method"><span class=secno>3.7.3.
1.205 avankest 264: </span>The <code title="">getResponseHeader()</code> method</a>
265:
266: <li><a href="#the-getallresponseheaders-method"><span
1.250 avankest 267: class=secno>3.7.4. </span>The <code
1.205 avankest 268: title="">getAllResponseHeaders()</code> method</a>
269:
1.250 avankest 270: <li><a href="#response-entity-body0"><span class=secno>3.7.5.
1.205 avankest 271: </span>Response Entity Body</a>
272:
1.250 avankest 273: <li><a href="#the-responsetext-attribute"><span class=secno>3.7.6.
1.205 avankest 274: </span>The <code title="">responseText</code> attribute</a>
275:
1.250 avankest 276: <li><a href="#the-responsexml-attribute"><span class=secno>3.7.7.
1.205 avankest 277: </span>The <code title="">responseXML</code> attribute</a>
278: </ul>
1.242 avankest 279: </ul>
1.205 avankest 280:
1.250 avankest 281: <li><a href="#exceptions"><span class=secno>4. </span>Exceptions</a>
1.2 avankest 282:
1.250 avankest 283: <li class=no-num><a href="#references">References</a>
1.2 avankest 284:
1.131 avankest 285: <li class=no-num><a href="#acknowledgments">Acknowledgments</a>
1.2 avankest 286: </ul>
287: <!--end-toc-->
288:
1.248 avankest 289: <h2 id=introduction><span class=secno>1. </span>Introduction</h2>
1.2 avankest 290:
291: <p><em>This section is non-normative.</em>
292:
1.270 avankest 293: <p>The <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object
1.225 avankest 294: implements an interface exposed by a scripting engine that allows scripts
295: to perform HTTP client functionality, such as submitting form data or
296: loading data from a server. It is the ECMAScript HTTP API.
1.2 avankest 297:
1.270 avankest 298: <p>The name of the object is <a
299: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> for compatibility
300: with the Web, though each component of this name is potentially
301: misleading. First, the object supports any text based format, including
302: XML. Second, it can be used to make requests over both HTTP and HTTPS
303: (some implementations support protocols in addition to HTTP and HTTPS, but
304: that functionality is not covered by this specification). Finally, it
305: supports "requests" in a broad sense of the term as it pertains to HTTP;
306: namely all activity involved with HTTP requests or responses for the
307: defined HTTP methods.
1.2 avankest 308:
1.25 avankest 309: <div class=example>
1.18 avankest 310: <p>Some simple code to do something with data from an XML document fetched
311: over the network:</p>
312:
1.60 avankest 313: <pre><code>function test(data) {
1.18 avankest 314: // taking care of data
315: }
316:
317: function handler() {
1.118 avankest 318: if(this.readyState == 4 && this.status == 200) {
1.18 avankest 319: // so far so good
1.118 avankest 320: if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data)
321: // success!
1.18 avankest 322: test(this.responseXML.getElementById('test').firstChild.data);
323: else
324: test(null);
1.118 avankest 325: } else if (this.readyState == 4 && this.status != 200) {
1.18 avankest 326: // fetched the wrong page or network error...
327: test(null);
328: }
329: }
330:
331: var client = new XMLHttpRequest();
332: client.onreadystatechange = handler;
1.252 avankest 333: client.open("GET", "unicorn.xml");
1.60 avankest 334: client.send();</code></pre>
1.18 avankest 335:
1.58 avankest 336: <p>If you just want to log a message to the server:</p>
1.18 avankest 337:
1.60 avankest 338: <pre><code>function log(message) {
1.18 avankest 339: var client = new XMLHttpRequest();
1.58 avankest 340: client.open("POST", "/log");
1.59 avankest 341: client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
1.18 avankest 342: client.send(message);
1.60 avankest 343: }</code></pre>
1.18 avankest 344:
345: <p>Or if you want to check the status of a document on the server:</p>
346:
1.60 avankest 347: <pre><code>function fetchStatus(address) {
1.18 avankest 348: var client = new XMLHttpRequest();
349: client.onreadystatechange = function() {
350: // in case of network errors this might not give reliable results
351: if(this.readyState == 4)
352: returnStatus(this.status);
353: }
354: client.open("HEAD", address);
355: client.send();
1.60 avankest 356: }</code></pre>
1.18 avankest 357: </div>
1.2 avankest 358:
1.250 avankest 359: <h2 id=conformance><span class=secno>2. </span>Conformance Criteria</h2>
1.2 avankest 360:
1.29 avankest 361: <p>Everything in this specification is normative except for diagrams,
1.2 avankest 362: examples, notes and sections marked non-normative.
363:
1.25 avankest 364: <p>The key words <em class=ct>must</em>, <em class=ct>must not</em>, <em
1.261 avankest 365: class=ct>should</em>, <em class=ct>should not</em>, and <em
366: class=ct>may</em> in this document are to be interpreted as described in
367: RFC 2119. [<cite><a href="#ref-rfc2119">RFC2119</a></cite>]
1.2 avankest 368:
1.304 avankest 369: <p>This specification defines a single conformance class:
1.2 avankest 370:
371: <dl>
1.75 avankest 372: <dt><dfn id=conforming-user-agent>Conforming user agent</dfn>
1.2 avankest 373:
1.75 avankest 374: <dd>
375: <p>A user agent <em class=ct>must</em> behave as described in this
1.107 avankest 376: specification in order to be considered conformant.</p>
1.75 avankest 377:
1.141 avankest 378: <p>User agents <em class=ct>may</em> implement algorithms given in this
379: specification in any way desired, so long as the end result is
380: indistinguishable from the result that would be obtained by the
381: specification's algorithms.</p>
1.2 avankest 382:
1.96 avankest 383: <p class=note>This specification uses both the terms "conforming user
384: agent(s)" and "user agent(s)" to refer to this product class.</p>
1.2 avankest 385: </dl>
386:
1.248 avankest 387: <h3 id=dependencies><span class=secno>2.1. </span>Dependencies</h3>
1.2 avankest 388:
1.31 avankest 389: <p>This specification relies on several underlying specifications.
1.2 avankest 390:
1.31 avankest 391: <dl>
392: <dt>DOM
1.2 avankest 393:
1.31 avankest 394: <dd>
1.127 avankest 395: <p>A <a href="#conforming-user-agent" title="conforming user
1.177 avankest 396: agent">conforming user agent</a> <em class=ct>must</em> support at least
397: the subset of the functionality defined in DOM Events and DOM Core that
1.183 avankest 398: this specification relies upon, such as various exceptions and
399: <code>EventTarget</code>. [<cite><a
1.156 avankest 400: href="#ref-dom2events">DOM2Events</a></cite>] [<cite><a
401: href="#ref-dom3core">DOM3Core</a></cite>]
1.2 avankest 402:
1.252 avankest 403: <dt>HTML5
1.162 avankest 404:
405: <dd>
1.183 avankest 406: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
1.190 avankest 407: class=ct>must</em> support at least the subset of the functionality
1.252 avankest 408: defined in HTML5 that this specification relies upon, such as the basics
409: of the <code>Window</code> object and serializing a
1.198 avankest 410: <code>Document</code> object. [<cite><a
411: href="#ref-html5">HTML5</a></cite>]</p>
1.190 avankest 412:
1.162 avankest 413: <p class=note>The <a
414: href="http://www.w3.org/TR/2006/WD-Window-20060407/">Window Object
415: 1.0</a> draft is not referenced normatively as it appears to be no
1.252 avankest 416: longer maintained and HTML5 defines the <code>Window</code> object in
417: more detail. This specification already depends on HTML5 for other
418: reasons so there is not much additional overhead because of this.</p>
1.162 avankest 419:
1.31 avankest 420: <dt>HTTP
1.11 avankest 421:
1.31 avankest 422: <dd>
1.304 avankest 423: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
424: class=ct>must</em> support some version of the HTTP protocol.
425: Requirements regarding HTTP are made throughout the specification.
426: [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.182 avankest 427:
428: <dt>Web IDL
429:
1.250 avankest 430: <dd>
431: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
432: class=ct>must</em> also be a conforming implementation of the IDL
433: fragments in this specification, as described in the Web IDL
434: specification. [<cite><a href="#ref-webidl">WebIDL</a></cite>]
1.304 avankest 435:
436: <dt>XML
437:
438: <dd>
439: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
440: class=ct>must</em> be a conforming XML processor that reports violations
441: of namespace well-formedness. [<cite><a href="#ref-xml">XML</a></cite>]
1.31 avankest 442: </dl>
1.2 avankest 443:
1.248 avankest 444: <h3 id=terminology><span class=secno>2.2. </span>Terminology</h3>
1.211 avankest 445:
1.286 avankest 446: <p><dfn id=dfn-obtain-unicode>Convert a DOMString to a sequence of Unicode
1.235 avankest 447: characters</dfn> is defined by the Web IDL specification. [<cite><a
448: href="#ref-webidl">WebIDL</a></cite>]
449:
1.259 avankest 450: <p>The terms and algorithms <dfn
451: id=url-fragment><code><fragment></code></dfn>, <dfn
452: id=url-scheme><code><scheme></code></dfn>, <dfn
1.268 avankest 453: id=cookie-free-document-object>cookie-free <code>Document</code>
454: object</dfn>, <dfn id=document-base-url>document base URL</dfn>, <dfn
1.259 avankest 455: id=document-character-encoding>document's character encoding</dfn>, <dfn
456: id=event-handler-attributes-0>event handler attributes</dfn>, <dfn
457: id=event-handler-event-type>event handler event type</dfn>, <dfn
1.262 avankest 458: id=fetch>fetch</dfn>, <dfn id=fully-active>fully active</dfn>, <dfn
1.227 avankest 459: id=function><code>Function</code></dfn>, <dfn id=dom-innerhtml
460: title=dom-innerHTML><code>innerHTML</code></dfn>, <dfn
1.234 avankest 461: id=origin>origin</dfn>, <dfn id=preferred-mime-name>preferred MIME
462: name</dfn>, <dfn id=resolve-a-url>resolve a URL</dfn>, <dfn
1.227 avankest 463: id=same-origin>same origin</dfn>, <dfn id=storage-mutex>storage
464: mutex</dfn>, <dfn id=task>task</dfn>, <dfn id=task-source>task
1.254 avankest 465: source</dfn>, <dfn id=task-queues>task queues</dfn>, <dfn
466: id=url>URL</dfn>, <dfn id=url-character-encoding>URL character
467: encoding</dfn>, <dfn id=queue-a-task>queue a task</dfn>, and <dfn
468: id=valid-mime-type>valid MIME type</dfn> are defined by the HTML5
1.252 avankest 469: specification. [<cite><a href="#ref-html5">HTML5</a></cite>]
1.205 avankest 470:
471: <p>The term <dfn id=entity-body>entity body</dfn> is used as described in
472: RFC 2616. <dfn id=method-token>Method token</dfn> is used as described in
473: section 5.1.1 of RFC 2616. <dfn
474: id=field-name><code>field-name</code></dfn> and <dfn
475: id=field-value><code>field-value</code></dfn> are used as described in
1.250 avankest 476: section 4.2 of RFC 2616. [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.205 avankest 477:
1.260 avankest 478: <p>To <dfn id=deflate-a-domstring-into-a-byte-sequence>deflate a DOMString
479: into a byte sequence</dfn> means to create a sequence of bytes such that
480: the <var title="">n</var>th byte of the sequence is equal to the low-order
481: byte of the <var title="">n</var>th code point in the original DOMString.
482:
483: <p>To <dfn id=inflate-a-byte-sequence-into-a-domstring>inflate a byte
484: sequence into a DOMString</dfn> means to create a DOMString such that the
485: <var title="">n</var>th code point has 0x00 as the high-order byte and the
486: <var title="">n</var>th byte of the byte sequence as the low-order byte.
1.258 avankest 487:
1.205 avankest 488: <p><dfn id=userinfo><code>userinfo</code></dfn> is used as described in
489: section 3.2.1 of RFC 3986. [<cite><a
490: href="#ref-rfc3986">RFC3986</a></cite>]
491:
492: <p>To <dfn id=dispatch-readystatechange-event>dispatch a
493: <code>readystatechange</code> event</dfn> means that an event with the
1.278 avankest 494: name <code title=event-xhr-readystatechange>readystatechange</code>, which
495: does not bubble and is not cancelable, and which uses the
496: <code>Event</code> interface, is to be dispatched at the <a
1.270 avankest 497: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object.
1.156 avankest 498:
1.248 avankest 499: <h3 id=extensibility><span class=secno>2.3. </span>Extensibility</h3>
1.2 avankest 500:
1.252 avankest 501: <p>User agents, Working Groups, and other interested parties are
502: <em>strongly encouraged</em> to discuss extensions on a relevant public
503: forum, preferably <a
504: href="mailto:public-webapps@w3.org">public-webapps@w3.org</a>. If this is
505: for some reason not possible prefix the extension in some way and start
506: the prefix with an uppercase letter. E.g. if company Foo wants to add a
507: private method <code>bar()</code> it could be named <code>FooBar()</code>
508: to prevent clashes with a potential future standardized
509: <code>bar()</code>.
1.2 avankest 510:
1.250 avankest 511: <h2 id=the-xmlhttprequest-interface><span class=secno>3. </span>The <code
1.225 avankest 512: title="">XMLHttpRequest</code> Interface</h2>
1.2 avankest 513:
1.270 avankest 514: <p>The <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object can
1.225 avankest 515: be used by scripts to programmatically connect to their originating server
516: via HTTP.
1.2 avankest 517:
1.230 avankest 518: <pre class=idl>[NoInterfaceObject]
519: interface <dfn id=xmlhttprequesteventtarget>XMLHttpRequestEventTarget</dfn> : EventTarget {
520: // for future use
521: };
522:
1.242 avankest 523: [<a href="#dom-xmlhttprequest" title=dom-XMLHttpRequest>Constructor</a>]
1.230 avankest 524: interface <dfn id=xmlhttprequest>XMLHttpRequest</dfn> : <a href="#xmlhttprequesteventtarget">XMLHttpRequestEventTarget</a> {
1.208 avankest 525: // <a href="#event-handler-attributes">event handler attributes</a>
1.278 avankest 526: attribute <a href="#function">Function</a> <a href="#handler-xhr-onreadystatechange" title=handler-xhr-onreadystatechange>onreadystatechange</a>;
1.60 avankest 527:
1.208 avankest 528: // <a href="#states">states</a>
1.277 avankest 529: const unsigned short <a href="#dom-xmlhttprequest-unsent" title=dom-XMLHttpRequest-UNSENT>UNSENT</a> = 0;
530: const unsigned short <a href="#dom-xmlhttprequest-opened" title=dom-XMLHttpRequest-OPENED>OPENED</a> = 1;
531: const unsigned short <a href="#dom-xmlhttprequest-headers_received" title="dom-XMLHttpRequest-HEADERS_RECEIVED">HEADERS_RECEIVED</a> = 2;
532: const unsigned short <a href="#dom-xmlhttprequest-loading" title=dom-XMLHttpRequest-LOADING>LOADING</a> = 3;
533: const unsigned short <a href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a> = 4;
1.282 avankest 534: readonly attribute unsigned short <a href="#dom-xmlhttprequest-readystate" title=dom-XMLHttpRequest-readyState>readyState</a>;
1.60 avankest 535:
1.207 avankest 536: // <a href="#request">request</a>
1.279 avankest 537: void <a href="#dom-xmlhttprequest-open" title=dom-XMLHttpRequest-open>open</a>(DOMString <var>method</var>, DOMString <var title="">url</var>);
538: void <a href="#dom-xmlhttprequest-open" title=dom-XMLHttpRequest-open>open</a>(DOMString <var>method</var>, DOMString <var title="">url</var>, boolean <var>async</var>);
539: void <a href="#dom-xmlhttprequest-open" title=dom-XMLHttpRequest-open>open</a>(DOMString <var>method</var>, DOMString <var title="">url</var>, boolean <var>async</var>, DOMString? <var>user</var>);
540: void <a href="#dom-xmlhttprequest-open" title=dom-XMLHttpRequest-open>open</a>(DOMString <var>method</var>, DOMString <var title="">url</var>, boolean <var>async</var>, DOMString? <var>user</var>, DOMString? <var>password</var>);
1.284 avankest 541: void <a href="#dom-xmlhttprequest-setrequestheader" title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader</a>(DOMString <var>header</var>, DOMString <var>value</var>);
1.276 avankest 542: void <a href="#dom-xmlhttprequest-send" title=dom-XMLHttpRequest-send>send</a>();
543: void <a href="#dom-xmlhttprequest-send" title=dom-XMLHttpRequest-send>send</a>(Document <var>data</var>);
544: void <a href="#dom-xmlhttprequest-send" title=dom-XMLHttpRequest-send>send</a>([AllowAny] DOMString? <var>data</var>);
1.280 avankest 545: void <a href="#dom-xmlhttprequest-abort" title=dom-XMLHttpRequest-abort>abort</a>();
1.60 avankest 546:
1.207 avankest 547: // <a href="#response">response</a>
1.281 avankest 548: readonly attribute unsigned short <a href="#dom-xmlhttprequest-status" title=dom-XMLHttpRequest-status>status</a>;
549: readonly attribute DOMString <a href="#dom-xmlhttprequest-statustext" title=dom-XMLHttpRequest-statusText>statusText</a>;
1.283 avankest 550: DOMString <a href="#dom-xmlhttprequest-getresponseheader" title=dom-XMLHttpRequest-getResponseHeader>getResponseHeader</a>(DOMString <var>header</var>);
1.298 avankest 551: DOMString <a href="#dom-xmlhttprequest-getallresponseheaders" title=dom-XMLHttpRequest-getAllResponseHeaders>getAllResponseHeaders</a>();
1.281 avankest 552: readonly attribute DOMString <a href="#dom-xmlhttprequest-responsetext" title=dom-XMLHttpRequest-responseText>responseText</a>;
553: readonly attribute Document <a href="#dom-xmlhttprequest-responsexml" title=dom-XMLHttpRequest-responseXML>responseXML</a>;
1.230 avankest 554: };</pre>
1.2 avankest 555:
1.250 avankest 556: <h3 id=origin-and-base-url><span class=secno>3.1. </span>Origin and Base
1.248 avankest 557: URL</h3>
1.205 avankest 558:
1.270 avankest 559: <p>Each <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object
1.225 avankest 560: has an associated <dfn
1.205 avankest 561: id=xmlhttprequest-origin><code>XMLHttpRequest</code> origin</dfn> and an
562: <dfn id=xmlhttprequest-base-url><code>XMLHttpRequest</code> base
563: URL</dfn>.
564:
565: <p>This specification defines their values when the global object is
1.270 avankest 566: represented by the <code>Window</code> object. When the <a
567: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object is used in
568: other contexts their values will have to be defined as appropriate for
569: that context. That is considered to be out of scope for this
570: specification.
1.205 avankest 571:
572: <p>In environments where the global object is represented by the
1.270 avankest 573: <code>Window</code> object the <a
574: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object has an
575: associated <dfn id=xmlhttprequest-document><code>XMLHttpRequest</code>
1.205 avankest 576: <code>Document</code></dfn> which is the <code>Document</code> object
1.270 avankest 577: associated with the <code>Window</code> object for which the <a
578: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> interface object
579: was created.
1.205 avankest 580:
581: <p class=note>The <a
582: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
583: <code>Document</code></a> is used to determine the <a
584: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a> and
585: <a href="#xmlhttprequest-base-url"><code>XMLHttpRequest</code> base
1.245 avankest 586: URL</a> at a later stage.
1.205 avankest 587:
1.250 avankest 588: <h3 id=task-sources><span class=secno>3.2. </span>Task Sources</h3>
1.205 avankest 589:
1.253 avankest 590: <p>The <a href="#task-source">task source</a> used by this specification is
591: the <dfn id=xmlhttprequest-task-source><code>XMLHttpRequest</code> task
592: source</dfn>.
1.205 avankest 593:
1.250 avankest 594: <h3 id=constructors><span class=secno>3.3. </span>Constructors</h3>
1.205 avankest 595:
1.275 avankest 596: <dl class=domintro>
597: <dt><var title="">client</var> = new <a href="#dom-xmlhttprequest"><code
598: title=dom-XMLHttpRequest>XMLHttpRequest</code></a>()
599:
600: <dd>Returns a new <a
601: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object.
602: </dl>
603:
1.271 avankest 604: <p>When the <dfn id=dom-xmlhttprequest
605: title=dom-XMLHttpRequest><code>XMLHttpRequest()</code></dfn> constructor
606: is invoked, the user agent <em class=ct>must</em> return a new <a
1.270 avankest 607: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object.
1.205 avankest 608:
1.250 avankest 609: <h3 id=event-handler-attributes><span class=secno>3.4. </span>Event Handler
1.207 avankest 610: Attributes</h3>
611:
612: <p>The following is the <a href="#event-handler-attributes-0" title="event
613: handler attributes">event handler attribute</a> (and its corresponding <a
614: href="#event-handler-event-type">event handler event type</a>) that <em
1.270 avankest 615: class=ct>must</em> be supported as DOM attribute by the <a
616: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object:
1.207 avankest 617:
618: <table>
619: <thead>
620: <tr>
621: <th><a href="#event-handler-attributes-0" title="event handler
622: attributes">event handler attribute</a>
623:
624: <th><a href="#event-handler-event-type">event handler event type</a>
625:
626: <tbody>
627: <tr>
1.278 avankest 628: <td><dfn id=handler-xhr-onreadystatechange
629: title=handler-xhr-onreadystatechange><code>onreadystatechange</code></dfn>
630:
1.207 avankest 631:
1.278 avankest 632: <td><code title=event-xhr-readystatechange>readystatechange</code>
1.207 avankest 633: </table>
634:
1.250 avankest 635: <h3 id=states><span class=secno>3.5. </span>States</h3>
1.205 avankest 636:
1.282 avankest 637: <dl class=domintro>
638: <dt><var title="">client</var> . <a
639: href="#dom-xmlhttprequest-readystate"><code
640: title=dom-XMLHttpRequest-readyState>readyState</code></a>
641:
642: <dd>
643: <p>Returns the current state.
644: </dl>
645:
1.270 avankest 646: <p>The <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object can
1.282 avankest 647: be in several states. The <dfn id=dom-xmlhttprequest-readystate
648: title=dom-XMLHttpRequest-readyState><code>readyState</code></dfn>
649: attribute <em class=ct>must</em> return the current state, which <em
650: class=ct>must</em> be one of the following values:
1.205 avankest 651:
652: <dl>
1.277 avankest 653: <dt><dfn id=dom-xmlhttprequest-unsent
654: title=dom-XMLHttpRequest-UNSENT><code>UNSENT</code></dfn> (numeric value
655: 0)
1.125 avankest 656:
1.205 avankest 657: <dd>
658: <p>The object has been constructed.
659:
1.277 avankest 660: <dt><dfn id=dom-xmlhttprequest-opened
661: title=dom-XMLHttpRequest-OPENED><code>OPENED</code></dfn> (numeric value
662: 1)
1.205 avankest 663:
664: <dd>
1.279 avankest 665: <p>The <a href="#dom-xmlhttprequest-open"><code
666: title=dom-XMLHttpRequest-open>open()</code></a> method has been
667: successfully invoked. During this state request headers can be set using
1.284 avankest 668: <a href="#dom-xmlhttprequest-setrequestheader"><code
669: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.275 avankest 670: and the request can be made using the <a
1.276 avankest 671: href="#dom-xmlhttprequest-send"><code
672: title=dom-XMLHttpRequest-send>send()</code></a> method.
1.89 avankest 673:
1.277 avankest 674: <dt><dfn id="dom-xmlhttprequest-headers_received"
675: title="dom-XMLHttpRequest-HEADERS_RECEIVED"><code>HEADERS_RECEIVED</code></dfn>
676: (numeric value 2)
1.89 avankest 677:
1.205 avankest 678: <dd>
1.259 avankest 679: <p>All redirects (if any) have been followed and all HTTP headers of the
680: final response have been received. Several response members of the
1.205 avankest 681: object are now available.
1.91 avankest 682:
1.277 avankest 683: <dt><dfn id=dom-xmlhttprequest-loading
684: title=dom-XMLHttpRequest-LOADING><code>LOADING</code></dfn> (numeric
685: value 3)
1.112 avankest 686:
1.205 avankest 687: <dd>
688: <p>The <a href="#response-entity-body">response entity body</a> is being
689: received.
1.91 avankest 690:
1.277 avankest 691: <dt><dfn id=dom-xmlhttprequest-done
692: title=dom-XMLHttpRequest-DONE><code>DONE</code></dfn> (numeric value 4)
1.119 avankest 693:
1.205 avankest 694: <dd>
695: <p>The data transfer has been completed or something went wrong during
696: the transfer (e.g. infinite redirects).
697: </dl>
1.116 avankest 698:
1.277 avankest 699: <p>The <a href="#dom-xmlhttprequest-opened"
700: title=dom-XMLHttpRequest-OPENED>OPENED</a> state has an associated <dfn
701: id=send-flag><code>send()</code> flag</dfn> that indicates whether the <a
702: href="#dom-xmlhttprequest-send"><code
1.276 avankest 703: title=dom-XMLHttpRequest-send>send()</code></a> method has been invoked.
704: It can be either true or false and has an initial value of false.
1.205 avankest 705:
1.277 avankest 706: <p>The <a href="#dom-xmlhttprequest-done"
707: title=dom-XMLHttpRequest-DONE>DONE</a> state has an associated <dfn
708: id=error-flag>error flag</dfn> that indicates some type of network error
709: or abortion. It can be either true or false and has an initial value of
710: false.
1.205 avankest 711:
1.250 avankest 712: <h3 id=request><span class=secno>3.6. </span>Request</h3>
1.112 avankest 713:
1.270 avankest 714: <p>The <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object
1.225 avankest 715: holds the following request metadata variables:
1.112 avankest 716:
1.206 avankest 717: <dl>
718: <dt>The <dfn id=asynchronous-flag>asynchronous flag</dfn>
719:
1.271 avankest 720: <dd>True when <a href="#fetch" title=fetch>fetching</a> is done
721: asychronously. False when fetching is done synchronously.
1.206 avankest 722:
723: <dt>The <dfn id=request-method>request method</dfn>
724:
725: <dd>The method used in the request.
726:
727: <dt>The <dfn id=request-url>request URL</dfn>
728:
729: <dd>The <a href="#url">URL</a> used in the request.
730:
731: <dt>The <dfn id=request-username>request username</dfn>
732:
733: <dd>The username used in the request or null if there is no username.
734:
735: <dt>The <dfn id=request-password>request password</dfn>
736:
737: <dd>The password used in the request or null if there is no password.
1.112 avankest 738:
1.206 avankest 739: <dt>The <dfn id=author-request-headers>author request headers</dfn>
1.112 avankest 740:
1.206 avankest 741: <dd>A list consisting of HTTP header name/value pairs to be used in the
742: request.
1.112 avankest 743:
1.206 avankest 744: <dt>The <dfn id=request-entity-body>request entity body</dfn>
1.112 avankest 745:
1.206 avankest 746: <dd>The <a href="#entity-body">entity body</a> used in the request.
747: </dl>
1.205 avankest 748:
1.250 avankest 749: <h4 id=the-open-method><span class=secno>3.6.1. </span>The <code
1.205 avankest 750: title="">open()</code> method</h4>
751:
1.274 avankest 752: <dl class=domintro>
1.275 avankest 753: <dt><var title="">client</var> . <a href="#dom-xmlhttprequest-open"><code
1.279 avankest 754: title=dom-XMLHttpRequest-open>open(<var title="">method</var>, <var
755: title="">url</var>, <var title="">async</var>, <var title="">user</var>,
756: <var title="">password</var>)</code></a>
1.274 avankest 757:
758: <dd>
759: <p>Sets the <a href="#request-method">request method</a>, <a
760: href="#request-url">request URL</a>, <a
761: href="#asynchronous-flag">asynchronous flag</a>, <a
762: href="#request-username">request username</a>, and <a
1.285 avankest 763: href="#request-password">request password</a>.</p>
764:
765: <p>Throws a <code>SYNTAX_ERR</code> exception if one of the following is
766: true:</p>
767:
768: <ul>
769: <li><var title="">method</var> is not a valid HTTP method.
770:
771: <li><var title="">url</var> cannot be resolved.
772:
773: <li><var title="">url</var> contains the <code>"user:password"</code>
774: format in the <a href="#userinfo"><code>userinfo</code></a> production.
775: </ul>
776:
777: <p>Throws a <a href="#security-err"><code>SECURITY_ERR</code></a>
778: exception if <var title="">method</var> is a case-insensitive match for
779: <code>CONNECT</code>, <code>TRACE</code> or <code>TRACK</code>.</p>
780:
1.286 avankest 781: <p>Throws a <code>NOT_SUPPORTED_ERR</code> exception if the <a
782: href="#url-scheme"><code><scheme></code></a> of <var
783: title="">url</var> is not supported.</p>
1.305 ! avankest 784:
! 785: <p>Throws an <code>INVALID_ACCESS_ERR</code> exception if either <var
! 786: title="">user</var> or <var title="">password</var> is passed as
! 787: argument and the <a href="#origin">origin</a> of <var title="">url</var>
! 788: does not match the <a
! 789: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>.</p>
1.274 avankest 790: </dl>
791:
1.275 avankest 792: <p>When the <dfn id=dom-xmlhttprequest-open
1.279 avankest 793: title=dom-XMLHttpRequest-open><code>open(<var title="">method</var>, <var
794: title="">url</var>, <var title="">async</var>, <var title="">user</var>,
795: <var title="">password</var>)</code></dfn> method is invoked, the user
796: agent <em class=ct>must</em> run these steps (unless otherwise indicated):
1.112 avankest 797:
1.205 avankest 798: <ol>
799: <li>
1.270 avankest 800: <p>If the <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a>
1.225 avankest 801: object has an associated <a
1.205 avankest 802: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
803: <code>Document</code></a> run these substeps:</p>
1.112 avankest 804:
1.205 avankest 805: <ol>
806: <li>
807: <p>If the <a
808: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
809: <code>Document</code></a> is not <a href="#fully-active">fully
810: active</a> raise an <code>INVALID_STATE_ERR</code> exception and
811: terminate the overall set of steps.
812:
813: <li>
814: <p>Let <a href="#xmlhttprequest-base-url"><code>XMLHttpRequest</code>
815: base URL</a> be the <a href="#document-base-url">document base URL</a>
816: of the <a href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
817: <code>Document</code></a>.
818:
819: <li>
820: <p>Let <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
821: origin</a> be the <a href="#origin">origin</a> of the <a
822: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
823: <code>Document</code></a>.
824: </ol>
1.112 avankest 825:
826: <li>
1.258 avankest 827: <p>If any code point in <var>method</var> is higher than U+00FF LATIN
1.299 avankest 828: SMALL LETTER Y WITH DIAERESIS or after <a
829: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
830: DOMString into a byte sequence">deflating</a> <var>method</var> it does
831: not match the <a href="#method-token">Method token</a> production raise
832: a <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
833: let <var>method</var> be the result of <a
834: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
835: DOMString into a byte sequence">deflating</a> <var>method</var>.
1.258 avankest 836: </li>
837: <!-- This sounds lame, but it works. -->
1.91 avankest 838:
839: <li>
1.258 avankest 840: <p>If <var>method</var> is a case-insensitive match for
841: <code>CONNECT</code>, <code>DELETE</code>, <code>GET</code>,
842: <code>HEAD</code>, <code>OPTIONS</code>, <code>POST</code>,
843: <code>PUT</code>, <code>TRACE</code>, or <code>TRACK</code> subtract
844: 0x20 from each byte in the range 0x61 (ASCII a) to 0x7A (ASCII z).</p>
1.205 avankest 845:
846: <p class=note>If it does not match any of the above, it is passed through
847: <em>literally</em>, including in the final request.</p>
848: </li>
849: <!-- WebKit (and supposedly Gecko) also uppercase: COPY, INDEX, LOCK,
850: M-POST, MKCOL, MOVE, PROPFIND, PROPPATCH, and UNLOCK. -->
1.89 avankest 851:
1.205 avankest 852: <li>
1.258 avankest 853: <p>If <var>method</var> is a case-sensitive match for
1.261 avankest 854: <code>CONNECT</code>, <code>TRACE</code>, or <code>TRACK</code> raise a
1.270 avankest 855: <a href="#security-err"><code>SECURITY_ERR</code></a> exception and
1.261 avankest 856: terminate these steps.</p>
1.164 avankest 857:
1.205 avankest 858: <p class=note>Allowing these methods poses a security risk. [<cite><a
859: href="#ref-httpverbsec">HTTPVERBSEC</a></cite>]</p>
1.89 avankest 860:
1.91 avankest 861: <li>
1.205 avankest 862: <p>Let <var title="">url</var> be a <a href="#url">URL</a>.
1.89 avankest 863:
864: <li>
1.205 avankest 865: <p>Let <a href="#url-character-encoding">URL character encoding</a> of
866: <var title="">url</var> be UTF-8.
1.89 avankest 867:
868: <li>
1.257 avankest 869: <p><a href="#resolve-a-url" title="Resolve a URL">Resolve</a> <var
870: title="">url</var> relative to the <a
1.205 avankest 871: href="#xmlhttprequest-base-url"><code>XMLHttpRequest</code> base
872: URL</a>. If the algorithm returns an error raise a
873: <code>SYNTAX_ERR</code> exception and terminate these steps.
874: </li>
875: <!-- Presto and Gecko override the encoding. WebKit does not. Trident
876: does not support non-ASCII URLs. This matters for the <query> component,
877: see HTML5. -->
1.129 avankest 878:
1.205 avankest 879: <li>
1.270 avankest 880: <p>Drop <a href="#url-fragment"><code><fragment></code></a> from <var
1.205 avankest 881: title="">url</var>.
1.89 avankest 882:
883: <li>
1.270 avankest 884: <p>If <var title="">url</var> contains an unsupported <a
885: href="#url-scheme"><code><scheme></code></a> raise a
1.205 avankest 886: <code>NOT_SUPPORTED_ERR</code> and terminate these steps.
1.89 avankest 887:
1.205 avankest 888: <li>
1.270 avankest 889: <p>If the <code>"user:password"</code> format in the <a
890: href="#userinfo"><code>userinfo</code></a> production is not supported
891: for the relevant scheme and <var title="">url</var> contains this format
892: raise a <code>SYNTAX_ERR</code> and terminate these steps.
1.2 avankest 893:
1.205 avankest 894: <li>
895: <p>If <var title="">url</var> contains the <code>"user:password"</code>
896: format let <var>temp user</var> be the user part and <var>temp
897: password</var> be the password part.
1.2 avankest 898:
1.205 avankest 899: <li>
900: <p>If <var title="">url</var> just contains the <code>"user"</code>
901: format let <var>temp user</var> be the user part.
1.2 avankest 902:
1.205 avankest 903: <li>
904: <p>Let <var>async</var> be the value of the <var>async</var> argument or
1.271 avankest 905: true if it was omitted.
1.2 avankest 906:
1.205 avankest 907: <li>
1.305 ! avankest 908: <p>If the <var title="">user</var> argument was not omitted follow these
! 909: sub steps:</p>
1.2 avankest 910:
1.60 avankest 911: <ol>
912: <li>
1.305 ! avankest 913: <p>If <var title="">user</var> is not null and the <a
! 914: href="#origin">origin</a> of <var title="">url</var> is not <a
! 915: href="#same-origin">same origin</a> with the <a
! 916: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>
! 917: raise an <code>INVALID_ACCESS_ERR</code> exception and terminate the
! 918: overall set of steps.
1.2 avankest 919:
1.60 avankest 920: <li>
1.305 ! avankest 921: <p>Let <var>temp user</var> be <var>user</var>.
1.205 avankest 922: </ol>
1.184 avankest 923:
1.205 avankest 924: <p class=note>These steps override anything that may have been set by the
925: <var title="">url</var> argument.</p>
1.157 avankest 926:
1.205 avankest 927: <li>
1.305 ! avankest 928: <p>If the <var title="">password</var> argument was not omitted follow
! 929: these sub steps:</p>
1.2 avankest 930:
1.205 avankest 931: <ol>
1.60 avankest 932: <li>
1.305 ! avankest 933: <p>If <var title="">password</var> is not null and the <a
! 934: href="#origin">origin</a> of <var title="">url</var> is not <a
! 935: href="#same-origin">same origin</a> with the <a
! 936: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>
! 937: raise an <code>INVALID_ACCESS_ERR</code> exception and terminate the
! 938: overall set of steps.
1.2 avankest 939:
1.60 avankest 940: <li>
1.305 ! avankest 941: <p>Let <var>temp password</var> be <var>password</var>.
1.205 avankest 942: </ol>
1.102 avankest 943:
1.205 avankest 944: <p class=note>These steps override anything that may have been set by the
945: <var title="">url</var> argument.</p>
1.2 avankest 946:
1.205 avankest 947: <li>
948: <p><a href="#abort-send-algorithm" title="abort send()">Abort the
949: <code>send()</code> algorithm</a>.
1.2 avankest 950:
1.205 avankest 951: <li>
952: <p>The user agent <em class=ct>should</em> cancel any network activity
953: for which the object is responsible.
954: </li>
955: <!-- we can hardly require it... -->
1.24 avankest 956:
1.205 avankest 957: <li>
1.254 avankest 958: <p>If there are any <a href="#task" title=task>tasks</a> from the
959: object's <a
960: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
961: source</a> in one of the <a href="#task-queues">task queues</a>, then
962: remove those tasks.
963:
964: <li>
1.205 avankest 965: <p>Set variables associated with the object as follows:</p>
1.70 avankest 966:
1.205 avankest 967: <ul>
1.60 avankest 968: <li>
1.205 avankest 969: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to false.
1.60 avankest 970:
971: <li>
1.205 avankest 972: <p>Set <a href="#response-entity-body">response entity body</a> to
973: null.
1.60 avankest 974:
975: <li>
1.205 avankest 976: <p>Empty the list of <a href="#author-request-headers">author request
977: headers</a>.</p>
1.17 avankest 978:
1.60 avankest 979: <li>
1.205 avankest 980: <p>Set the <a href="#request-method">request method</a> to
981: <var>method</var>.
1.17 avankest 982:
1.60 avankest 983: <li>
1.205 avankest 984: <p>Set the <a href="#request-url">request URL</a> to <var
985: title="">url</var>.
1.17 avankest 986:
1.60 avankest 987: <li>
1.205 avankest 988: <p>Set the <a href="#request-username">request username</a> to
989: <var>temp user</var>.
1.17 avankest 990:
1.60 avankest 991: <li>
1.205 avankest 992: <p>Set the <a href="#request-password">request password</a> to
993: <var>temp password</var>.
1.17 avankest 994:
1.60 avankest 995: <li>
1.271 avankest 996: <p>Set the <a href="#asynchronous-flag">asynchronous flag</a> to the
997: value of <var>async</var>.
1.205 avankest 998: </ul>
1.44 avankest 999:
1.205 avankest 1000: <li>
1.277 avankest 1001: <p>Switch the the state to <a href="#dom-xmlhttprequest-opened"
1002: title=dom-XMLHttpRequest-OPENED>OPENED</a>.
1.176 avankest 1003:
1.205 avankest 1004: <li>
1005: <p><a href="#dispatch-readystatechange-event">Dispatch a
1006: <code>readystatechange</code> event</a>.
1007: </ol>
1.22 avankest 1008:
1.250 avankest 1009: <h4 id=the-setrequestheader-method><span class=secno>3.6.2. </span>The
1.248 avankest 1010: <code title="">setRequestHeader()</code> method</h4>
1.275 avankest 1011:
1012: <dl class=domintro>
1.284 avankest 1013: <dt><var title="">client</var> . <a
1014: href="#dom-xmlhttprequest-setrequestheader"><code
1015: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader(<var
1016: title="">header</var>, <var title="">value</var>)</code></a>
1.275 avankest 1017:
1018: <dd>
1019: <p>Appends an header to the list of <a
1020: href="#author-request-headers">author request headers</a> or if the
1021: header is already in the <a href="#author-request-headers">author
1022: request headers</a> its value appended to.</p>
1.285 avankest 1023:
1024: <p>Throws an <code>INVALID_STATE_ERR</code> exception if the state is not
1025: <a href="#dom-xmlhttprequest-opened"
1026: title=dom-XMLHttpRequest-OPENED>OPENED</a> or if the <a
1027: href="#send-flag"><code>send()</code> flag</a> is true.</p>
1028:
1029: <p>Throws a <code>SYNTAX_ERR</code> exception if <var
1030: title="">header</var> is not a valid HTTP header field name or if <var
1031: title="">value</var> is not a valid HTTP header field value.</p>
1.275 avankest 1032: </dl>
1.205 avankest 1033:
1.284 avankest 1034: <p class=note>As indicated in the algorithm below certain headers cannot be
1035: set and are left up to the user agent. In addition there are certain other
1036: headers the user agent will take control of if they are not set by the
1037: author as indicated at the end of the <a
1038: href="#dom-xmlhttprequest-send"><code
1.276 avankest 1039: title=dom-XMLHttpRequest-send>send()</code></a> method section.
1.205 avankest 1040:
1.275 avankest 1041: <p>When the <dfn id=dom-xmlhttprequest-setrequestheader
1.284 avankest 1042: title=dom-XMLHttpRequest-setRequestHeader><code>setRequestHeader(<var
1043: title="">header</var>, <var title="">value</var>)</code></dfn> method is
1044: invoked, the user agent <em class=ct>must</em> run these steps:
1.6 avankest 1045:
1.205 avankest 1046: <ol>
1047: <li>
1.277 avankest 1048: <p>If the state is not <a href="#dom-xmlhttprequest-opened"
1049: title=dom-XMLHttpRequest-OPENED>OPENED</a> raise an
1050: <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.47 avankest 1051:
1.205 avankest 1052: <li>
1053: <p>If the <a href="#send-flag"><code>send()</code> flag</a> is true raise
1054: an <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1055:
1.205 avankest 1056: <li>
1.258 avankest 1057: <p>If any code point in <var>header</var> is higher than U+00FF LATIN
1.299 avankest 1058: SMALL LETTER Y WITH DIAERESIS or after <a
1059: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1060: DOMString into a byte sequence">deflating</a> <var>header</var> it does
1061: not match the <a href="#field-name">field-name</a> production raise a
1.258 avankest 1062: <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
1.299 avankest 1063: let <var>header</var> be the result of <a
1064: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1065: DOMString into a byte sequence">deflating</a> <var>header</var>.
1.258 avankest 1066: </li>
1067: <!-- This sounds lame, but it works. -->
1.6 avankest 1068:
1.205 avankest 1069: <li>
1.258 avankest 1070: <p>If any code point in <var>value</var> is higher than U+00FF LATIN
1.299 avankest 1071: SMALL LETTER Y WITH DIAERESIS or after <a
1072: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1073: DOMString into a byte sequence">deflating</a> <var>value</var> it does
1074: not match the <a href="#field-value">field-value</a> production raise a
1.258 avankest 1075: <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
1.299 avankest 1076: let <var>value</var> be the result of <a
1077: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1078: DOMString into a byte sequence">deflating</a> <var>value</var>.</p>
1.258 avankest 1079: <!-- This sounds lame, but it works. -->
1.205 avankest 1080: <p class=note>The empty string is legal and represents the empty header
1081: value.</p>
1.71 avankest 1082:
1.205 avankest 1083: <li>
1.261 avankest 1084: <p>Terminate these steps if <var>header</var> is a case-insensitive match
1085: for one of the following headers:</p>
1.179 avankest 1086:
1.205 avankest 1087: <ul>
1088: <li><code>Accept-Charset</code>
1.60 avankest 1089:
1.205 avankest 1090: <li><code>Accept-Encoding</code>
1.34 avankest 1091:
1.205 avankest 1092: <li><code>Connection</code>
1.34 avankest 1093:
1.205 avankest 1094: <li><code>Content-Length</code>
1.177 avankest 1095:
1.205 avankest 1096: <li><code>Cookie</code>
1.69 avankest 1097:
1.205 avankest 1098: <li><code>Cookie2</code>
1.34 avankest 1099:
1.205 avankest 1100: <li><code>Content-Transfer-Encoding</code>
1.177 avankest 1101:
1.205 avankest 1102: <li><code>Date</code>
1.177 avankest 1103:
1.205 avankest 1104: <li><code>Expect</code>
1.69 avankest 1105:
1.205 avankest 1106: <li><code>Host</code>
1.69 avankest 1107:
1.205 avankest 1108: <li><code>Keep-Alive</code>
1.34 avankest 1109:
1.205 avankest 1110: <li><code>Referer</code>
1.34 avankest 1111:
1.205 avankest 1112: <li><code>TE</code>
1.34 avankest 1113:
1.205 avankest 1114: <li><code>Trailer</code>
1.34 avankest 1115:
1.205 avankest 1116: <li><code>Transfer-Encoding</code>
1.34 avankest 1117:
1.205 avankest 1118: <li><code>Upgrade</code>
1.34 avankest 1119:
1.205 avankest 1120: <li><code>User-Agent</code>
1.34 avankest 1121:
1.205 avankest 1122: <li><code>Via</code>
1123: </ul>
1.69 avankest 1124:
1.258 avankest 1125: <p>… or if the start of <var>header</var> is a case-insensitive
1126: match for <code>Proxy-</code> or <code>Sec-</code> (including when
1.205 avankest 1127: <var>header</var> is just <code>Proxy-</code> or <code>Sec-</code>).</p>
1128:
1.285 avankest 1129: <p class=note>The above headers are controlled by the user agent to let
1130: it control those aspects of transport. This guarantees data integrity to
1131: some extent. Header names starting with <code>Sec-</code> are not
1132: allowed to be set to allow new headers to be minted that are guaranteed
1133: not to come from <a
1134: href="#xmlhttprequest"><code>XMLHttpRequest</code></a>.</p>
1.185 avankest 1135:
1.205 avankest 1136: <li>
1137: <p>If <var>header</var> is not in the <a
1138: href="#author-request-headers">author request headers</a> list append
1139: <var>header</var> with its associated <var>value</var> to the list and
1140: terminate these steps.
1.6 avankest 1141:
1.205 avankest 1142: <li>
1143: <p>If <var>header</var> is in the <a
1144: href="#author-request-headers">author request headers</a> list either
1145: use multiple headers, combine the values or use a combination of those
1146: (section 4.2, RFC 2616). [<cite><a
1.250 avankest 1147: href="#rfc-rfc2616">RFC2616</a></cite>]
1.205 avankest 1148: </li>
1149: <!-- XXX it seems UAs always combine the values -->
1150: </ol>
1.18 avankest 1151:
1.276 avankest 1152: <p class=note>See also the <a href="#dom-xmlhttprequest-send"><code
1153: title=dom-XMLHttpRequest-send>send()</code></a> method regarding user
1154: agent header handling for caching, authentication, proxies, and cookies.
1.47 avankest 1155:
1.205 avankest 1156: <div class=example>
1157: <pre><code>// The following script:
1.18 avankest 1158: var client = new XMLHttpRequest();
1159: client.open('GET', 'demo.cgi');
1160: client.setRequestHeader('X-Test', 'one');
1161: client.setRequestHeader('X-Test', 'two');
1162: client.send();
1163:
1164: // ...would result in the following header being sent:
1165: ...
1166: X-Test: one, two
1.60 avankest 1167: ...</code></pre>
1.205 avankest 1168: </div>
1.6 avankest 1169:
1.250 avankest 1170: <h4 id=the-send-method><span class=secno>3.6.3. </span>The <code
1.205 avankest 1171: title="">send()</code> method</h4>
1.276 avankest 1172:
1173: <dl class=domintro>
1174: <dt><var title="">client</var> . <a href="#dom-xmlhttprequest-send"><code
1175: title=dom-XMLHttpRequest-send>send(<var title="">data</var>)</code></a>
1176:
1177: <dd>
1178: <p>Initiates the request. The optional argument provides the <a
1.285 avankest 1179: href="#request-entity-body">request entity body</a>. The argument is
1180: ignored if <a href="#request-method">request method</a> is
1181: <code>GET</code> or <code>HEAD</code>.</p>
1182:
1183: <p>Throws an <code>INVALID_STATE_ERR</code> exception if the state is not
1184: <a href="#dom-xmlhttprequest-opened"
1185: title=dom-XMLHttpRequest-OPENED>OPENED</a> or if the <a
1186: href="#send-flag"><code>send()</code> flag</a> is true.</p>
1.276 avankest 1187: </dl>
1.205 avankest 1188:
1.275 avankest 1189: <p>When the <dfn id=dom-xmlhttprequest-send
1.276 avankest 1190: title=dom-XMLHttpRequest-send><code>send(<var>data</var>)</code></dfn>
1191: method is invoked, the user agent <em class=ct>must</em> run the following
1192: steps (unless otherwise noted). This algorithm gets aborted when the <a
1.279 avankest 1193: href="#dom-xmlhttprequest-open"><code
1194: title=dom-XMLHttpRequest-open>open()</code></a> or <a
1.280 avankest 1195: href="#dom-xmlhttprequest-abort"><code
1196: title=dom-XMLHttpRequest-abort>abort()</code></a> method is invoked. When
1197: the <dfn id=abort-send-algorithm title="abort send()"><code>send()</code>
1198: algorithm is aborted</dfn> the user agent <em class=ct>must</em> terminate
1199: the algorithm after finishing the step it is on.
1.205 avankest 1200:
1201: <p class=note>The <code title="">send()</code> algorithm can only be
1202: aborted when the <a href="#asynchronous-flag">asynchronous flag</a> is
1203: true and only after the method call has returned.
1.60 avankest 1204:
1.205 avankest 1205: <ol>
1206: <li>
1.277 avankest 1207: <p>If the state is not <a href="#dom-xmlhttprequest-opened"
1208: title=dom-XMLHttpRequest-OPENED>OPENED</a> raise an
1209: <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1210:
1.205 avankest 1211: <li>
1212: <p>If the <a href="#send-flag"><code>send()</code> flag</a> is true raise
1213: an <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1214:
1.205 avankest 1215: <li>
1.285 avankest 1216: <p>If the <a href="#request-method">request method</a> is a
1217: case-sensitive match for <code>GET</code> or <code>HEAD</code> act as if
1218: <var title="">data</var> is null.</p>
1.203 avankest 1219:
1.241 avankest 1220: <p>If the <var>data</var> argument has been omitted or is null, do not
1221: include a <a href="#request-entity-body">request entity body</a> and go
1222: to the next step.</p>
1.234 avankest 1223:
1.250 avankest 1224: <p>Otherwise, let <var>encoding</var> be null, <var>mime type</var> be
1225: null, and then follow these rules:</p>
1.205 avankest 1226:
1227: <dl class=switch>
1.250 avankest 1228: <dt>If <var>data</var> is a <code>Document</code>
1.205 avankest 1229:
1230: <dd>
1.234 avankest 1231: <p>Let <var>encoding</var> be the <a
1232: href="#preferred-mime-name">preferred MIME name</a> of the <a
1.246 avankest 1233: href="#document-character-encoding" title="document's character
1.234 avankest 1234: encoding">character encoding</a> of <var>data</var>. If
1235: <var>encoding</var> is UTF-16 change it to UTF-8.</p>
1236:
1.250 avankest 1237: <p>Let <var>mime type</var> be "<code>application/xml;charset=</code>"
1238: followed by <var>encoding</var>.</p>
1.234 avankest 1239:
1240: <p>Let the <a href="#request-entity-body">request entity body</a> be
1.270 avankest 1241: the result of getting the <a href="#dom-innerhtml"><code
1242: title=dom-innerHTML>innerHTML</code></a> attribute on <var>data</var>
1243: <a href="#dfn-obtain-unicode" title="convert a DOMString to a sequence
1244: of Unicode characters">converted to Unicode</a> and encoded as
1245: <var>encoding</var>. Re-raise any exception this raises.</p>
1.210 avankest 1246:
1.235 avankest 1247: <p class=note>In particular, if the document cannot be serialized an
1.219 avankest 1248: <code>INVALID_STATE_ERR</code> exception is raised.</p>
1249:
1.205 avankest 1250: <p class=note>Subsequent changes to the <code>Document</code> have no
1251: effect on what is submitted.</p>
1.239 avankest 1252:
1.250 avankest 1253: <dt>If <var>data</var> is a <code>DOMString</code>
1.239 avankest 1254:
1255: <dd>
1.250 avankest 1256: <p>Let <var>encoding</var> be UTF-8.</p>
1257:
1258: <p>Let <var>mime type</var> be "<code>text/plain;charset=UTF-8</code>".</p>
1259:
1.239 avankest 1260: <p>Let the <a href="#request-entity-body">request entity body</a> be
1261: <var>data</var> <a href="#dfn-obtain-unicode" title="convert a
1262: DOMString to a sequence of Unicode characters">converted to
1.250 avankest 1263: Unicode</a> and encoded as UTF-8.</p>
1.205 avankest 1264: </dl>
1.103 avankest 1265:
1.270 avankest 1266: <p>If a <code>Content-Type</code> header is set using <a
1.284 avankest 1267: href="#dom-xmlhttprequest-setrequestheader"><code
1268: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.275 avankest 1269: whose value is a <a href="#valid-mime-type">valid MIME type</a> and has
1270: a <code>charset</code> parameter whose value is not a case-insensitive
1.284 avankest 1271: match for <var title="">encoding</var>, and <var title="">encoding</var>
1272: is not null, set all the <code>charset</code> parameters of the
1273: <code>Content-Type</code> header to <var title="">encoding</var>.</p>
1.234 avankest 1274:
1.270 avankest 1275: <p>If no <code>Content-Type</code> header has been set using <a
1.284 avankest 1276: href="#dom-xmlhttprequest-setrequestheader"><code
1277: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1278: and <var title="">mime type</var> is not null set a
1279: <code>Content-Type</code> request header with as value <var
1280: title="">mime type</var>.</p>
1.238 avankest 1281: <!-- reminder: if we ever change this to always include charset it has
1282: to be included as the first parameter for compatibility reasons -->
1283:
1.167 avankest 1284:
1.205 avankest 1285: <li>
1286: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1287: release the <a href="#storage-mutex">storage mutex</a>.
1.60 avankest 1288:
1.205 avankest 1289: <li>
1290: <p>Set the <a href="#error-flag">error flag</a> to false.
1.164 avankest 1291:
1.205 avankest 1292: <li>
1.213 avankest 1293: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is true run
1294: these substeps:</p>
1295:
1296: <ol>
1297: <li>
1.219 avankest 1298: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to true.
1299:
1300: <li>
1.213 avankest 1301: <p><a href="#dispatch-readystatechange-event">Dispatch a
1302: <code>readystatechange</code> event</a>.</p>
1303:
1304: <p class=note>The state does not change. The event is dispatched for
1305: historical reasons.</p>
1306:
1307: <li>
1.276 avankest 1308: <p>Return the <a href="#dom-xmlhttprequest-send"><code
1309: title=dom-XMLHttpRequest-send>send()</code></a> method call, but
1310: continue running the steps in this algorithm.
1.213 avankest 1311: </ol>
1312:
1313: <li>
1.226 avankest 1314: <dl class=switch>
1.305 ! avankest 1315: <dt>If the <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
! 1316: origin</a> and the <a href="#request-url">request URL</a> are <a
! 1317: href="#same-origin">same origin</a>
1.195 avankest 1318:
1.205 avankest 1319: <dd>
1.305 ! avankest 1320: <p>These are the <dfn id=same-origin-request-steps>same-origin request
! 1321: steps</dfn>.</p>
! 1322:
! 1323: <p><a href="#fetch">Fetch</a> the <a href="#request-url">request
! 1324: URL</a> from <i title="">origin</i> <a
! 1325: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>,
! 1326: with the <i title="">synchronous flag</i> set if the <a
! 1327: href="#asynchronous-flag">asynchronous flag</a> is false, using HTTP
! 1328: method <a href="#request-method">request method</a>, user <a
! 1329: href="#request-username">request username</a> (if non-null) and
! 1330: password <a href="#request-password">request password</a> (if
! 1331: non-null), taking into account the <a
! 1332: href="#request-entity-body">request entity body</a>, list of <a
! 1333: href="#author-request-headers">author request headers</a> and the
! 1334: rules listed at the end of this section.</p>
! 1335:
! 1336: <dl class=switch>
! 1337: <dt>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
! 1338:
! 1339: <dd>
! 1340: <p>While making the request also follow the <a
! 1341: href="#same-origin-request-event-rules">same-origin request event
! 1342: rules</a>.</p>
! 1343: <!--
1.250 avankest 1344: This cannot involve any task queue whatsoever because that would
1345: mean other tasks on the task queue might get processed as well
1346: which is counter to the whole idea of doing things synchronous.
1347: -->
1.305 ! avankest 1348:
! 1349: <p class=note>The <a href="#dom-xmlhttprequest-send"><code
! 1350: title=dom-XMLHttpRequest-send>send()</code></a> method call will now
! 1351: be returned by virtue of this algorithm ending.</p>
! 1352:
! 1353: <dt>If the <a href="#asynchronous-flag">asynchronous flag</a> is true
! 1354:
! 1355: <dd>
! 1356: <p>While processing the request, as data becomes available and when
! 1357: the user interferes with the request, <a href="#queue-a-task"
! 1358: title="queue a task">queue tasks</a> to update the <a
! 1359: href="#response-entity-body">response entity body</a> and follow the
! 1360: <a href="#same-origin-request-event-rules">same-origin request event
! 1361: rules</a>.</p>
! 1362: </dl>
1.205 avankest 1363:
1.305 ! avankest 1364: <dt>Otherwise
1.205 avankest 1365:
1366: <dd>
1.305 ! avankest 1367: <p>These are the <dfn id=cross-origin-request-steps>cross-origin
! 1368: request steps</dfn>.</p>
1.250 avankest 1369:
1.305 ! avankest 1370: <p>This is a <a href="#network-error">network error</a>.</p>
1.205 avankest 1371: </dl>
1372: </ol>
1.124 avankest 1373:
1.205 avankest 1374: <hr>
1375:
1.229 avankest 1376: <p>If the user agent allows the end user to configure a proxy it <em
1.250 avankest 1377: class=ct>should</em> modify the request appropriately; i.e., connect to
1378: the proxy host instead of the origin server, modify the
1.214 avankest 1379: <code>Request-Line</code> and send <code>Proxy-Authorization</code>
1380: headers as specified.
1381:
1.264 avankest 1382: <hr>
1383:
1384: <p>If the user agent supports HTTP Authentication and <code
1385: title=http-authorization>Authorization</code> is not in the list of <a
1.220 avankest 1386: href="#author-request-headers">author request headers</a>, it <em
1.270 avankest 1387: class=ct>should</em> consider requests originating from the <a
1388: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object to be part
1389: of the protection space that includes the accessed URIs and send <code
1.264 avankest 1390: title=http-authorization>Authorization</code> headers and handle <code>401
1391: Unauthorized</code> requests appropriately.
1392:
1393: <p>If authentication fails, <code
1394: title=http-authorization>Authorization</code> is not in the list of <a
1395: href="#author-request-headers">author request headers</a>, <a
1396: href="#request-username">request username</a> is null, and <a
1397: href="#request-password">request password</a> is null, user agents <em
1398: class=ct>should</em> prompt the end user for their username and password.
1399:
1400: <p>If authentication fails, <code
1401: title=http-authorization>Authorization</code> is not in the list of <a
1402: href="#author-request-headers">author request headers</a>, <a
1403: href="#request-username">request username</a> is non-null, and <a
1404: href="#request-password">request password</a> is non-null, user agents <em
1405: class=ct>must not</em> prompt the end user for their username and
1406: password. [<cite><a href="#ref-rfc2617">RFC2617</a></cite>]
1.214 avankest 1407:
1.271 avankest 1408: <p class=note>End users are not prompted if username/password are provided
1.279 avankest 1409: through the <a href="#dom-xmlhttprequest-open"><code
1410: title=dom-XMLHttpRequest-open>open()</code></a> API so that authors can
1411: implement their own user interface.
1.214 avankest 1412:
1.264 avankest 1413: <hr>
1414:
1.214 avankest 1415: <p>If the user agent supports HTTP State Management it <em
1416: class=ct>should</em> persist, discard and send cookies (as received in the
1.302 avankest 1417: <code>Set-Cookie</code> response header, and sent in the
1418: <code>Cookie</code> header) as applicable. [<cite><a
1.232 avankest 1419: href="#ref-cookies">COOKIES</a></cite>]
1.214 avankest 1420:
1.264 avankest 1421: <hr>
1422:
1.214 avankest 1423: <p>If the user agent implements a HTTP cache it <em class=ct>should</em>
1.270 avankest 1424: respect <code>Cache-Control</code> request headers set by the <a
1.284 avankest 1425: href="#dom-xmlhttprequest-setrequestheader"><code
1426: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.275 avankest 1427: (e.g., <code>Cache-Control: no-cache</code> bypasses the cache). It <em
1.214 avankest 1428: class=ct>must not</em> send <code>Cache-Control</code> or
1.229 avankest 1429: <code>Pragma</code> request headers automatically unless the end user
1.284 avankest 1430: explicitly requests such behavior (e.g. by reloading the page).
1.214 avankest 1431:
1432: <p>For <code>304 Not Modified</code> responses that are a result of a user
1433: agent generated conditional request the user agent <em class=ct>must</em>
1434: act as if the server gave a <code>200 OK</code> response with the
1.270 avankest 1435: appropriate content. The user agent <em class=ct>must</em> allow <a
1.284 avankest 1436: href="#dom-xmlhttprequest-setrequestheader"><code
1437: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a> to
1438: override automatic cache validation by setting request headers (e.g.
1.250 avankest 1439: <code>If-None-Match</code> or <code>If-Modified-Since</code>), in which
1440: case <code>304 Not Modified</code> responses <em class=ct>must</em> be
1441: passed through. [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.214 avankest 1442:
1.264 avankest 1443: <hr>
1444:
1.214 avankest 1445: <p>If the user agent implements server-driven content-negotiation it <em
1.303 avankest 1446: class=ct>must</em> follow these constraints for the <code>Accept</code>
1447: and <code>Accept-Language</code> request headers:
1.233 avankest 1448:
1449: <ul>
1450: <li>
1451: <p>Both headers <em class=ct>must not</em> be modified if they are
1.284 avankest 1452: already set through <a href="#dom-xmlhttprequest-setrequestheader"><code
1453: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>.
1.233 avankest 1454:
1455: <li>
1.270 avankest 1456: <p>If not set through <a
1.284 avankest 1457: href="#dom-xmlhttprequest-setrequestheader"><code
1458: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.257 avankest 1459: <code>Accept-Language</code> <em class=ct>should</em> be set as
1.233 avankest 1460: appropriate.
1461:
1462: <li>
1.270 avankest 1463: <p>If not set through <a
1.284 avankest 1464: href="#dom-xmlhttprequest-setrequestheader"><code
1465: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.233 avankest 1466: <code>Accept</code> <em class=ct>must</em> be set with as value
1467: <code>*/*</code>.
1468: </ul>
1469:
1470: <p>Responses <em class=ct>must</em> have the content-encodings
1.250 avankest 1471: automatically decoded. [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.214 avankest 1472:
1.264 avankest 1473: <hr>
1474:
1.214 avankest 1475: <p>Besides the <a href="#author-request-headers">author request headers</a>
1476: user agents <em class=ct>should not</em> include additional request
1477: headers other than those mentioned above or other than those authors are
1.270 avankest 1478: not allowed to set using <a
1.284 avankest 1479: href="#dom-xmlhttprequest-setrequestheader"><code
1480: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>.
1.275 avankest 1481: This ensures that authors have a reasonably predictable API.
1.214 avankest 1482:
1.250 avankest 1483: <h4 id=infrastructure-for-the-send-method><span class=secno>3.6.4.
1.214 avankest 1484: </span>Infrastructure for the <code title="">send()</code> method</h4>
1485:
1.221 avankest 1486: <p>The <dfn id=same-origin-request-event-rules>same-origin request event
1487: rules</dfn> are as follows:
1.205 avankest 1488:
1489: <dl class=switch>
1.290 avankest 1490: <dt>If the response has an HTTP status code of 301, 302, 303, or 307
1.205 avankest 1491:
1492: <dd>
1.305 ! avankest 1493: <p>If the redirect violates infinite loop precautions this is a <a
! 1494: href="#network-error">network error</a>.</p>
1.205 avankest 1495:
1.305 ! avankest 1496: <p>Otherwise, run these steps:</p>
! 1497:
! 1498: <ol>
! 1499: <li>
! 1500: <p>Set the <a href="#request-url">request URL</a> to the <a
! 1501: href="#url">URL</a> conveyed by the <code>Location</code> header.
! 1502:
! 1503: <li>
! 1504: <p>If the <a href="#url-scheme"><code><scheme></code></a> of <a
! 1505: href="#request-url">request URL</a> is not supported this is a <a
! 1506: href="#network-error">network error</a>. Terminate the steps for this
! 1507: algorithm if that is the case.
! 1508:
! 1509: <li>
! 1510: <p>If the <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
! 1511: origin</a> and the <a href="#origin">origin</a> of <a
! 1512: href="#request-url">request URL</a> are <a href="#same-origin">same
! 1513: origin</a> transparently follow the redirect while observing the <a
! 1514: href="#same-origin-request-event-rules">same-origin request event
! 1515: rules</a>.
! 1516:
! 1517: <li>
! 1518: <p>Otherwise, follow the <a
! 1519: href="#cross-origin-request-steps">cross-origin request steps</a> and
! 1520: terminate the steps for this algorithm.
! 1521: </ol>
1.250 avankest 1522:
1.205 avankest 1523: <p class=note>HTTP places requirements on the user agent regarding the
1.206 avankest 1524: preservation of the <a href="#request-method">request method</a> and <a
1525: href="#request-entity-body">request entity body</a> during redirects,
1.229 avankest 1526: and also requires end users to be notified of certain kinds of automatic
1.205 avankest 1527: redirections.</p>
1528: <!-- XXX HTTP needs fixing here -->
1529:
1.290 avankest 1530: <dt>If the end user cancels the request
1.205 avankest 1531:
1.215 avankest 1532: <dd>
1533: <p>This is an <a href="#abort-error">abort error</a>.
1.119 avankest 1534:
1.290 avankest 1535: <dt>If there is a network error
1.216 avankest 1536:
1.215 avankest 1537: <dd>
1538: <p>In case of DNS errors, TLS negotiation failure, or other type of
1539: network errors, this is a <a href="#network-error">network error</a>. Do
1.229 avankest 1540: not request any kind of end user interaction.</p>
1.205 avankest 1541:
1.215 avankest 1542: <p class=note>This does not include HTTP responses that indicate some
1543: type of error, such as HTTP status code 410.</p>
1.119 avankest 1544:
1.215 avankest 1545: <dt>Once all HTTP headers have been received and the <a
1.259 avankest 1546: href="#asynchronous-flag">asynchronous flag</a> is true (and this is not
1547: an HTTP redirect)
1.60 avankest 1548:
1.215 avankest 1549: <dd>
1.289 avankest 1550: <p><a href="#switch-headers-received">Switch to the HEADERS_RECEIVED
1551: state</a>.
1.60 avankest 1552:
1.222 avankest 1553: <dt>Once the first byte (or more) of the <a
1554: href="#response-entity-body">response entity body</a> has been received
1555: and the <a href="#asynchronous-flag">asynchronous flag</a> is true
1556:
1557: <dt>If there is no <a href="#response-entity-body">response entity
1558: body</a> and the <a href="#asynchronous-flag">asynchronous flag</a> is
1.215 avankest 1559: true
1.19 avankest 1560:
1.222 avankest 1561: <dd>
1.289 avankest 1562: <p><a href="#switch-loading">Switch to the LOADING state</a>.
1.222 avankest 1563:
1564: <dt>Once the whole <a href="#response-entity-body">response entity
1565: body</a> has been received
1566:
1567: <dt>If there is no <a href="#response-entity-body">response entity
1.301 avankest 1568: body</a> and the state is <a href="#dom-xmlhttprequest-loading"
1569: title=dom-XMLHttpRequest-LOADING>LOADING</a>
1570:
1571: <dt>If there is no <a href="#response-entity-body">response entity
1.226 avankest 1572: body</a> and the <a href="#asynchronous-flag">asynchronous flag</a> is
1.301 avankest 1573: false
1.185 avankest 1574:
1.215 avankest 1575: <dd>
1.289 avankest 1576: <p><a href="#switch-done">Switch to the DONE state</a>.
1.215 avankest 1577: </dl>
1.6 avankest 1578:
1.215 avankest 1579: <hr>
1.6 avankest 1580:
1.215 avankest 1581: <p>When something is said to be a <dfn id=network-error>network error</dfn>
1.270 avankest 1582: run the <a href="#request-error">request error</a> steps for exception <a
1583: href="#network-err"><code>NETWORK_ERR</code></a>.
1.62 avankest 1584:
1.243 avankest 1585: <p>When something is said to be an <dfn id=abort-error>abort error</dfn>
1.270 avankest 1586: run the <a href="#request-error">request error</a> steps for exception <a
1587: href="#abort-err"><code>ABORT_ERR</code></a>.
1.84 avankest 1588:
1.244 avankest 1589: <p>When something is said to be a <dfn id=request-error>request error</dfn>
1590: for exception <var>exception</var> run these steps:
1.60 avankest 1591:
1.256 avankest 1592: <ol>
1593: <li>
1594: <p>The user agent <em class=ct>should</em> cancel any network activity
1595: for which the object is responsible.
1596:
1597: <li>
1598: <p>If there are any <a href="#task" title=task>tasks</a> from the
1599: object's <a
1600: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
1601: source</a> in one of the <a href="#task-queues">task queues</a>, then
1602: remove those tasks.
1.252 avankest 1603:
1.215 avankest 1604: <li>
1605: <p>Set the <a href="#response-entity-body">response entity body</a> to
1606: null.
1.205 avankest 1607:
1.215 avankest 1608: <li>
1.256 avankest 1609: <p>Empty the list of <a href="#author-request-headers">author request
1610: headers</a>.
1.205 avankest 1611:
1.215 avankest 1612: <li>
1.256 avankest 1613: <p>Set the the <a href="#error-flag">error flag</a> to true.
1.205 avankest 1614:
1.215 avankest 1615: <li>
1.277 avankest 1616: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1617: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.205 avankest 1618:
1.215 avankest 1619: <li>
1620: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1.243 avankest 1621: raise an <var>exception</var> exception and terminate the overall set of
1622: steps.
1.205 avankest 1623:
1.215 avankest 1624: <li>
1.251 avankest 1625: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.250 avankest 1626: <code>readystatechange</code> event</a>.</p>
1627:
1628: <p class=note>At this point it is clear that the <a
1629: href="#asynchronous-flag">asynchronous flag</a> is true.</p>
1.205 avankest 1630:
1.215 avankest 1631: <li>
1.250 avankest 1632: <p>Terminate the overall algorithm.
1.215 avankest 1633: </ol>
1.6 avankest 1634:
1.278 avankest 1635: <p class=note>A future version of this specification will dispatch an <code
1.280 avankest 1636: title=event-xhr-error>error</code>/<code>abort</code> event here as well.
1637: (Depending on the type of error.)
1.6 avankest 1638:
1.215 avankest 1639: <hr>
1.2 avankest 1640:
1.215 avankest 1641: <p>When it is said to <dfn id=switch-headers-received>switch to the
1.289 avankest 1642: HEADERS_RECEIVED state</dfn> run these steps:
1.60 avankest 1643:
1.215 avankest 1644: <ol>
1645: <li>
1.277 avankest 1646: <p>Switch the state to <a href="#dom-xmlhttprequest-headers_received"
1647: title="dom-XMLHttpRequest-HEADERS_RECEIVED">HEADERS_RECEIVED</a>.
1.125 avankest 1648:
1.215 avankest 1649: <li>
1.251 avankest 1650: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.215 avankest 1651: <code>readystatechange</code> event</a>.
1652: </ol>
1.205 avankest 1653:
1.289 avankest 1654: <p>When it is said to <dfn id=switch-loading>switch to the LOADING
1655: state</dfn> run these steps:
1.205 avankest 1656:
1.215 avankest 1657: <ol>
1658: <li>
1.277 avankest 1659: <p>Switch the state to <a href="#dom-xmlhttprequest-loading"
1660: title=dom-XMLHttpRequest-LOADING>LOADING</a>.
1.17 avankest 1661:
1.215 avankest 1662: <li>
1.251 avankest 1663: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.215 avankest 1664: <code>readystatechange</code> event</a>.
1665: </ol>
1.205 avankest 1666:
1.289 avankest 1667: <p>When it is said to <dfn id=switch-done>switch to the DONE state</dfn>
1668: run these steps:
1.218 avankest 1669:
1670: <ol>
1671: <li>
1.257 avankest 1672: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1673: update the <a href="#response-entity-body">response entity body</a>.
1674:
1675: <li>
1.277 avankest 1676: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1677: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.218 avankest 1678:
1679: <li>
1.250 avankest 1680: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.218 avankest 1681: <code>readystatechange</code> event</a>.
1682: </ol>
1683:
1.250 avankest 1684: <h4 id=the-abort-method><span class=secno>3.6.5. </span>The <code
1.205 avankest 1685: title="">abort()</code> method</h4>
1686:
1.280 avankest 1687: <dl class=domintro>
1688: <dt><var title="">client</var> . <a href="#dom-xmlhttprequest-abort"><code
1689: title=dom-XMLHttpRequest-abort>abort()</code></a>
1690:
1691: <dd>Cancels any network activity.
1692: </dl>
1693:
1694: <p>When the <dfn id=dom-xmlhttprequest-abort
1695: title=dom-XMLHttpRequest-abort><code>abort()</code></dfn> method is
1696: invoked, the user agent <em class=ct>must</em> run these steps (unless
1697: otherwise noted):
1.205 avankest 1698:
1699: <ol>
1700: <li>
1701: <p><a href="#abort-send-algorithm" title="abort send()">Abort the
1702: <code>send()</code> algorithm</a>.
1.202 avankest 1703:
1.205 avankest 1704: <li>
1705: <p>The user agent <em class=ct>should</em> cancel any network activity
1706: for which the object is responsible.
1.254 avankest 1707:
1708: <li>
1709: <p>If there are any <a href="#task" title=task>tasks</a> from the
1710: object's <a
1711: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
1712: source</a> in one of the <a href="#task-queues">task queues</a>, then
1713: remove those tasks.
1.205 avankest 1714:
1715: <li>
1716: <p>Set the <a href="#response-entity-body">response entity body</a> to
1717: null.
1718:
1719: <li>
1.254 avankest 1720: <p>Empty the list of <a href="#author-request-headers">author request
1721: headers</a>.
1.205 avankest 1722:
1723: <li>
1.254 avankest 1724: <p>Set the <a href="#error-flag">error flag</a> to true.
1.205 avankest 1725:
1726: <li>
1.277 avankest 1727: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1728: title=dom-XMLHttpRequest-UNSENT>UNSENT</a>, <a
1729: href="#dom-xmlhttprequest-opened"
1730: title=dom-XMLHttpRequest-OPENED>OPENED</a> with the <a
1731: href="#send-flag"><code>send()</code> flag</a> being false, or <a
1732: href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a>
1733: go to the next step.</p>
1.205 avankest 1734:
1735: <p>Otherwise run these substeps:</p>
1736:
1737: <ol>
1.202 avankest 1738: <li>
1.277 avankest 1739: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1740: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.77 avankest 1741:
1742: <li>
1.205 avankest 1743: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to false.
1.77 avankest 1744:
1745: <li>
1.205 avankest 1746: <p><a href="#dispatch-readystatechange-event">Dispatch a
1747: <code>readystatechange</code> event</a>.
1.60 avankest 1748: </ol>
1.17 avankest 1749:
1.252 avankest 1750: <p class=note>A future version of this specification will dispatch an
1.278 avankest 1751: <code title=event-xhr-abort>abort</code> event here.</p>
1.220 avankest 1752:
1.205 avankest 1753: <li>
1.277 avankest 1754: <p>Switch the state to <a href="#dom-xmlhttprequest-unsent"
1755: title=dom-XMLHttpRequest-UNSENT>UNSENT</a>.</p>
1.205 avankest 1756:
1.278 avankest 1757: <p class=note>No <code
1758: title=event-xhr-readystatechange>readystatechange</code> event is
1759: dispatched.</p>
1.205 avankest 1760: </ol>
1761:
1.250 avankest 1762: <h3 id=response><span class=secno>3.7. </span>Response</h3>
1.205 avankest 1763:
1.250 avankest 1764: <h4 id=the-status-attribute><span class=secno>3.7.1. </span>The <code
1.205 avankest 1765: title="">status</code> attribute</h4>
1766:
1.281 avankest 1767: <dl class=domintro>
1768: <dt><var title="">client</var> . <a
1769: href="#dom-xmlhttprequest-status"><code
1770: title=dom-XMLHttpRequest-status>status</code></a>
1771:
1772: <dd>
1773: <p>Returns the HTTP status code.
1774: </dl>
1775:
1776: <p>The <dfn id=dom-xmlhttprequest-status
1777: title=dom-XMLHttpRequest-status><code>status</code></dfn> attribute <em
1778: class=ct>must</em> return the result of running these steps:
1.224 avankest 1779:
1780: <ol>
1781: <li>
1.277 avankest 1782: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1783: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1784: href="#dom-xmlhttprequest-opened"
1785: title=dom-XMLHttpRequest-OPENED>OPENED</a> return 0 and terminate these
1786: steps.
1.224 avankest 1787:
1788: <li>
1.241 avankest 1789: <p>If the <a href="#error-flag">error flag</a> is true return 0 and
1790: terminate these steps.
1.224 avankest 1791:
1792: <li>
1793: <p>Return the HTTP status code.
1794: </ol>
1.205 avankest 1795:
1.250 avankest 1796: <h4 id=the-statustext-attribute><span class=secno>3.7.2. </span>The <code
1.205 avankest 1797: title="">statusText</code> attribute</h4>
1798:
1.281 avankest 1799: <dl class=domintro>
1800: <dt><var title="">client</var> . <a
1801: href="#dom-xmlhttprequest-statustext"><code
1802: title=dom-XMLHttpRequest-statusText>statusText</code></a>
1803:
1804: <dd>
1805: <p>Returns the HTTP status text.
1806: </dl>
1807:
1808: <p>The <dfn id=dom-xmlhttprequest-statustext
1809: title=dom-XMLHttpRequest-statusText><code>statusText</code></dfn>
1.275 avankest 1810: attribute <em class=ct>must</em> return the result of running these steps:
1.224 avankest 1811:
1812: <ol>
1813: <li>
1.277 avankest 1814: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1815: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1816: href="#dom-xmlhttprequest-opened"
1817: title=dom-XMLHttpRequest-OPENED>OPENED</a> return the empty string and
1818: terminate these steps.
1.224 avankest 1819:
1820: <li>
1821: <p>If the <a href="#error-flag">error flag</a> is true return the empty
1822: string and terminate these steps.
1823:
1824: <li>
1825: <p>Return the HTTP status text.
1826: </ol>
1.205 avankest 1827:
1.250 avankest 1828: <h4 id=the-getresponseheader-method><span class=secno>3.7.3. </span>The
1.205 avankest 1829: <code title="">getResponseHeader()</code> method</h4>
1830:
1.283 avankest 1831: <dl class=domintro>
1832: <dt><var title="">client</var> . <a
1833: href="#dom-xmlhttprequest-getresponseheader"><code
1834: title=dom-XMLHttpRequest-getResponseHeader>getResponseHeader(<var
1835: title="">header</var>)</code></a>
1836:
1837: <dd>
1838: <p>Returns the header field value from the response of which the field
1839: name matches <var title="">header</var>, unless the field name is
1840: <code>Set-Cookie</code> or <code>Set-Cookie2</code>.
1841: </dl>
1842:
1.275 avankest 1843: <p>When the <dfn id=dom-xmlhttprequest-getresponseheader
1.283 avankest 1844: title=dom-XMLHttpRequest-getResponseHeader><code>getResponseHeader(<var
1845: title="">header</var>)</code></dfn> is invoked, the user agent <em
1846: class=ct>must</em> run these steps:
1.205 avankest 1847:
1848: <ol>
1849: <li>
1.277 avankest 1850: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1851: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1852: href="#dom-xmlhttprequest-opened"
1853: title=dom-XMLHttpRequest-OPENED>OPENED</a> return null and terminate
1854: these steps.
1.205 avankest 1855:
1856: <li>
1.241 avankest 1857: <p>If the <a href="#error-flag">error flag</a> is true return null and
1858: terminate these steps.
1.205 avankest 1859:
1860: <li>
1.258 avankest 1861: <p>If any code point in <var>header</var> is higher than U+00FF LATIN
1862: SMALL LETTER Y WITH DIAERESIS return null and terminate these steps.
1863:
1864: <li>
1.299 avankest 1865: <p>Let <var>header</var> be the result of <a
1866: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1867: DOMString into a byte sequence">deflating</a> <var>header</var>.
1.258 avankest 1868: </li>
1869: <!-- This sounds lame, but it works. -->
1.205 avankest 1870:
1871: <li>
1.258 avankest 1872: <p>If <var>header</var> is a case-insensitive match for
1873: <code>Set-Cookie</code> or <code>Set-Cookie2</code> return null and
1.205 avankest 1874: terminate these steps.
1875:
1876: <li>
1.258 avankest 1877: <p>If <var>header</var> is a case-insensitive match for multiple HTTP
1.299 avankest 1878: response headers, return the <a
1879: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1880: sequence into a DOMString">inflated</a> values of these headers as a
1881: single concatenated string separated from each other by a U+002C COMMA
1882: U+0020 SPACE character pair and terminate these steps.
1.258 avankest 1883:
1884: <li>
1885: <p>If <var>header</var> is a case-insensitive match for a single HTTP
1.299 avankest 1886: response header, return the <a
1887: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1888: sequence into a DOMString">inflated</a> value of that header and
1889: terminate these steps.
1.205 avankest 1890:
1891: <li>
1.241 avankest 1892: <p>Return null.
1.205 avankest 1893: </ol>
1894:
1895: <div class=example>
1.252 avankest 1896: <p>For the following script:</p>
1897:
1898: <pre><code>var client = new XMLHttpRequest();
1899: client.open("GET", "unicorns-are-teh-awesome.txt", true);
1.6 avankest 1900: client.send();
1.16 avankest 1901: client.onreadystatechange = function() {
1.252 avankest 1902: if(this.readyState == 2) {
1903: print(client.getResponseHeader("Content-Type"));
1904: }
1905: }</code></pre>
1906:
1907: <p>The <code>print()</code> function will get to process something like:</p>
1.1 avankest 1908:
1.252 avankest 1909: <pre><code>text/plain; charset=UTF-8</code></pre>
1.205 avankest 1910: </div>
1911:
1.250 avankest 1912: <h4 id=the-getallresponseheaders-method><span class=secno>3.7.4. </span>The
1.205 avankest 1913: <code title="">getAllResponseHeaders()</code> method</h4>
1.2 avankest 1914:
1.283 avankest 1915: <dl class=domintro>
1.298 avankest 1916: <dt><var title="">client</var> . <a
1917: href="#dom-xmlhttprequest-getallresponseheaders"><code
1918: title=dom-XMLHttpRequest-getAllResponseHeaders>getAllResponseHeaders()</code></a>
1.283 avankest 1919:
1920: <dd>
1921: <p>Returns all headers from the response, with the exception of those
1922: whose field name is <code>Set-Cookie</code> or <code>Set-Cookie2</code>.
1923: </dl>
1924:
1.298 avankest 1925: <p>When the <dfn id=dom-xmlhttprequest-getallresponseheaders
1926: title=dom-XMLHttpRequest-getAllResponseHeaders><code>getAllResponseHeaders()</code></dfn>
1.275 avankest 1927: method is invoked, the user agent <em class=ct>must</em> run the following
1928: steps:
1.6 avankest 1929:
1.205 avankest 1930: <ol>
1931: <li>
1.277 avankest 1932: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1933: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1934: href="#dom-xmlhttprequest-opened"
1935: title=dom-XMLHttpRequest-OPENED>OPENED</a> return the empty string and
1936: terminate these steps.
1.205 avankest 1937:
1938: <li>
1939: <p>If the <a href="#error-flag">error flag</a> is true return the empty
1940: string and terminate these steps.
1941:
1942: <li>
1.258 avankest 1943: <p>Return all the HTTP headers, excluding headers that are a
1944: case-insensitive match for <code>Set-Cookie</code> or
1.299 avankest 1945: <code>Set-Cookie2</code>, <a
1946: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1947: sequence into a DOMString">inflated</a>, as a single string, with each
1948: header line separated by a U+000D CR U+000A LF pair, excluding the
1949: status line, and with each header name and header value separated by a
1950: U+003A COLON U+0020 SPACE pair.
1.205 avankest 1951: </ol>
1952:
1953: <div class=example>
1.252 avankest 1954: <p>For the following script:</p>
1955:
1956: <pre><code>var client = new XMLHttpRequest();
1957: client.open("GET", "narwhals-too.txt", true);
1.205 avankest 1958: client.send();
1959: client.onreadystatechange = function() {
1960: if(this.readyState == 2) {
1961: print(this.getAllResponseHeaders());
1962: }
1.252 avankest 1963: }</code></pre>
1964:
1965: <p>The <code>print()</code> function will get to process something like:</p>
1.205 avankest 1966:
1.252 avankest 1967: <pre><code>Date: Sun, 24 Oct 2004 04:58:38 GMT
1.205 avankest 1968: Server: Apache/1.3.31 (Unix)
1969: Keep-Alive: timeout=15, max=99
1970: Connection: Keep-Alive
1971: Transfer-Encoding: chunked
1972: Content-Type: text/plain; charset=utf-8</code></pre>
1973: </div>
1974:
1.250 avankest 1975: <h4 id=response-entity-body0><span class=secno>3.7.5. </span>Response
1.248 avankest 1976: Entity Body</h4>
1.250 avankest 1977:
1978: <p>The <dfn id=response-mime-type>response MIME type</dfn> is the MIME type
1979: the <code>Content-Type</code> header contains without any parameters or
1980: null if the header could not be parsed properly or was omitted. The <dfn
1981: id=override-mime-type>override MIME type</dfn> is always null. <dfn
1982: id=final-mime-type>Final MIME type</dfn> is the override MIME type unless
1983: that is null in which case it is the response MIME type.
1984:
1985: <p>The <dfn id=response-charset>response charset</dfn> is the value of the
1986: <code>charset</code> parameter of the <code>Content-Type</code> header or
1987: null if there was no <code>charset</code> parameter or if the header could
1988: not be parsed properly or was omitted. The <dfn
1989: id=override-charset>override charset</dfn> is always null. <dfn
1990: id=final-charset>Final charset</dfn> is the override charset unless that
1991: is null in which case it is the response charset.
1992:
1993: <p class=note><a href="#override-mime-type">Override MIME type</a> and <a
1994: href="#override-charset">override charset</a> are introduced here solely
1995: to make editing several levels of XMLHttpRequest simultaneously somewhat
1996: easier. Apologies for any confusion they might cause.
1997:
1998: <hr>
1.205 avankest 1999:
2000: <p>The <dfn id=response-entity-body>response entity body</dfn> is the
1.257 avankest 2001: fragment of the <a href="#entity-body">entity body</a> of the response
1.277 avankest 2002: received so far (<a href="#dom-xmlhttprequest-loading"
2003: title=dom-XMLHttpRequest-LOADING>LOADING</a>) or the complete entity body
2004: of the response (<a href="#dom-xmlhttprequest-done"
2005: title=dom-XMLHttpRequest-DONE>DONE</a>). If the response does not have an
2006: entity body the response entity body is null.
1.257 avankest 2007:
2008: <p class=note>The <a href="#response-entity-body">response entity body</a>
1.276 avankest 2009: is updated as part of the <a href="#dom-xmlhttprequest-send"><code
2010: title=dom-XMLHttpRequest-send>send()</code></a> algorithm.
1.205 avankest 2011:
2012: <hr>
2013:
2014: <p>The <dfn id=text-response-entity-body>text response entity body</dfn> is
2015: a <code>DOMString</code> representing the <a
1.250 avankest 2016: href="#response-entity-body">response entity body</a>. The text response
2017: entity body is the return value of the following algorithm:
1.205 avankest 2018:
2019: <ol>
2020: <li>
1.250 avankest 2021: <p>If the response entity body is null return the empty string and
2022: terminate these steps.</p>
2023:
2024: <li>
2025: <p>Let <var>charset</var> be the <a href="#final-charset">final
2026: charset</a>.
1.205 avankest 2027:
2028: <li>
1.250 avankest 2029: <p>Let <var>mime</var> be the <a href="#final-mime-type">final MIME
2030: type</a>.
1.205 avankest 2031:
2032: <li>
1.250 avankest 2033: <p>If <var>charset</var> is null and <var>mime</var> is null,
1.205 avankest 2034: <code>text/xml</code>, <code>application/xml</code> or ends in <code
1.250 avankest 2035: title="">+xml</code> use the rules set forth in the XML specifications
2036: to determine the character encoding. Let <var>charset</var> be the
2037: determined character encoding.
1.205 avankest 2038:
2039: <li>
1.250 avankest 2040: <p>If <var>charset</var> is null and <var>mime</var> is
2041: <code>text/html</code> follow the rules set forth in the HTML
2042: specification to determine the character encoding. Let
1.205 avankest 2043: <var>charset</var> be the determined character encoding. [<cite><a
2044: href="#ref-html5">HTML5</a></cite>]
2045:
2046: <li>
2047: <p>If <var>charset</var> is null then, for each of the rows in the
2048: following table, starting with the first one and going down, if the
2049: first bytes of <var>bytes</var> match the bytes given in the first
2050: column, then let <var>charset</var> be the encoding given in the cell in
2051: the second column of that row. If there is no match <var>charset</var>
2052: remains null.</p>
2053:
2054: <table>
2055: <thead>
2056: <tr>
2057: <th>Bytes in Hexadecimal
2058:
2059: <th>Description
2060:
1.239 avankest 2061: <tbody>
1.205 avankest 2062: <tr>
2063: <td>FE FF
2064:
2065: <td>UTF-16BE BOM
2066:
2067: <tr>
2068: <td>FF FE
2069:
2070: <td>UTF-16LE BOM
2071:
2072: <tr>
2073: <td>EF BB BF
2074:
1.239 avankest 2075: <td>UTF-8 BOM
1.205 avankest 2076: </table>
2077:
2078: <li>
2079: <p>If <var>charset</var> is null let <var>charset</var> be UTF-8.
2080:
2081: <li>
2082: <p>Return the result of decoding the response entity body using
2083: <var>charset</var>. Replace bytes or sequences of bytes that are not
1.250 avankest 2084: valid accordng to the <var>charset</var> with a single U+FFFD
1.205 avankest 2085: REPLACEMENT CHARACTER character.
2086: </ol>
2087:
2088: <p class=note>Authors are strongly encouraged to encode their resources
2089: using UTF-8.
2090:
2091: <hr>
2092:
1.250 avankest 2093: <p>The <dfn id=document-response-entity-body>document response entity
2094: body</dfn> is either a <code>Document</code> representing the <a
2095: href="#response-entity-body">response entity body</a> or null. The
2096: document response entity body is the return value of the following
2097: algorithm:
1.89 avankest 2098:
1.205 avankest 2099: <ol>
2100: <li>
2101: <p>If the <a href="#response-entity-body">response entity body</a> is
1.241 avankest 2102: null terminate these steps and return null.
1.6 avankest 2103:
1.205 avankest 2104: <li>
1.250 avankest 2105: <p>If <a href="#final-mime-type">final MIME type</a> is not null,
1.300 avankest 2106: <code>text/xml</code>, <code>application/xml</code>, or does not end in
1.250 avankest 2107: <code title="">+xml</code> terminate these steps and return null.
1.12 avankest 2108:
1.205 avankest 2109: <li>
1.268 avankest 2110: <p>Let <var>document</var> be a <a
2111: href="#cookie-free-document-object">cookie-free <code>Document</code>
2112: object</a> that represents the result of parsing the response entity
2113: body into a document tree following the rules from the XML
2114: specifications. If this fails (unsupported character encoding, namespace
2115: well-formedness error et cetera) terminate these steps return null.
2116: [<cite><a href="#ref-xml">XML</a></cite>]</p>
1.6 avankest 2117:
1.205 avankest 2118: <p class=note>Scripts in the resulting document tree will not be
2119: executed, resources referenced will not be loaded and no associated XSLT
2120: will be applied.</p>
1.76 avankest 2121:
1.205 avankest 2122: <li>
1.250 avankest 2123: <p>Return <var>document</var>.
1.205 avankest 2124: </ol>
1.76 avankest 2125:
1.250 avankest 2126: <h4 id=the-responsetext-attribute><span class=secno>3.7.6. </span>The <code
1.205 avankest 2127: title="">responseText</code> attribute</h4>
1.12 avankest 2128:
1.281 avankest 2129: <dl class=domintro>
2130: <dt><var title="">client</var> . <a
2131: href="#dom-xmlhttprequest-responsetext"><code
2132: title=dom-XMLHttpRequest-responseText>responseText</code></a>
2133:
2134: <dd>
2135: <p>Returns the <a href="#text-response-entity-body">text response entity
2136: body</a>.
2137: </dl>
2138:
2139: <p>The <dfn id=dom-xmlhttprequest-responsetext
2140: title=dom-XMLHttpRequest-responseText><code>responseText</code></dfn>
1.275 avankest 2141: attribute <em class=ct>must</em> return the result of running these steps:
1.6 avankest 2142:
1.205 avankest 2143: <ol>
2144: <li>
1.277 avankest 2145: <p>If the state is not <a href="#dom-xmlhttprequest-loading"
2146: title=dom-XMLHttpRequest-LOADING>LOADING</a> or <a
2147: href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a>
1.205 avankest 2148: return the empty string and terminate these steps.
1.12 avankest 2149:
1.205 avankest 2150: <li>
2151: <p>Return the <a href="#text-response-entity-body">text response entity
2152: body</a>.
2153: </ol>
1.2 avankest 2154:
1.250 avankest 2155: <h4 id=the-responsexml-attribute><span class=secno>3.7.7. </span>The <code
1.205 avankest 2156: title="">responseXML</code> attribute</h4>
1.2 avankest 2157:
1.281 avankest 2158: <dl class=domintro>
2159: <dt><var title="">client</var> . <a
2160: href="#dom-xmlhttprequest-responsexml"><code
2161: title=dom-XMLHttpRequest-responseXML>responseXML</code></a>
2162:
2163: <dd>
2164: <p>Returns the <a href="#document-response-entity-body">document response
2165: entity body</a>.
2166: </dl>
2167:
2168: <p>The <dfn id=dom-xmlhttprequest-responsexml
2169: title=dom-XMLHttpRequest-responseXML><code>responseXML</code></dfn>
2170: attribute <em class=ct>must</em> return the result of running these steps:
1.2 avankest 2171:
1.205 avankest 2172: <ol>
2173: <li>
1.277 avankest 2174: <p>If the state is not <a href="#dom-xmlhttprequest-done"
2175: title=dom-XMLHttpRequest-DONE>DONE</a> return null and terminate these
2176: steps.
1.2 avankest 2177:
1.205 avankest 2178: <li>
1.250 avankest 2179: <p>Return the <a href="#document-response-entity-body">document response
2180: entity body</a>.
1.291 avankest 2181: </li>
2182: <!-- XXX same object -->
1.205 avankest 2183: </ol>
1.2 avankest 2184:
1.250 avankest 2185: <h2 id=exceptions><span class=secno>4. </span>Exceptions</h2>
1.33 avankest 2186:
1.139 avankest 2187: <p>Several algorithms in this specification may result in an exception
2188: being thrown. These exceptions are all part of the group
1.186 avankest 2189: <code>ExceptionCode</code> and use the <code>DOMException</code> object,
1.139 avankest 2190: which is defined in DOM Level 3 Core. In addition this specification
2191: extends the <code>ExceptionCode</code> group with several new constants as
1.146 avankest 2192: indicated below. [<cite><a href="#ref-dom3core">DOM3Core</a></cite>]
1.139 avankest 2193:
1.194 avankest 2194: <p class=note>Thus, exceptions used by this specification and not defined
2195: in this section are defined by DOM Level 3 Core.
2196:
1.34 avankest 2197: <pre
1.139 avankest 2198: class=idl>const unsigned short <a href="#security-err">SECURITY_ERR</a> = 18;
1.200 avankest 2199: const unsigned short <a href="#network-err">NETWORK_ERR</a> = 19;
2200: const unsigned short <a href="#abort-err">ABORT_ERR</a> = 20;</pre>
1.33 avankest 2201:
1.139 avankest 2202: <p>The <dfn id=security-err><code>SECURITY_ERR</code></dfn> exception is
2203: raised if an attempt is made to perform an operation or access some data
2204: in a way that would be a security risk or a violation of the user agent's
2205: security policy.</p>
2206: <!-- http://lists.w3.org/Archives/Public/public-webapi/2006May/0027.html -->
2207:
1.35 avankest 2208: <p>The <dfn id=network-err><code>NETWORK_ERR</code></dfn> exception is
1.139 avankest 2209: raised when a network error occurs in synchronous requests.
1.122 avankest 2210:
1.139 avankest 2211: <p>The <dfn id=abort-err><code>ABORT_ERR</code></dfn> exception is raised
1.122 avankest 2212: when the user aborts a request in synchronous requests.
2213:
1.242 avankest 2214: <p class=note>These exceptions will be folded into an update of DOM Level 3
2215: Core in due course, as they are appropriate for other API specifications
1.200 avankest 2216: as well.
2217:
1.250 avankest 2218: <h2 class=no-num id=references>References</h2>
1.2 avankest 2219:
1.178 avankest 2220: <p>Unless marked "Non-normative" these references are normative.
2221:
1.7 avankest 2222: <dl>
1.232 avankest 2223: <dt>[<dfn id=ref-cookies>COOKIES</dfn>]
1.205 avankest 2224:
1.273 avankest 2225: <dd><cite><a
2226: href="http://tools.ietf.org/html/draft-ietf-httpstate-cookie">HTTP State
2227: Management Mechanism</a></cite> (work in progress), A. Barth. IETF.
1.205 avankest 2228:
1.156 avankest 2229: <dt>[<dfn id=ref-dom2events>DOM2Events</dfn>]
2230:
2231: <dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Events/">Document
1.272 avankest 2232: Object Model (DOM) Level 2 Events Specification</a></cite>, T. Pixley.
2233: W3C.
1.156 avankest 2234:
1.146 avankest 2235: <dt>[<dfn id=ref-dom3core>DOM3Core</dfn>]
1.2 avankest 2236:
1.15 avankest 2237: <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object
2238: Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. Le
1.272 avankest 2239: Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne. W3C.
1.2 avankest 2240:
1.39 avankest 2241: <dt>[<dfn id=ref-ecmascript>ECMAScript</dfn>]
1.18 avankest 2242:
2243: <dd><cite><a
2244: href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript
1.272 avankest 2245: Language Specification</a></cite>. ECMA.
1.18 avankest 2246:
1.146 avankest 2247: <dt>[<dfn id=ref-html5>HTML5</dfn>]
1.143 avankest 2248:
1.252 avankest 2249: <dd><cite><a href="http://www.w3.org/html/wg/html5/">HTML5</a></cite>
1.272 avankest 2250: (work in progress), I. Hickson. W3C.
1.172 avankest 2251:
2252: <dd><cite><a
1.295 avankest 2253: href="http://www.whatwg.org/specs/web-apps/current-work/">HTML5</a></cite>
1.272 avankest 2254: (work in progress), I. Hickson. WHATWG.
1.18 avankest 2255:
1.199 avankest 2256: <dt>[<dfn id=ref-httpverbsec>HTTPVERBSEC</dfn>]
2257:
2258: <dd>(Non-normative) <cite><a
2259: href="http://www.kb.cert.org/vuls/id/867593">Multiple vendors' web
2260: servers enable HTTP TRACE method by default</a></cite>, US-CERT.
2261:
2262: <dd>(Non-normative) <cite><a
2263: href="http://www.kb.cert.org/vuls/id/288308">Microsoft Internet
2264: Information Server (IIS) vulnerable to cross-site scripting via HTTP
2265: TRACK method</a></cite>, US-CERT.
2266:
2267: <dd>(Non-normative) <cite><a
2268: href="http://www.kb.cert.org/vuls/id/150227">HTTP proxy default
2269: configurations allow arbitrary TCP connections</a></cite>, US-CERT.
2270:
1.250 avankest 2271: <dt>[<dfn id=ref-rfc2046>RFC2046</dfn>]
2272:
2273: <dd><cite><a href="http://ietf.org/rfc/rfc2046">Multipurpose Internet Mail
2274: Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N.
1.272 avankest 2275: Borenstein. IETF.
1.250 avankest 2276:
1.146 avankest 2277: <dt>[<dfn id=ref-rfc2119>RFC2119</dfn>]
1.15 avankest 2278:
1.118 avankest 2279: <dd><cite><a href="http://ietf.org/rfc/rfc2119">Key words for use in RFCs
1.272 avankest 2280: to Indicate Requirement Levels</a></cite>, S. Bradner. IETF.
1.15 avankest 2281:
1.250 avankest 2282: <dt>[<dfn id=rfc-rfc2616>RFC2616</dfn>]
1.15 avankest 2283:
2284: <dd><cite><a href="http://ietf.org/rfc/rfc2616">Hypertext Transfer
2285: Protocol -- HTTP/1.1</a></cite>, R. Fielding, J. Gettys, J. Mogul, H.
1.272 avankest 2286: Frystyk, L. Masinter, P. Leach, T. Berners-Lee. IETF.
1.15 avankest 2287:
1.39 avankest 2288: <dt>[<dfn id=ref-rfc2617>RFC2617</dfn>]
1.15 avankest 2289:
2290: <dd><cite><a href="http://ietf.org/rfc/rfc2617">HTTP Authentication: Basic
1.93 avankest 2291: and Digest Access Authentication</a></cite>, P. Hallam-Baker, J.
1.272 avankest 2292: Hostetler, S. Lawrence, P. Leach, A. Luotonen, L. Stewart. IETF.
1.2 avankest 2293:
1.39 avankest 2294: <dt>[<dfn id=ref-rfc3986>RFC3986</dfn>]
1.2 avankest 2295:
1.15 avankest 2296: <dd><cite><a href="http://ietf.org/rfc/rfc3986">Uniform Resource
2297: Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding,
1.272 avankest 2298: L. Masinter. IETF.
1.188 avankest 2299:
1.250 avankest 2300: <dt>[<dfn id=ref-rfc3987>RFC3987</dfn>]
2301:
2302: <dd><cite><a href="http://ietf.org/rfc/rfc3987">Internationalized Resource
1.272 avankest 2303: Identifiers (IRIs)</a></cite>, M. Duerst, M. Suignard. IETF.
1.250 avankest 2304:
1.205 avankest 2305: <dt>[<dfn id=ref-webidl>WebIDL</dfn>]
1.182 avankest 2306:
1.201 avankest 2307: <dd><cite><a href="http://dev.w3.org/2006/webapi/WebIDL/">Web
1.272 avankest 2308: IDL</a></cite> (work in progress), C. McCormack. W3C.</dd>
1.252 avankest 2309: <!-- XXX add Sam -->
1.182 avankest 2310:
1.43 avankest 2311: <dt>[<dfn id=ref-xml>XML</dfn>]
2312:
2313: <dd><cite><a href="http://www.w3.org/TR/xml/">Extensible Markup Language
1.272 avankest 2314: (XML) 1.0</a></cite>, T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler,
2315: F. Yergeau. W3C.
1.43 avankest 2316:
1.272 avankest 2317: <dd><cite><a href="http://www.w3.org/TR/xml-names/">Namespaces in
2318: XML</a></cite>, T. Bray, D. Hollander, A. Layman, R. Tobin, H. S.
2319: Thompson. W3C.
1.2 avankest 2320: </dl>
2321:
1.131 avankest 2322: <h2 class=no-num id=acknowledgments>Acknowledgments</h2>
1.2 avankest 2323:
1.164 avankest 2324: <p>The editor would like to thank Addison Phillips, Ahmed Kamel, Alex
2325: Hopmann, Alex Vincent, Alexey Proskuryakov, Asbjørn Ulsberg, Boris
2326: Zbarsky, Björn Höhrmann, Cameron McCormack, Christophe Jolif,
1.250 avankest 2327: Charles McCathieNevile, Dan Winship, David Andersson, David
2328: Håsäther, David Levin, Dean Jackson, Denis Sureau, Doug
2329: Schepers, Douglas Livingstone, Elliotte Harold, Eric Lawrence, Erik
2330: Dahlström, Geoffrey Sneddon, Gideon Cohn, Gorm Haug Eriksen,
2331: Håkon Wium Lie, Hallvord R. M. Steen, Huub Schaeks, Ian Davis, Ian
2332: Hickson, Ivan Herman, Jeff Walden, Jens Lindström, Jim Deegan, Jim
2333: Ley, Joe Farro, Jonas Sicking, Julian Reschke, Karl Dubost, Lachlan Hunt,
2334: Maciej Stachowiak, Magnus Kristiansen, Marc Hadley, Marcos Caceres, Mark
1.272 avankest 2335: Baker, Mark Birbeck, Mark Nottingham, Mark S. Miller, Martin Hassman,
2336: Mohamed Zergaoui, Olli Pettay, Pawel Glowacki, Peter Michaux, Philip
2337: Taylor, Robin Berjon, Rune Halvorsen, Ruud Steltenpool, Simon Pieters,
2338: Stewart Brodie, Sunava Dutta, Thomas Roessler, Tom Magliery, and Zhenbin
2339: Xu for their contributions to this specification.
1.2 avankest 2340:
2341: <p>Special thanks to the Microsoft employees who first implemented the
1.144 avankest 2342: <code title="">XMLHttpRequest</code> interface, which was first widely
2343: deployed by the Windows Internet Explorer browser.
1.2 avankest 2344:
1.56 avankest 2345: <p>Special thanks also to the WHATWG for drafting an initial version of
1.131 avankest 2346: this specification in their Web Applications 1.0 document (now renamed to
1.252 avankest 2347: HTML5). [<cite><a href="#ref-html5">HTML5</a></cite>]
1.2 avankest 2348:
2349: <p>Thanks also to all those who have helped to improve this specification
2350: by sending suggestions and corrections. (Please, keep bugging us with your
2351: issues!)
Webmaster