Annotation of 2006/webapi/XMLHttpRequest/Overview.html, revision 1.316
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.316 ! avankest 43: <h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 14 September 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.316 ! avankest 49: href="http://www.w3.org/TR/2010/ED-XMLHttpRequest-20100914/">http://www.w3.org/TR/2010/ED-XMLHttpRequest-20100914/</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.316 ! avankest 132: <p>This is the 14 September 2010 <!--Last Call Working Draft-->Editor's
1.311 avankest 133: Draft 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.312 avankest 313: <pre><code>function processData(data) {
1.316 ! avankest 314: // taking care of data
1.18 avankest 315: }
316:
317: function handler() {
1.316 ! avankest 318: if(this.readyState == this.DONE) {
! 319: if(this.status == 200 &&
! 320: this.responseXML != null &&
! 321: this.responseXML.getElementById('test').textContent) {
1.312 avankest 322: // success!
323: processData(this.responseXML.getElementById('test').textContent);
324: return;
325: }
1.316 ! avankest 326: // something went wrong
! 327: processData(null);
1.312 avankest 328: }
1.18 avankest 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.312 avankest 339: var client = new XMLHttpRequest();
340: client.open("POST", "/log");
341: client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
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.312 avankest 348: var client = new XMLHttpRequest();
349: client.onreadystatechange = function() {
350: // in case of network errors this might not give reliable results
1.314 avankest 351: if(this.readyState == this.DONE)
1.312 avankest 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.314 avankest 395: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
396: class=ct>must</em> support at least the subset of the functionality
397: defined in DOM Events and DOM Core that this specification relies upon,
398: such as various exceptions and <code>EventTarget</code>. [<cite><a
1.156 avankest 399: href="#ref-dom2events">DOM2Events</a></cite>] [<cite><a
400: href="#ref-dom3core">DOM3Core</a></cite>]
1.2 avankest 401:
1.252 avankest 402: <dt>HTML5
1.162 avankest 403:
404: <dd>
1.183 avankest 405: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
1.190 avankest 406: class=ct>must</em> support at least the subset of the functionality
1.252 avankest 407: defined in HTML5 that this specification relies upon, such as the basics
408: of the <code>Window</code> object and serializing a
1.198 avankest 409: <code>Document</code> object. [<cite><a
410: href="#ref-html5">HTML5</a></cite>]</p>
1.190 avankest 411:
1.162 avankest 412: <p class=note>The <a
413: href="http://www.w3.org/TR/2006/WD-Window-20060407/">Window Object
414: 1.0</a> draft is not referenced normatively as it appears to be no
1.252 avankest 415: longer maintained and HTML5 defines the <code>Window</code> object in
416: more detail. This specification already depends on HTML5 for other
417: reasons so there is not much additional overhead because of this.</p>
1.162 avankest 418:
1.31 avankest 419: <dt>HTTP
1.11 avankest 420:
1.31 avankest 421: <dd>
1.304 avankest 422: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
423: class=ct>must</em> support some version of the HTTP protocol.
424: Requirements regarding HTTP are made throughout the specification.
425: [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.182 avankest 426:
427: <dt>Web IDL
428:
1.250 avankest 429: <dd>
430: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
431: class=ct>must</em> also be a conforming implementation of the IDL
432: fragments in this specification, as described in the Web IDL
433: specification. [<cite><a href="#ref-webidl">WebIDL</a></cite>]
1.304 avankest 434:
435: <dt>XML
436:
437: <dd>
438: <p>A <a href="#conforming-user-agent">conforming user agent</a> <em
439: class=ct>must</em> be a conforming XML processor that reports violations
440: of namespace well-formedness. [<cite><a href="#ref-xml">XML</a></cite>]
1.31 avankest 441: </dl>
1.2 avankest 442:
1.248 avankest 443: <h3 id=terminology><span class=secno>2.2. </span>Terminology</h3>
1.211 avankest 444:
1.286 avankest 445: <p><dfn id=dfn-obtain-unicode>Convert a DOMString to a sequence of Unicode
1.235 avankest 446: characters</dfn> is defined by the Web IDL specification. [<cite><a
447: href="#ref-webidl">WebIDL</a></cite>]
448:
1.259 avankest 449: <p>The terms and algorithms <dfn
450: id=url-fragment><code><fragment></code></dfn>, <dfn
451: id=url-scheme><code><scheme></code></dfn>, <dfn
1.268 avankest 452: id=cookie-free-document-object>cookie-free <code>Document</code>
453: object</dfn>, <dfn id=document-base-url>document base URL</dfn>, <dfn
1.259 avankest 454: id=document-character-encoding>document's character encoding</dfn>, <dfn
455: id=event-handler-attributes-0>event handler attributes</dfn>, <dfn
456: id=event-handler-event-type>event handler event type</dfn>, <dfn
1.262 avankest 457: id=fetch>fetch</dfn>, <dfn id=fully-active>fully active</dfn>, <dfn
1.307 avankest 458: id=function><code>Function</code></dfn>, <dfn id=html-documents>HTML
459: documents</dfn>, <dfn id=dom-innerhtml
1.227 avankest 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>();
1.309 avankest 543: void <a href="#dom-xmlhttprequest-send" title=dom-XMLHttpRequest-send>send</a>(<span>Document</span> <var>data</var>);
1.276 avankest 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>;
1.309 avankest 553: readonly attribute <span>Document</span> <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.314 avankest 706: <p>The <dfn id=error-flag>error flag</dfn> indicates some type of network
707: error or abortion. It is used during the <a
708: href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a>
709: state. It can be either true or false and has an initial value of false.
1.205 avankest 710:
1.250 avankest 711: <h3 id=request><span class=secno>3.6. </span>Request</h3>
1.112 avankest 712:
1.270 avankest 713: <p>The <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object
1.225 avankest 714: holds the following request metadata variables:
1.112 avankest 715:
1.206 avankest 716: <dl>
717: <dt>The <dfn id=asynchronous-flag>asynchronous flag</dfn>
718:
1.271 avankest 719: <dd>True when <a href="#fetch" title=fetch>fetching</a> is done
720: asychronously. False when fetching is done synchronously.
1.206 avankest 721:
722: <dt>The <dfn id=request-method>request method</dfn>
723:
1.314 avankest 724: <dd>The HTTP method used in the request.
1.206 avankest 725:
726: <dt>The <dfn id=request-url>request URL</dfn>
727:
1.316 ! avankest 728: <dd>The resolved <a href="#url">URL</a> used in the request.
1.206 avankest 729:
730: <dt>The <dfn id=request-username>request username</dfn>
731:
732: <dd>The username used in the request or null if there is no username.
733:
734: <dt>The <dfn id=request-password>request password</dfn>
735:
736: <dd>The password used in the request or null if there is no password.
1.112 avankest 737:
1.206 avankest 738: <dt>The <dfn id=author-request-headers>author request headers</dfn>
1.112 avankest 739:
1.206 avankest 740: <dd>A list consisting of HTTP header name/value pairs to be used in the
741: request.
1.112 avankest 742:
1.206 avankest 743: <dt>The <dfn id=request-entity-body>request entity body</dfn>
1.112 avankest 744:
1.314 avankest 745: <dd>The <a href="#entity-body">entity body</a> used in the request or null
746: if there is no <a href="#entity-body">entity body</a>.
1.206 avankest 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.305 avankest 781: <p>Throws an <code>INVALID_ACCESS_ERR</code> exception if either <var
782: title="">user</var> or <var title="">password</var> is passed as
783: argument and the <a href="#origin">origin</a> of <var title="">url</var>
784: does not match the <a
785: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>.</p>
1.274 avankest 786: </dl>
787:
1.275 avankest 788: <p>When the <dfn id=dom-xmlhttprequest-open
1.279 avankest 789: title=dom-XMLHttpRequest-open><code>open(<var title="">method</var>, <var
790: title="">url</var>, <var title="">async</var>, <var title="">user</var>,
791: <var title="">password</var>)</code></dfn> method is invoked, the user
792: agent <em class=ct>must</em> run these steps (unless otherwise indicated):
1.112 avankest 793:
1.205 avankest 794: <ol>
795: <li>
1.270 avankest 796: <p>If the <a href="#xmlhttprequest"><code>XMLHttpRequest</code></a>
1.225 avankest 797: object has an associated <a
1.205 avankest 798: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
799: <code>Document</code></a> run these substeps:</p>
1.112 avankest 800:
1.205 avankest 801: <ol>
802: <li>
803: <p>If the <a
804: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
805: <code>Document</code></a> is not <a href="#fully-active">fully
806: active</a> raise an <code>INVALID_STATE_ERR</code> exception and
807: terminate the overall set of steps.
808:
809: <li>
810: <p>Let <a href="#xmlhttprequest-base-url"><code>XMLHttpRequest</code>
811: base URL</a> be the <a href="#document-base-url">document base URL</a>
812: of the <a href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
813: <code>Document</code></a>.
814:
815: <li>
816: <p>Let <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
817: origin</a> be the <a href="#origin">origin</a> of the <a
818: href="#xmlhttprequest-document"><code>XMLHttpRequest</code>
819: <code>Document</code></a>.
820: </ol>
1.112 avankest 821:
822: <li>
1.258 avankest 823: <p>If any code point in <var>method</var> is higher than U+00FF LATIN
1.299 avankest 824: SMALL LETTER Y WITH DIAERESIS or after <a
825: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
826: DOMString into a byte sequence">deflating</a> <var>method</var> it does
827: not match the <a href="#method-token">Method token</a> production raise
828: a <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
829: let <var>method</var> be the result of <a
830: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
831: DOMString into a byte sequence">deflating</a> <var>method</var>.
1.258 avankest 832: </li>
833: <!-- This sounds lame, but it works. -->
1.91 avankest 834:
835: <li>
1.258 avankest 836: <p>If <var>method</var> is a case-insensitive match for
837: <code>CONNECT</code>, <code>DELETE</code>, <code>GET</code>,
838: <code>HEAD</code>, <code>OPTIONS</code>, <code>POST</code>,
839: <code>PUT</code>, <code>TRACE</code>, or <code>TRACK</code> subtract
840: 0x20 from each byte in the range 0x61 (ASCII a) to 0x7A (ASCII z).</p>
1.205 avankest 841:
842: <p class=note>If it does not match any of the above, it is passed through
843: <em>literally</em>, including in the final request.</p>
844: </li>
845: <!-- WebKit (and supposedly Gecko) also uppercase: COPY, INDEX, LOCK,
846: M-POST, MKCOL, MOVE, PROPFIND, PROPPATCH, and UNLOCK. -->
1.89 avankest 847:
1.205 avankest 848: <li>
1.258 avankest 849: <p>If <var>method</var> is a case-sensitive match for
1.261 avankest 850: <code>CONNECT</code>, <code>TRACE</code>, or <code>TRACK</code> raise a
1.270 avankest 851: <a href="#security-err"><code>SECURITY_ERR</code></a> exception and
1.261 avankest 852: terminate these steps.</p>
1.164 avankest 853:
1.205 avankest 854: <p class=note>Allowing these methods poses a security risk. [<cite><a
855: href="#ref-httpverbsec">HTTPVERBSEC</a></cite>]</p>
1.89 avankest 856:
1.91 avankest 857: <li>
1.205 avankest 858: <p>Let <var title="">url</var> be a <a href="#url">URL</a>.
1.89 avankest 859:
860: <li>
1.205 avankest 861: <p>Let <a href="#url-character-encoding">URL character encoding</a> of
862: <var title="">url</var> be UTF-8.
1.89 avankest 863:
864: <li>
1.257 avankest 865: <p><a href="#resolve-a-url" title="Resolve a URL">Resolve</a> <var
866: title="">url</var> relative to the <a
1.205 avankest 867: href="#xmlhttprequest-base-url"><code>XMLHttpRequest</code> base
868: URL</a>. If the algorithm returns an error raise a
869: <code>SYNTAX_ERR</code> exception and terminate these steps.
870: </li>
871: <!-- Presto and Gecko override the encoding. WebKit does not. Trident
872: does not support non-ASCII URLs. This matters for the <query> component,
873: see HTML5. -->
1.129 avankest 874:
1.205 avankest 875: <li>
1.270 avankest 876: <p>Drop <a href="#url-fragment"><code><fragment></code></a> from <var
1.205 avankest 877: title="">url</var>.
1.89 avankest 878:
879: <li>
1.270 avankest 880: <p>If the <code>"user:password"</code> format in the <a
881: href="#userinfo"><code>userinfo</code></a> production is not supported
1.306 avankest 882: for the relevant <a href="#url-scheme"><code><scheme></code></a> and
883: <var title="">url</var> contains this format raise a
884: <code>SYNTAX_ERR</code> and terminate these steps.
1.314 avankest 885: </li>
886: <!-- XXX need to throw here for "user:password" or just "user" for
887: cross-origin unless we solve this in another way -->
1.2 avankest 888:
1.205 avankest 889: <li>
890: <p>If <var title="">url</var> contains the <code>"user:password"</code>
891: format let <var>temp user</var> be the user part and <var>temp
892: password</var> be the password part.
1.2 avankest 893:
1.205 avankest 894: <li>
895: <p>If <var title="">url</var> just contains the <code>"user"</code>
896: format let <var>temp user</var> be the user part.
1.2 avankest 897:
1.205 avankest 898: <li>
899: <p>Let <var>async</var> be the value of the <var>async</var> argument or
1.271 avankest 900: true if it was omitted.
1.2 avankest 901:
1.205 avankest 902: <li>
1.305 avankest 903: <p>If the <var title="">user</var> argument was not omitted follow these
904: sub steps:</p>
1.2 avankest 905:
1.60 avankest 906: <ol>
907: <li>
1.305 avankest 908: <p>If <var title="">user</var> is not null and the <a
909: href="#origin">origin</a> of <var title="">url</var> is not <a
910: href="#same-origin">same origin</a> with the <a
911: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>
912: raise an <code>INVALID_ACCESS_ERR</code> exception and terminate the
913: overall set of steps.
1.2 avankest 914:
1.60 avankest 915: <li>
1.305 avankest 916: <p>Let <var>temp user</var> be <var>user</var>.
1.205 avankest 917: </ol>
1.184 avankest 918:
1.205 avankest 919: <p class=note>These steps override anything that may have been set by the
920: <var title="">url</var> argument.</p>
1.157 avankest 921:
1.205 avankest 922: <li>
1.305 avankest 923: <p>If the <var title="">password</var> argument was not omitted follow
924: these sub steps:</p>
1.2 avankest 925:
1.205 avankest 926: <ol>
1.60 avankest 927: <li>
1.305 avankest 928: <p>If <var title="">password</var> is not null and the <a
929: href="#origin">origin</a> of <var title="">url</var> is not <a
930: href="#same-origin">same origin</a> with the <a
931: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>
932: raise an <code>INVALID_ACCESS_ERR</code> exception and terminate the
933: overall set of steps.
1.2 avankest 934:
1.60 avankest 935: <li>
1.305 avankest 936: <p>Let <var>temp password</var> be <var>password</var>.
1.205 avankest 937: </ol>
1.102 avankest 938:
1.205 avankest 939: <p class=note>These steps override anything that may have been set by the
940: <var title="">url</var> argument.</p>
1.2 avankest 941:
1.205 avankest 942: <li>
943: <p><a href="#abort-send-algorithm" title="abort send()">Abort the
944: <code>send()</code> algorithm</a>.
1.2 avankest 945:
1.205 avankest 946: <li>
947: <p>The user agent <em class=ct>should</em> cancel any network activity
948: for which the object is responsible.
949: </li>
950: <!-- we can hardly require it... -->
1.24 avankest 951:
1.205 avankest 952: <li>
1.254 avankest 953: <p>If there are any <a href="#task" title=task>tasks</a> from the
954: object's <a
955: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
956: source</a> in one of the <a href="#task-queues">task queues</a>, then
957: remove those tasks.
958:
959: <li>
1.205 avankest 960: <p>Set variables associated with the object as follows:</p>
1.70 avankest 961:
1.205 avankest 962: <ul>
1.60 avankest 963: <li>
1.205 avankest 964: <p>Set the <a href="#request-method">request method</a> to
965: <var>method</var>.
1.17 avankest 966:
1.60 avankest 967: <li>
1.205 avankest 968: <p>Set the <a href="#request-url">request URL</a> to <var
969: title="">url</var>.
1.17 avankest 970:
1.60 avankest 971: <li>
1.308 avankest 972: <p>Set the <a href="#asynchronous-flag">asynchronous flag</a> to the
973: value of <var>async</var>.
974:
975: <li>
1.205 avankest 976: <p>Set the <a href="#request-username">request username</a> to
977: <var>temp user</var>.
1.17 avankest 978:
1.60 avankest 979: <li>
1.205 avankest 980: <p>Set the <a href="#request-password">request password</a> to
981: <var>temp password</var>.
1.17 avankest 982:
1.60 avankest 983: <li>
1.308 avankest 984: <p>Empty the list of <a href="#author-request-headers">author request
985: headers</a>.</p>
986:
987: <li>
988: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to false.
989:
990: <li>
991: <p>Set <a href="#response-entity-body">response entity body</a> to
992: null.
1.205 avankest 993: </ul>
1.44 avankest 994:
1.205 avankest 995: <li>
1.312 avankest 996: <p>Switch the state to <a href="#dom-xmlhttprequest-opened"
1.277 avankest 997: title=dom-XMLHttpRequest-OPENED>OPENED</a>.
1.176 avankest 998:
1.205 avankest 999: <li>
1000: <p><a href="#dispatch-readystatechange-event">Dispatch a
1001: <code>readystatechange</code> event</a>.
1002: </ol>
1.22 avankest 1003:
1.250 avankest 1004: <h4 id=the-setrequestheader-method><span class=secno>3.6.2. </span>The
1.248 avankest 1005: <code title="">setRequestHeader()</code> method</h4>
1.275 avankest 1006:
1007: <dl class=domintro>
1.284 avankest 1008: <dt><var title="">client</var> . <a
1009: href="#dom-xmlhttprequest-setrequestheader"><code
1010: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader(<var
1011: title="">header</var>, <var title="">value</var>)</code></a>
1.275 avankest 1012:
1013: <dd>
1014: <p>Appends an header to the list of <a
1.314 avankest 1015: href="#author-request-headers">author request headers</a>, or if
1016: <var>header</var> is already in the list of <a
1017: href="#author-request-headers">author request headers</a>, combines its
1018: value with <var>value</var>.</p>
1.285 avankest 1019:
1020: <p>Throws an <code>INVALID_STATE_ERR</code> exception if the state is not
1021: <a href="#dom-xmlhttprequest-opened"
1022: title=dom-XMLHttpRequest-OPENED>OPENED</a> or if the <a
1023: href="#send-flag"><code>send()</code> flag</a> is true.</p>
1024:
1025: <p>Throws a <code>SYNTAX_ERR</code> exception if <var
1026: title="">header</var> is not a valid HTTP header field name or if <var
1027: title="">value</var> is not a valid HTTP header field value.</p>
1.275 avankest 1028: </dl>
1.205 avankest 1029:
1.284 avankest 1030: <p class=note>As indicated in the algorithm below certain headers cannot be
1031: set and are left up to the user agent. In addition there are certain other
1032: headers the user agent will take control of if they are not set by the
1033: author as indicated at the end of the <a
1034: href="#dom-xmlhttprequest-send"><code
1.276 avankest 1035: title=dom-XMLHttpRequest-send>send()</code></a> method section.
1.205 avankest 1036:
1.275 avankest 1037: <p>When the <dfn id=dom-xmlhttprequest-setrequestheader
1.284 avankest 1038: title=dom-XMLHttpRequest-setRequestHeader><code>setRequestHeader(<var
1039: title="">header</var>, <var title="">value</var>)</code></dfn> method is
1040: invoked, the user agent <em class=ct>must</em> run these steps:
1.6 avankest 1041:
1.205 avankest 1042: <ol>
1043: <li>
1.277 avankest 1044: <p>If the state is not <a href="#dom-xmlhttprequest-opened"
1045: title=dom-XMLHttpRequest-OPENED>OPENED</a> raise an
1046: <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.47 avankest 1047:
1.205 avankest 1048: <li>
1049: <p>If the <a href="#send-flag"><code>send()</code> flag</a> is true raise
1050: an <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1051:
1.205 avankest 1052: <li>
1.258 avankest 1053: <p>If any code point in <var>header</var> is higher than U+00FF LATIN
1.299 avankest 1054: SMALL LETTER Y WITH DIAERESIS or after <a
1055: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1056: DOMString into a byte sequence">deflating</a> <var>header</var> it does
1057: not match the <a href="#field-name">field-name</a> production raise a
1.258 avankest 1058: <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
1.299 avankest 1059: let <var>header</var> be the result of <a
1060: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1061: DOMString into a byte sequence">deflating</a> <var>header</var>.
1.258 avankest 1062: </li>
1063: <!-- This sounds lame, but it works. -->
1.6 avankest 1064:
1.205 avankest 1065: <li>
1.258 avankest 1066: <p>If any code point in <var>value</var> is higher than U+00FF LATIN
1.299 avankest 1067: SMALL LETTER Y WITH DIAERESIS or after <a
1068: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1069: DOMString into a byte sequence">deflating</a> <var>value</var> it does
1070: not match the <a href="#field-value">field-value</a> production raise a
1.258 avankest 1071: <code>SYNTAX_ERR</code> exception and terminate these steps. Otherwise
1.299 avankest 1072: let <var>value</var> be the result of <a
1073: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1074: DOMString into a byte sequence">deflating</a> <var>value</var>.</p>
1.258 avankest 1075: <!-- This sounds lame, but it works. -->
1.205 avankest 1076: <p class=note>The empty string is legal and represents the empty header
1077: value.</p>
1.71 avankest 1078:
1.205 avankest 1079: <li>
1.261 avankest 1080: <p>Terminate these steps if <var>header</var> is a case-insensitive match
1081: for one of the following headers:</p>
1.179 avankest 1082:
1.205 avankest 1083: <ul>
1084: <li><code>Accept-Charset</code>
1.60 avankest 1085:
1.205 avankest 1086: <li><code>Accept-Encoding</code>
1.34 avankest 1087:
1.205 avankest 1088: <li><code>Connection</code>
1.34 avankest 1089:
1.205 avankest 1090: <li><code>Content-Length</code>
1.177 avankest 1091:
1.205 avankest 1092: <li><code>Cookie</code>
1.69 avankest 1093:
1.205 avankest 1094: <li><code>Cookie2</code>
1.34 avankest 1095:
1.205 avankest 1096: <li><code>Content-Transfer-Encoding</code>
1.177 avankest 1097:
1.205 avankest 1098: <li><code>Date</code>
1.177 avankest 1099:
1.205 avankest 1100: <li><code>Expect</code>
1.69 avankest 1101:
1.205 avankest 1102: <li><code>Host</code>
1.69 avankest 1103:
1.205 avankest 1104: <li><code>Keep-Alive</code>
1.34 avankest 1105:
1.205 avankest 1106: <li><code>Referer</code>
1.34 avankest 1107:
1.205 avankest 1108: <li><code>TE</code>
1.34 avankest 1109:
1.205 avankest 1110: <li><code>Trailer</code>
1.34 avankest 1111:
1.205 avankest 1112: <li><code>Transfer-Encoding</code>
1.34 avankest 1113:
1.205 avankest 1114: <li><code>Upgrade</code>
1.34 avankest 1115:
1.205 avankest 1116: <li><code>User-Agent</code>
1.34 avankest 1117:
1.205 avankest 1118: <li><code>Via</code>
1119: </ul>
1.69 avankest 1120:
1.258 avankest 1121: <p>… or if the start of <var>header</var> is a case-insensitive
1122: match for <code>Proxy-</code> or <code>Sec-</code> (including when
1.205 avankest 1123: <var>header</var> is just <code>Proxy-</code> or <code>Sec-</code>).</p>
1124:
1.285 avankest 1125: <p class=note>The above headers are controlled by the user agent to let
1126: it control those aspects of transport. This guarantees data integrity to
1127: some extent. Header names starting with <code>Sec-</code> are not
1128: allowed to be set to allow new headers to be minted that are guaranteed
1129: not to come from <a
1130: href="#xmlhttprequest"><code>XMLHttpRequest</code></a>.</p>
1.185 avankest 1131:
1.205 avankest 1132: <li>
1133: <p>If <var>header</var> is not in the <a
1134: href="#author-request-headers">author request headers</a> list append
1135: <var>header</var> with its associated <var>value</var> to the list and
1136: terminate these steps.
1.6 avankest 1137:
1.205 avankest 1138: <li>
1139: <p>If <var>header</var> is in the <a
1140: href="#author-request-headers">author request headers</a> list either
1141: use multiple headers, combine the values or use a combination of those
1142: (section 4.2, RFC 2616). [<cite><a
1.250 avankest 1143: href="#rfc-rfc2616">RFC2616</a></cite>]
1.205 avankest 1144: </li>
1145: <!-- XXX it seems UAs always combine the values -->
1146: </ol>
1.18 avankest 1147:
1.276 avankest 1148: <p class=note>See also the <a href="#dom-xmlhttprequest-send"><code
1149: title=dom-XMLHttpRequest-send>send()</code></a> method regarding user
1150: agent header handling for caching, authentication, proxies, and cookies.
1.47 avankest 1151:
1.205 avankest 1152: <div class=example>
1.316 ! avankest 1153: <p>Some simple code demonstrating what happens when setting the same
! 1154: header twice:</p>
! 1155:
1.205 avankest 1156: <pre><code>// The following script:
1.18 avankest 1157: var client = new XMLHttpRequest();
1158: client.open('GET', 'demo.cgi');
1159: client.setRequestHeader('X-Test', 'one');
1160: client.setRequestHeader('X-Test', 'two');
1161: client.send();
1162:
1.316 ! avankest 1163: // …results in the following header being sent:
! 1164: X-Test: one, two</code></pre>
1.205 avankest 1165: </div>
1.6 avankest 1166:
1.250 avankest 1167: <h4 id=the-send-method><span class=secno>3.6.3. </span>The <code
1.205 avankest 1168: title="">send()</code> method</h4>
1.276 avankest 1169:
1170: <dl class=domintro>
1171: <dt><var title="">client</var> . <a href="#dom-xmlhttprequest-send"><code
1172: title=dom-XMLHttpRequest-send>send(<var title="">data</var>)</code></a>
1173:
1174: <dd>
1175: <p>Initiates the request. The optional argument provides the <a
1.285 avankest 1176: href="#request-entity-body">request entity body</a>. The argument is
1177: ignored if <a href="#request-method">request method</a> is
1178: <code>GET</code> or <code>HEAD</code>.</p>
1179:
1180: <p>Throws an <code>INVALID_STATE_ERR</code> exception if the state is not
1181: <a href="#dom-xmlhttprequest-opened"
1182: title=dom-XMLHttpRequest-OPENED>OPENED</a> or if the <a
1183: href="#send-flag"><code>send()</code> flag</a> is true.</p>
1.276 avankest 1184: </dl>
1.205 avankest 1185:
1.275 avankest 1186: <p>When the <dfn id=dom-xmlhttprequest-send
1.276 avankest 1187: title=dom-XMLHttpRequest-send><code>send(<var>data</var>)</code></dfn>
1188: method is invoked, the user agent <em class=ct>must</em> run the following
1189: steps (unless otherwise noted). This algorithm gets aborted when the <a
1.279 avankest 1190: href="#dom-xmlhttprequest-open"><code
1191: title=dom-XMLHttpRequest-open>open()</code></a> or <a
1.280 avankest 1192: href="#dom-xmlhttprequest-abort"><code
1193: title=dom-XMLHttpRequest-abort>abort()</code></a> method is invoked. When
1194: the <dfn id=abort-send-algorithm title="abort send()"><code>send()</code>
1195: algorithm is aborted</dfn> the user agent <em class=ct>must</em> terminate
1196: the algorithm after finishing the step it is on.
1.205 avankest 1197:
1198: <p class=note>The <code title="">send()</code> algorithm can only be
1199: aborted when the <a href="#asynchronous-flag">asynchronous flag</a> is
1200: true and only after the method call has returned.
1.60 avankest 1201:
1.205 avankest 1202: <ol>
1203: <li>
1.277 avankest 1204: <p>If the state is not <a href="#dom-xmlhttprequest-opened"
1205: title=dom-XMLHttpRequest-OPENED>OPENED</a> raise an
1206: <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1207:
1.205 avankest 1208: <li>
1209: <p>If the <a href="#send-flag"><code>send()</code> flag</a> is true raise
1210: an <code>INVALID_STATE_ERR</code> exception and terminate these steps.
1.60 avankest 1211:
1.205 avankest 1212: <li>
1.285 avankest 1213: <p>If the <a href="#request-method">request method</a> is a
1214: case-sensitive match for <code>GET</code> or <code>HEAD</code> act as if
1215: <var title="">data</var> is null.</p>
1.203 avankest 1216:
1.241 avankest 1217: <p>If the <var>data</var> argument has been omitted or is null, do not
1218: include a <a href="#request-entity-body">request entity body</a> and go
1219: to the next step.</p>
1.234 avankest 1220:
1.250 avankest 1221: <p>Otherwise, let <var>encoding</var> be null, <var>mime type</var> be
1222: null, and then follow these rules:</p>
1.205 avankest 1223:
1224: <dl class=switch>
1.250 avankest 1225: <dt>If <var>data</var> is a <code>Document</code>
1.205 avankest 1226:
1227: <dd>
1.234 avankest 1228: <p>Let <var>encoding</var> be the <a
1229: href="#preferred-mime-name">preferred MIME name</a> of the <a
1.246 avankest 1230: href="#document-character-encoding" title="document's character
1.234 avankest 1231: encoding">character encoding</a> of <var>data</var>. If
1232: <var>encoding</var> is UTF-16 change it to UTF-8.</p>
1233:
1.307 avankest 1234: <p>Let <var>mime type</var> be "<code>application/xml</code>" or
1235: "<code>text/html</code>" if <code>Document</code> is flagged as <a
1236: href="#html-documents" title="HTML documents">HTML document</a>,
1237: followed by "<code>;charset=</code>", followed by <var>encoding</var>.</p>
1.234 avankest 1238:
1239: <p>Let the <a href="#request-entity-body">request entity body</a> be
1.270 avankest 1240: the result of getting the <a href="#dom-innerhtml"><code
1241: title=dom-innerHTML>innerHTML</code></a> attribute on <var>data</var>
1242: <a href="#dfn-obtain-unicode" title="convert a DOMString to a sequence
1243: of Unicode characters">converted to Unicode</a> and encoded as
1244: <var>encoding</var>. Re-raise any exception this raises.</p>
1.210 avankest 1245:
1.235 avankest 1246: <p class=note>In particular, if the document cannot be serialized an
1.219 avankest 1247: <code>INVALID_STATE_ERR</code> exception is raised.</p>
1248:
1.205 avankest 1249: <p class=note>Subsequent changes to the <code>Document</code> have no
1250: effect on what is submitted.</p>
1.239 avankest 1251:
1.250 avankest 1252: <dt>If <var>data</var> is a <code>DOMString</code>
1.239 avankest 1253:
1254: <dd>
1.250 avankest 1255: <p>Let <var>encoding</var> be UTF-8.</p>
1256:
1257: <p>Let <var>mime type</var> be "<code>text/plain;charset=UTF-8</code>".</p>
1258:
1.239 avankest 1259: <p>Let the <a href="#request-entity-body">request entity body</a> be
1260: <var>data</var> <a href="#dfn-obtain-unicode" title="convert a
1261: DOMString to a sequence of Unicode characters">converted to
1.250 avankest 1262: Unicode</a> and encoded as UTF-8.</p>
1.205 avankest 1263: </dl>
1.103 avankest 1264:
1.270 avankest 1265: <p>If a <code>Content-Type</code> header is set using <a
1.284 avankest 1266: href="#dom-xmlhttprequest-setrequestheader"><code
1267: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.275 avankest 1268: whose value is a <a href="#valid-mime-type">valid MIME type</a> and has
1269: a <code>charset</code> parameter whose value is not a case-insensitive
1.284 avankest 1270: match for <var title="">encoding</var>, and <var title="">encoding</var>
1271: is not null, set all the <code>charset</code> parameters of the
1272: <code>Content-Type</code> header to <var title="">encoding</var>.</p>
1.234 avankest 1273:
1.270 avankest 1274: <p>If no <code>Content-Type</code> header has been set using <a
1.284 avankest 1275: href="#dom-xmlhttprequest-setrequestheader"><code
1276: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1277: and <var title="">mime type</var> is not null set a
1278: <code>Content-Type</code> request header with as value <var
1279: title="">mime type</var>.</p>
1.238 avankest 1280: <!-- reminder: if we ever change this to always include charset it has
1281: to be included as the first parameter for compatibility reasons -->
1282:
1.167 avankest 1283:
1.205 avankest 1284: <li>
1285: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1286: release the <a href="#storage-mutex">storage mutex</a>.
1.60 avankest 1287:
1.205 avankest 1288: <li>
1289: <p>Set the <a href="#error-flag">error flag</a> to false.
1.164 avankest 1290:
1.205 avankest 1291: <li>
1.213 avankest 1292: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is true run
1293: these substeps:</p>
1294:
1295: <ol>
1296: <li>
1.219 avankest 1297: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to true.
1298:
1299: <li>
1.213 avankest 1300: <p><a href="#dispatch-readystatechange-event">Dispatch a
1301: <code>readystatechange</code> event</a>.</p>
1302:
1303: <p class=note>The state does not change. The event is dispatched for
1304: historical reasons.</p>
1305:
1306: <li>
1.276 avankest 1307: <p>Return the <a href="#dom-xmlhttprequest-send"><code
1308: title=dom-XMLHttpRequest-send>send()</code></a> method call, but
1309: continue running the steps in this algorithm.
1.213 avankest 1310: </ol>
1311:
1312: <li>
1.226 avankest 1313: <dl class=switch>
1.305 avankest 1314: <dt>If the <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
1315: origin</a> and the <a href="#request-url">request URL</a> are <a
1316: href="#same-origin">same origin</a>
1.195 avankest 1317:
1.205 avankest 1318: <dd>
1.305 avankest 1319: <p>These are the <dfn id=same-origin-request-steps>same-origin request
1320: steps</dfn>.</p>
1321:
1322: <p><a href="#fetch">Fetch</a> the <a href="#request-url">request
1323: URL</a> from <i title="">origin</i> <a
1324: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a>,
1325: with the <i title="">synchronous flag</i> set if the <a
1326: href="#asynchronous-flag">asynchronous flag</a> is false, using HTTP
1327: method <a href="#request-method">request method</a>, user <a
1328: href="#request-username">request username</a> (if non-null) and
1329: password <a href="#request-password">request password</a> (if
1330: non-null), taking into account the <a
1331: href="#request-entity-body">request entity body</a>, list of <a
1332: href="#author-request-headers">author request headers</a> and the
1333: rules listed at the end of this section.</p>
1334:
1335: <dl class=switch>
1336: <dt>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1337:
1338: <dd>
1339: <p>While making the request also follow the <a
1340: href="#same-origin-request-event-rules">same-origin request event
1341: rules</a>.</p>
1342: <!--
1.250 avankest 1343: This cannot involve any task queue whatsoever because that would
1344: mean other tasks on the task queue might get processed as well
1345: which is counter to the whole idea of doing things synchronous.
1346: -->
1.305 avankest 1347:
1348: <p class=note>The <a href="#dom-xmlhttprequest-send"><code
1349: title=dom-XMLHttpRequest-send>send()</code></a> method call will now
1350: be returned by virtue of this algorithm ending.</p>
1351:
1352: <dt>If the <a href="#asynchronous-flag">asynchronous flag</a> is true
1353:
1354: <dd>
1355: <p>While processing the request, as data becomes available and when
1356: the user interferes with the request, <a href="#queue-a-task"
1357: title="queue a task">queue tasks</a> to update the <a
1358: href="#response-entity-body">response entity body</a> and follow the
1359: <a href="#same-origin-request-event-rules">same-origin request event
1360: rules</a>.</p>
1361: </dl>
1.205 avankest 1362:
1.305 avankest 1363: <dt>Otherwise
1.205 avankest 1364:
1365: <dd>
1.305 avankest 1366: <p>These are the <dfn id=cross-origin-request-steps>cross-origin
1367: request steps</dfn>.</p>
1.250 avankest 1368:
1.305 avankest 1369: <p>This is a <a href="#network-error">network error</a>.</p>
1.205 avankest 1370: </dl>
1371: </ol>
1.124 avankest 1372:
1.205 avankest 1373: <hr>
1374:
1.229 avankest 1375: <p>If the user agent allows the end user to configure a proxy it <em
1.250 avankest 1376: class=ct>should</em> modify the request appropriately; i.e., connect to
1377: the proxy host instead of the origin server, modify the
1.214 avankest 1378: <code>Request-Line</code> and send <code>Proxy-Authorization</code>
1379: headers as specified.
1380:
1.264 avankest 1381: <hr>
1382:
1383: <p>If the user agent supports HTTP Authentication and <code
1384: title=http-authorization>Authorization</code> is not in the list of <a
1.220 avankest 1385: href="#author-request-headers">author request headers</a>, it <em
1.270 avankest 1386: class=ct>should</em> consider requests originating from the <a
1387: href="#xmlhttprequest"><code>XMLHttpRequest</code></a> object to be part
1388: of the protection space that includes the accessed URIs and send <code
1.264 avankest 1389: title=http-authorization>Authorization</code> headers and handle <code>401
1390: Unauthorized</code> requests appropriately.
1391:
1.315 avankest 1392: <p>If authentication fails, <a
1393: href="#xmlhttprequest-origin"><code>XMLHttpRequest</code> origin</a> and
1394: the <a href="#request-url">request URL</a> are <a href="#same-origin">same
1395: origin</a>, <code title=http-authorization>Authorization</code> is not in
1396: the list of <a href="#author-request-headers">author request headers</a>,
1397: <a href="#request-username">request username</a> is null, and <a
1.264 avankest 1398: href="#request-password">request password</a> is null, user agents <em
1399: class=ct>should</em> prompt the end user for their username and password.
1400:
1.315 avankest 1401: <p>Otherwise, if authentication fails, user agents <em class=ct>must
1402: not</em> prompt the end user for their username and password. [<cite><a
1403: href="#ref-rfc2617">RFC2617</a></cite>]
1404:
1405: <p class=note>End users are not prompted for various cases so that authors
1406: can implement their own user interface.
1.214 avankest 1407:
1.264 avankest 1408: <hr>
1409:
1.214 avankest 1410: <p>If the user agent supports HTTP State Management it <em
1411: class=ct>should</em> persist, discard and send cookies (as received in the
1.302 avankest 1412: <code>Set-Cookie</code> response header, and sent in the
1413: <code>Cookie</code> header) as applicable. [<cite><a
1.232 avankest 1414: href="#ref-cookies">COOKIES</a></cite>]
1.214 avankest 1415:
1.264 avankest 1416: <hr>
1417:
1.214 avankest 1418: <p>If the user agent implements a HTTP cache it <em class=ct>should</em>
1.270 avankest 1419: respect <code>Cache-Control</code> request headers set by the <a
1.284 avankest 1420: href="#dom-xmlhttprequest-setrequestheader"><code
1421: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.275 avankest 1422: (e.g., <code>Cache-Control: no-cache</code> bypasses the cache). It <em
1.214 avankest 1423: class=ct>must not</em> send <code>Cache-Control</code> or
1.229 avankest 1424: <code>Pragma</code> request headers automatically unless the end user
1.284 avankest 1425: explicitly requests such behavior (e.g. by reloading the page).
1.214 avankest 1426:
1427: <p>For <code>304 Not Modified</code> responses that are a result of a user
1428: agent generated conditional request the user agent <em class=ct>must</em>
1429: act as if the server gave a <code>200 OK</code> response with the
1.270 avankest 1430: appropriate content. The user agent <em class=ct>must</em> allow <a
1.284 avankest 1431: href="#dom-xmlhttprequest-setrequestheader"><code
1432: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a> to
1433: override automatic cache validation by setting request headers (e.g.
1.250 avankest 1434: <code>If-None-Match</code> or <code>If-Modified-Since</code>), in which
1435: case <code>304 Not Modified</code> responses <em class=ct>must</em> be
1436: passed through. [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.214 avankest 1437:
1.264 avankest 1438: <hr>
1439:
1.214 avankest 1440: <p>If the user agent implements server-driven content-negotiation it <em
1.303 avankest 1441: class=ct>must</em> follow these constraints for the <code>Accept</code>
1442: and <code>Accept-Language</code> request headers:
1.233 avankest 1443:
1444: <ul>
1445: <li>
1446: <p>Both headers <em class=ct>must not</em> be modified if they are
1.284 avankest 1447: already set through <a href="#dom-xmlhttprequest-setrequestheader"><code
1448: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>.
1.233 avankest 1449:
1450: <li>
1.270 avankest 1451: <p>If not set through <a
1.284 avankest 1452: href="#dom-xmlhttprequest-setrequestheader"><code
1453: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.257 avankest 1454: <code>Accept-Language</code> <em class=ct>should</em> be set as
1.233 avankest 1455: appropriate.
1456:
1457: <li>
1.270 avankest 1458: <p>If not set through <a
1.284 avankest 1459: href="#dom-xmlhttprequest-setrequestheader"><code
1460: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>
1.233 avankest 1461: <code>Accept</code> <em class=ct>must</em> be set with as value
1462: <code>*/*</code>.
1463: </ul>
1464:
1465: <p>Responses <em class=ct>must</em> have the content-encodings
1.250 avankest 1466: automatically decoded. [<cite><a href="#rfc-rfc2616">RFC2616</a></cite>]
1.214 avankest 1467:
1.264 avankest 1468: <hr>
1469:
1.214 avankest 1470: <p>Besides the <a href="#author-request-headers">author request headers</a>
1471: user agents <em class=ct>should not</em> include additional request
1472: headers other than those mentioned above or other than those authors are
1.270 avankest 1473: not allowed to set using <a
1.284 avankest 1474: href="#dom-xmlhttprequest-setrequestheader"><code
1475: title=dom-XMLHttpRequest-setRequestHeader>setRequestHeader()</code></a>.
1.275 avankest 1476: This ensures that authors have a reasonably predictable API.
1.214 avankest 1477:
1.250 avankest 1478: <h4 id=infrastructure-for-the-send-method><span class=secno>3.6.4.
1.214 avankest 1479: </span>Infrastructure for the <code title="">send()</code> method</h4>
1480:
1.221 avankest 1481: <p>The <dfn id=same-origin-request-event-rules>same-origin request event
1482: rules</dfn> are as follows:
1.205 avankest 1483:
1484: <dl class=switch>
1.290 avankest 1485: <dt>If the response has an HTTP status code of 301, 302, 303, or 307
1.205 avankest 1486:
1487: <dd>
1.305 avankest 1488: <p>If the redirect violates infinite loop precautions this is a <a
1489: href="#network-error">network error</a>.</p>
1.205 avankest 1490:
1.305 avankest 1491: <p>Otherwise, run these steps:</p>
1492:
1493: <ol>
1494: <li>
1495: <p>Set the <a href="#request-url">request URL</a> to the <a
1496: href="#url">URL</a> conveyed by the <code>Location</code> header.
1497:
1498: <li>
1499: <p>If the <a href="#xmlhttprequest-origin"><code>XMLHttpRequest</code>
1500: origin</a> and the <a href="#origin">origin</a> of <a
1501: href="#request-url">request URL</a> are <a href="#same-origin">same
1502: origin</a> transparently follow the redirect while observing the <a
1503: href="#same-origin-request-event-rules">same-origin request event
1504: rules</a>.
1505:
1506: <li>
1507: <p>Otherwise, follow the <a
1508: href="#cross-origin-request-steps">cross-origin request steps</a> and
1509: terminate the steps for this algorithm.
1510: </ol>
1.250 avankest 1511:
1.205 avankest 1512: <p class=note>HTTP places requirements on the user agent regarding the
1.206 avankest 1513: preservation of the <a href="#request-method">request method</a> and <a
1514: href="#request-entity-body">request entity body</a> during redirects,
1.229 avankest 1515: and also requires end users to be notified of certain kinds of automatic
1.205 avankest 1516: redirections.</p>
1517: <!-- XXX HTTP needs fixing here -->
1518:
1.290 avankest 1519: <dt>If the end user cancels the request
1.205 avankest 1520:
1.215 avankest 1521: <dd>
1522: <p>This is an <a href="#abort-error">abort error</a>.
1.119 avankest 1523:
1.290 avankest 1524: <dt>If there is a network error
1.216 avankest 1525:
1.215 avankest 1526: <dd>
1527: <p>In case of DNS errors, TLS negotiation failure, or other type of
1528: network errors, this is a <a href="#network-error">network error</a>. Do
1.229 avankest 1529: not request any kind of end user interaction.</p>
1.205 avankest 1530:
1.215 avankest 1531: <p class=note>This does not include HTTP responses that indicate some
1532: type of error, such as HTTP status code 410.</p>
1.119 avankest 1533:
1.310 avankest 1534: <dt>Once all HTTP headers have been received, the <a
1535: href="#asynchronous-flag">asynchronous flag</a> is true, and the HTTP
1536: status code of the response is not 301, 302, 303, or 307
1.60 avankest 1537:
1.215 avankest 1538: <dd>
1.289 avankest 1539: <p><a href="#switch-headers-received">Switch to the HEADERS_RECEIVED
1540: state</a>.
1.60 avankest 1541:
1.222 avankest 1542: <dt>Once the first byte (or more) of the <a
1543: href="#response-entity-body">response entity body</a> has been received
1544: and the <a href="#asynchronous-flag">asynchronous flag</a> is true
1545:
1546: <dt>If there is no <a href="#response-entity-body">response entity
1547: body</a> and the <a href="#asynchronous-flag">asynchronous flag</a> is
1.215 avankest 1548: true
1.19 avankest 1549:
1.222 avankest 1550: <dd>
1.289 avankest 1551: <p><a href="#switch-loading">Switch to the LOADING state</a>.
1.222 avankest 1552:
1553: <dt>Once the whole <a href="#response-entity-body">response entity
1554: body</a> has been received
1555:
1556: <dt>If there is no <a href="#response-entity-body">response entity
1.301 avankest 1557: body</a> and the state is <a href="#dom-xmlhttprequest-loading"
1558: title=dom-XMLHttpRequest-LOADING>LOADING</a>
1559:
1560: <dt>If there is no <a href="#response-entity-body">response entity
1.226 avankest 1561: body</a> and the <a href="#asynchronous-flag">asynchronous flag</a> is
1.301 avankest 1562: false
1.185 avankest 1563:
1.215 avankest 1564: <dd>
1.289 avankest 1565: <p><a href="#switch-done">Switch to the DONE state</a>.
1.215 avankest 1566: </dl>
1.6 avankest 1567:
1.215 avankest 1568: <hr>
1.6 avankest 1569:
1.215 avankest 1570: <p>When something is said to be a <dfn id=network-error>network error</dfn>
1.270 avankest 1571: run the <a href="#request-error">request error</a> steps for exception <a
1572: href="#network-err"><code>NETWORK_ERR</code></a>.
1.62 avankest 1573:
1.243 avankest 1574: <p>When something is said to be an <dfn id=abort-error>abort error</dfn>
1.270 avankest 1575: run the <a href="#request-error">request error</a> steps for exception <a
1576: href="#abort-err"><code>ABORT_ERR</code></a>.
1.84 avankest 1577:
1.244 avankest 1578: <p>When something is said to be a <dfn id=request-error>request error</dfn>
1579: for exception <var>exception</var> run these steps:
1.60 avankest 1580:
1.256 avankest 1581: <ol>
1582: <li>
1583: <p>The user agent <em class=ct>should</em> cancel any network activity
1584: for which the object is responsible.
1585:
1586: <li>
1587: <p>If there are any <a href="#task" title=task>tasks</a> from the
1588: object's <a
1589: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
1590: source</a> in one of the <a href="#task-queues">task queues</a>, then
1591: remove those tasks.
1.252 avankest 1592:
1.215 avankest 1593: <li>
1594: <p>Set the <a href="#response-entity-body">response entity body</a> to
1595: null.
1.205 avankest 1596:
1.215 avankest 1597: <li>
1.256 avankest 1598: <p>Empty the list of <a href="#author-request-headers">author request
1599: headers</a>.
1.205 avankest 1600:
1.215 avankest 1601: <li>
1.256 avankest 1602: <p>Set the the <a href="#error-flag">error flag</a> to true.
1.205 avankest 1603:
1.215 avankest 1604: <li>
1.277 avankest 1605: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1606: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.205 avankest 1607:
1.215 avankest 1608: <li>
1609: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1.243 avankest 1610: raise an <var>exception</var> exception and terminate the overall set of
1611: steps.
1.205 avankest 1612:
1.215 avankest 1613: <li>
1.251 avankest 1614: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.250 avankest 1615: <code>readystatechange</code> event</a>.</p>
1616:
1617: <p class=note>At this point it is clear that the <a
1618: href="#asynchronous-flag">asynchronous flag</a> is true.</p>
1.215 avankest 1619: </ol>
1.6 avankest 1620:
1.278 avankest 1621: <p class=note>A future version of this specification will dispatch an <code
1.280 avankest 1622: title=event-xhr-error>error</code>/<code>abort</code> event here as well.
1623: (Depending on the type of error.)
1.6 avankest 1624:
1.215 avankest 1625: <hr>
1.2 avankest 1626:
1.215 avankest 1627: <p>When it is said to <dfn id=switch-headers-received>switch to the
1.289 avankest 1628: HEADERS_RECEIVED state</dfn> run these steps:
1.60 avankest 1629:
1.215 avankest 1630: <ol>
1631: <li>
1.277 avankest 1632: <p>Switch the state to <a href="#dom-xmlhttprequest-headers_received"
1633: title="dom-XMLHttpRequest-HEADERS_RECEIVED">HEADERS_RECEIVED</a>.
1.125 avankest 1634:
1.215 avankest 1635: <li>
1.251 avankest 1636: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.215 avankest 1637: <code>readystatechange</code> event</a>.
1638: </ol>
1.205 avankest 1639:
1.289 avankest 1640: <p>When it is said to <dfn id=switch-loading>switch to the LOADING
1641: state</dfn> run these steps:
1.205 avankest 1642:
1.215 avankest 1643: <ol>
1644: <li>
1.277 avankest 1645: <p>Switch the state to <a href="#dom-xmlhttprequest-loading"
1646: title=dom-XMLHttpRequest-LOADING>LOADING</a>.
1.17 avankest 1647:
1.215 avankest 1648: <li>
1.251 avankest 1649: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.215 avankest 1650: <code>readystatechange</code> event</a>.
1651: </ol>
1.205 avankest 1652:
1.289 avankest 1653: <p>When it is said to <dfn id=switch-done>switch to the DONE state</dfn>
1654: run these steps:
1.218 avankest 1655:
1656: <ol>
1657: <li>
1.257 avankest 1658: <p>If the <a href="#asynchronous-flag">asynchronous flag</a> is false
1659: update the <a href="#response-entity-body">response entity body</a>.
1660:
1661: <li>
1.277 avankest 1662: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1663: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.218 avankest 1664:
1665: <li>
1.250 avankest 1666: <p><a href="#dispatch-readystatechange-event">Dispatch a
1.218 avankest 1667: <code>readystatechange</code> event</a>.
1668: </ol>
1669:
1.250 avankest 1670: <h4 id=the-abort-method><span class=secno>3.6.5. </span>The <code
1.205 avankest 1671: title="">abort()</code> method</h4>
1672:
1.280 avankest 1673: <dl class=domintro>
1674: <dt><var title="">client</var> . <a href="#dom-xmlhttprequest-abort"><code
1675: title=dom-XMLHttpRequest-abort>abort()</code></a>
1676:
1677: <dd>Cancels any network activity.
1678: </dl>
1679:
1680: <p>When the <dfn id=dom-xmlhttprequest-abort
1681: title=dom-XMLHttpRequest-abort><code>abort()</code></dfn> method is
1682: invoked, the user agent <em class=ct>must</em> run these steps (unless
1683: otherwise noted):
1.205 avankest 1684:
1685: <ol>
1686: <li>
1687: <p><a href="#abort-send-algorithm" title="abort send()">Abort the
1688: <code>send()</code> algorithm</a>.
1.202 avankest 1689:
1.205 avankest 1690: <li>
1691: <p>The user agent <em class=ct>should</em> cancel any network activity
1692: for which the object is responsible.
1.254 avankest 1693:
1694: <li>
1695: <p>If there are any <a href="#task" title=task>tasks</a> from the
1696: object's <a
1697: href="#xmlhttprequest-task-source"><code>XMLHttpRequest</code> task
1698: source</a> in one of the <a href="#task-queues">task queues</a>, then
1699: remove those tasks.
1.205 avankest 1700:
1701: <li>
1702: <p>Set the <a href="#response-entity-body">response entity body</a> to
1703: null.
1704:
1705: <li>
1.254 avankest 1706: <p>Empty the list of <a href="#author-request-headers">author request
1707: headers</a>.
1.205 avankest 1708:
1709: <li>
1.254 avankest 1710: <p>Set the <a href="#error-flag">error flag</a> to true.
1.205 avankest 1711:
1712: <li>
1.277 avankest 1713: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1714: title=dom-XMLHttpRequest-UNSENT>UNSENT</a>, <a
1715: href="#dom-xmlhttprequest-opened"
1716: title=dom-XMLHttpRequest-OPENED>OPENED</a> with the <a
1717: href="#send-flag"><code>send()</code> flag</a> being false, or <a
1718: href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a>
1719: go to the next step.</p>
1.205 avankest 1720:
1721: <p>Otherwise run these substeps:</p>
1722:
1723: <ol>
1.202 avankest 1724: <li>
1.277 avankest 1725: <p>Switch the state to <a href="#dom-xmlhttprequest-done"
1726: title=dom-XMLHttpRequest-DONE>DONE</a>.
1.77 avankest 1727:
1728: <li>
1.205 avankest 1729: <p>Set the <a href="#send-flag"><code>send()</code> flag</a> to false.
1.77 avankest 1730:
1731: <li>
1.205 avankest 1732: <p><a href="#dispatch-readystatechange-event">Dispatch a
1733: <code>readystatechange</code> event</a>.
1.60 avankest 1734: </ol>
1.17 avankest 1735:
1.252 avankest 1736: <p class=note>A future version of this specification will dispatch an
1.278 avankest 1737: <code title=event-xhr-abort>abort</code> event here.</p>
1.220 avankest 1738:
1.205 avankest 1739: <li>
1.277 avankest 1740: <p>Switch the state to <a href="#dom-xmlhttprequest-unsent"
1741: title=dom-XMLHttpRequest-UNSENT>UNSENT</a>.</p>
1.205 avankest 1742:
1.278 avankest 1743: <p class=note>No <code
1744: title=event-xhr-readystatechange>readystatechange</code> event is
1745: dispatched.</p>
1.205 avankest 1746: </ol>
1747:
1.250 avankest 1748: <h3 id=response><span class=secno>3.7. </span>Response</h3>
1.205 avankest 1749:
1.250 avankest 1750: <h4 id=the-status-attribute><span class=secno>3.7.1. </span>The <code
1.205 avankest 1751: title="">status</code> attribute</h4>
1752:
1.281 avankest 1753: <dl class=domintro>
1754: <dt><var title="">client</var> . <a
1755: href="#dom-xmlhttprequest-status"><code
1756: title=dom-XMLHttpRequest-status>status</code></a>
1757:
1758: <dd>
1759: <p>Returns the HTTP status code.
1760: </dl>
1761:
1762: <p>The <dfn id=dom-xmlhttprequest-status
1763: title=dom-XMLHttpRequest-status><code>status</code></dfn> attribute <em
1764: class=ct>must</em> return the result of running these steps:
1.224 avankest 1765:
1766: <ol>
1767: <li>
1.277 avankest 1768: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1769: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1770: href="#dom-xmlhttprequest-opened"
1771: title=dom-XMLHttpRequest-OPENED>OPENED</a> return 0 and terminate these
1772: steps.
1.224 avankest 1773:
1774: <li>
1.241 avankest 1775: <p>If the <a href="#error-flag">error flag</a> is true return 0 and
1776: terminate these steps.
1.224 avankest 1777:
1778: <li>
1779: <p>Return the HTTP status code.
1780: </ol>
1.205 avankest 1781:
1.250 avankest 1782: <h4 id=the-statustext-attribute><span class=secno>3.7.2. </span>The <code
1.205 avankest 1783: title="">statusText</code> attribute</h4>
1784:
1.281 avankest 1785: <dl class=domintro>
1786: <dt><var title="">client</var> . <a
1787: href="#dom-xmlhttprequest-statustext"><code
1788: title=dom-XMLHttpRequest-statusText>statusText</code></a>
1789:
1790: <dd>
1791: <p>Returns the HTTP status text.
1792: </dl>
1793:
1794: <p>The <dfn id=dom-xmlhttprequest-statustext
1795: title=dom-XMLHttpRequest-statusText><code>statusText</code></dfn>
1.275 avankest 1796: attribute <em class=ct>must</em> return the result of running these steps:
1.224 avankest 1797:
1798: <ol>
1799: <li>
1.277 avankest 1800: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1801: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1802: href="#dom-xmlhttprequest-opened"
1803: title=dom-XMLHttpRequest-OPENED>OPENED</a> return the empty string and
1804: terminate these steps.
1.224 avankest 1805:
1806: <li>
1807: <p>If the <a href="#error-flag">error flag</a> is true return the empty
1808: string and terminate these steps.
1809:
1810: <li>
1811: <p>Return the HTTP status text.
1812: </ol>
1.205 avankest 1813:
1.250 avankest 1814: <h4 id=the-getresponseheader-method><span class=secno>3.7.3. </span>The
1.205 avankest 1815: <code title="">getResponseHeader()</code> method</h4>
1816:
1.283 avankest 1817: <dl class=domintro>
1818: <dt><var title="">client</var> . <a
1819: href="#dom-xmlhttprequest-getresponseheader"><code
1820: title=dom-XMLHttpRequest-getResponseHeader>getResponseHeader(<var
1821: title="">header</var>)</code></a>
1822:
1823: <dd>
1824: <p>Returns the header field value from the response of which the field
1825: name matches <var title="">header</var>, unless the field name is
1826: <code>Set-Cookie</code> or <code>Set-Cookie2</code>.
1827: </dl>
1828:
1.275 avankest 1829: <p>When the <dfn id=dom-xmlhttprequest-getresponseheader
1.283 avankest 1830: title=dom-XMLHttpRequest-getResponseHeader><code>getResponseHeader(<var
1831: title="">header</var>)</code></dfn> is invoked, the user agent <em
1832: class=ct>must</em> run these steps:
1.205 avankest 1833:
1834: <ol>
1835: <li>
1.277 avankest 1836: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1837: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1838: href="#dom-xmlhttprequest-opened"
1839: title=dom-XMLHttpRequest-OPENED>OPENED</a> return null and terminate
1840: these steps.
1.205 avankest 1841:
1842: <li>
1.241 avankest 1843: <p>If the <a href="#error-flag">error flag</a> is true return null and
1844: terminate these steps.
1.205 avankest 1845:
1846: <li>
1.258 avankest 1847: <p>If any code point in <var>header</var> is higher than U+00FF LATIN
1848: SMALL LETTER Y WITH DIAERESIS return null and terminate these steps.
1849:
1850: <li>
1.299 avankest 1851: <p>Let <var>header</var> be the result of <a
1852: href="#deflate-a-domstring-into-a-byte-sequence" title="deflate a
1853: DOMString into a byte sequence">deflating</a> <var>header</var>.
1.258 avankest 1854: </li>
1855: <!-- This sounds lame, but it works. -->
1.205 avankest 1856:
1857: <li>
1.258 avankest 1858: <p>If <var>header</var> is a case-insensitive match for
1859: <code>Set-Cookie</code> or <code>Set-Cookie2</code> return null and
1.205 avankest 1860: terminate these steps.
1861:
1862: <li>
1.258 avankest 1863: <p>If <var>header</var> is a case-insensitive match for multiple HTTP
1.299 avankest 1864: response headers, return the <a
1865: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1866: sequence into a DOMString">inflated</a> values of these headers as a
1867: single concatenated string separated from each other by a U+002C COMMA
1868: U+0020 SPACE character pair and terminate these steps.
1.258 avankest 1869:
1870: <li>
1871: <p>If <var>header</var> is a case-insensitive match for a single HTTP
1.299 avankest 1872: response header, return the <a
1873: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1874: sequence into a DOMString">inflated</a> value of that header and
1875: terminate these steps.
1.205 avankest 1876:
1877: <li>
1.241 avankest 1878: <p>Return null.
1.205 avankest 1879: </ol>
1880:
1881: <div class=example>
1.252 avankest 1882: <p>For the following script:</p>
1883:
1884: <pre><code>var client = new XMLHttpRequest();
1885: client.open("GET", "unicorns-are-teh-awesome.txt", true);
1.6 avankest 1886: client.send();
1.16 avankest 1887: client.onreadystatechange = function() {
1.252 avankest 1888: if(this.readyState == 2) {
1889: print(client.getResponseHeader("Content-Type"));
1890: }
1891: }</code></pre>
1892:
1893: <p>The <code>print()</code> function will get to process something like:</p>
1.1 avankest 1894:
1.252 avankest 1895: <pre><code>text/plain; charset=UTF-8</code></pre>
1.205 avankest 1896: </div>
1897:
1.250 avankest 1898: <h4 id=the-getallresponseheaders-method><span class=secno>3.7.4. </span>The
1.205 avankest 1899: <code title="">getAllResponseHeaders()</code> method</h4>
1.2 avankest 1900:
1.283 avankest 1901: <dl class=domintro>
1.298 avankest 1902: <dt><var title="">client</var> . <a
1903: href="#dom-xmlhttprequest-getallresponseheaders"><code
1904: title=dom-XMLHttpRequest-getAllResponseHeaders>getAllResponseHeaders()</code></a>
1.283 avankest 1905:
1906: <dd>
1907: <p>Returns all headers from the response, with the exception of those
1908: whose field name is <code>Set-Cookie</code> or <code>Set-Cookie2</code>.
1909: </dl>
1910:
1.298 avankest 1911: <p>When the <dfn id=dom-xmlhttprequest-getallresponseheaders
1912: title=dom-XMLHttpRequest-getAllResponseHeaders><code>getAllResponseHeaders()</code></dfn>
1.275 avankest 1913: method is invoked, the user agent <em class=ct>must</em> run the following
1914: steps:
1.6 avankest 1915:
1.205 avankest 1916: <ol>
1917: <li>
1.277 avankest 1918: <p>If the state is <a href="#dom-xmlhttprequest-unsent"
1919: title=dom-XMLHttpRequest-UNSENT>UNSENT</a> or <a
1920: href="#dom-xmlhttprequest-opened"
1921: title=dom-XMLHttpRequest-OPENED>OPENED</a> return the empty string and
1922: terminate these steps.
1.205 avankest 1923:
1924: <li>
1925: <p>If the <a href="#error-flag">error flag</a> is true return the empty
1926: string and terminate these steps.
1927:
1928: <li>
1.258 avankest 1929: <p>Return all the HTTP headers, excluding headers that are a
1930: case-insensitive match for <code>Set-Cookie</code> or
1.299 avankest 1931: <code>Set-Cookie2</code>, <a
1932: href="#inflate-a-byte-sequence-into-a-domstring" title="inflate a byte
1933: sequence into a DOMString">inflated</a>, as a single string, with each
1934: header line separated by a U+000D CR U+000A LF pair, excluding the
1935: status line, and with each header name and header value separated by a
1936: U+003A COLON U+0020 SPACE pair.
1.205 avankest 1937: </ol>
1938:
1939: <div class=example>
1.252 avankest 1940: <p>For the following script:</p>
1941:
1942: <pre><code>var client = new XMLHttpRequest();
1943: client.open("GET", "narwhals-too.txt", true);
1.205 avankest 1944: client.send();
1945: client.onreadystatechange = function() {
1.312 avankest 1946: if(this.readyState == 2) {
1947: print(this.getAllResponseHeaders());
1948: }
1.252 avankest 1949: }</code></pre>
1950:
1951: <p>The <code>print()</code> function will get to process something like:</p>
1.205 avankest 1952:
1.252 avankest 1953: <pre><code>Date: Sun, 24 Oct 2004 04:58:38 GMT
1.205 avankest 1954: Server: Apache/1.3.31 (Unix)
1955: Keep-Alive: timeout=15, max=99
1956: Connection: Keep-Alive
1957: Transfer-Encoding: chunked
1958: Content-Type: text/plain; charset=utf-8</code></pre>
1959: </div>
1960:
1.250 avankest 1961: <h4 id=response-entity-body0><span class=secno>3.7.5. </span>Response
1.248 avankest 1962: Entity Body</h4>
1.250 avankest 1963:
1964: <p>The <dfn id=response-mime-type>response MIME type</dfn> is the MIME type
1965: the <code>Content-Type</code> header contains without any parameters or
1966: null if the header could not be parsed properly or was omitted. The <dfn
1967: id=override-mime-type>override MIME type</dfn> is always null. <dfn
1968: id=final-mime-type>Final MIME type</dfn> is the override MIME type unless
1969: that is null in which case it is the response MIME type.
1970:
1971: <p>The <dfn id=response-charset>response charset</dfn> is the value of the
1972: <code>charset</code> parameter of the <code>Content-Type</code> header or
1973: null if there was no <code>charset</code> parameter or if the header could
1974: not be parsed properly or was omitted. The <dfn
1975: id=override-charset>override charset</dfn> is always null. <dfn
1976: id=final-charset>Final charset</dfn> is the override charset unless that
1977: is null in which case it is the response charset.
1978:
1979: <p class=note><a href="#override-mime-type">Override MIME type</a> and <a
1980: href="#override-charset">override charset</a> are introduced here solely
1981: to make editing several levels of XMLHttpRequest simultaneously somewhat
1982: easier. Apologies for any confusion they might cause.
1983:
1984: <hr>
1.205 avankest 1985:
1986: <p>The <dfn id=response-entity-body>response entity body</dfn> is the
1.257 avankest 1987: fragment of the <a href="#entity-body">entity body</a> of the response
1.277 avankest 1988: received so far (<a href="#dom-xmlhttprequest-loading"
1989: title=dom-XMLHttpRequest-LOADING>LOADING</a>) or the complete entity body
1990: of the response (<a href="#dom-xmlhttprequest-done"
1991: title=dom-XMLHttpRequest-DONE>DONE</a>). If the response does not have an
1992: entity body the response entity body is null.
1.257 avankest 1993:
1994: <p class=note>The <a href="#response-entity-body">response entity body</a>
1.276 avankest 1995: is updated as part of the <a href="#dom-xmlhttprequest-send"><code
1996: title=dom-XMLHttpRequest-send>send()</code></a> algorithm.
1.205 avankest 1997:
1998: <hr>
1999:
2000: <p>The <dfn id=text-response-entity-body>text response entity body</dfn> is
2001: a <code>DOMString</code> representing the <a
1.250 avankest 2002: href="#response-entity-body">response entity body</a>. The text response
2003: entity body is the return value of the following algorithm:
1.205 avankest 2004:
2005: <ol>
2006: <li>
1.250 avankest 2007: <p>If the response entity body is null return the empty string and
2008: terminate these steps.</p>
2009:
2010: <li>
2011: <p>Let <var>charset</var> be the <a href="#final-charset">final
2012: charset</a>.
1.205 avankest 2013:
2014: <li>
1.250 avankest 2015: <p>Let <var>mime</var> be the <a href="#final-mime-type">final MIME
2016: type</a>.
1.205 avankest 2017:
2018: <li>
1.250 avankest 2019: <p>If <var>charset</var> is null and <var>mime</var> is null,
1.205 avankest 2020: <code>text/xml</code>, <code>application/xml</code> or ends in <code
1.250 avankest 2021: title="">+xml</code> use the rules set forth in the XML specifications
2022: to determine the character encoding. Let <var>charset</var> be the
2023: determined character encoding.
1.205 avankest 2024:
2025: <li>
1.250 avankest 2026: <p>If <var>charset</var> is null and <var>mime</var> is
2027: <code>text/html</code> follow the rules set forth in the HTML
2028: specification to determine the character encoding. Let
1.205 avankest 2029: <var>charset</var> be the determined character encoding. [<cite><a
2030: href="#ref-html5">HTML5</a></cite>]
2031:
2032: <li>
2033: <p>If <var>charset</var> is null then, for each of the rows in the
2034: following table, starting with the first one and going down, if the
2035: first bytes of <var>bytes</var> match the bytes given in the first
2036: column, then let <var>charset</var> be the encoding given in the cell in
2037: the second column of that row. If there is no match <var>charset</var>
2038: remains null.</p>
2039:
2040: <table>
2041: <thead>
2042: <tr>
2043: <th>Bytes in Hexadecimal
2044:
2045: <th>Description
2046:
1.239 avankest 2047: <tbody>
1.205 avankest 2048: <tr>
2049: <td>FE FF
2050:
2051: <td>UTF-16BE BOM
2052:
2053: <tr>
2054: <td>FF FE
2055:
2056: <td>UTF-16LE BOM
2057:
2058: <tr>
2059: <td>EF BB BF
2060:
1.239 avankest 2061: <td>UTF-8 BOM
1.205 avankest 2062: </table>
2063:
2064: <li>
2065: <p>If <var>charset</var> is null let <var>charset</var> be UTF-8.
2066:
2067: <li>
2068: <p>Return the result of decoding the response entity body using
2069: <var>charset</var>. Replace bytes or sequences of bytes that are not
1.250 avankest 2070: valid accordng to the <var>charset</var> with a single U+FFFD
1.205 avankest 2071: REPLACEMENT CHARACTER character.
2072: </ol>
2073:
2074: <p class=note>Authors are strongly encouraged to encode their resources
2075: using UTF-8.
2076:
2077: <hr>
2078:
1.250 avankest 2079: <p>The <dfn id=document-response-entity-body>document response entity
2080: body</dfn> is either a <code>Document</code> representing the <a
2081: href="#response-entity-body">response entity body</a> or null. The
2082: document response entity body is the return value of the following
2083: algorithm:
1.89 avankest 2084:
1.205 avankest 2085: <ol>
2086: <li>
2087: <p>If the <a href="#response-entity-body">response entity body</a> is
1.313 avankest 2088: null, return null and terminate these steps.
1.6 avankest 2089:
1.205 avankest 2090: <li>
1.250 avankest 2091: <p>If <a href="#final-mime-type">final MIME type</a> is not null,
1.300 avankest 2092: <code>text/xml</code>, <code>application/xml</code>, or does not end in
1.313 avankest 2093: <code title="">+xml</code>, return null and terminate these steps.
1.12 avankest 2094:
1.205 avankest 2095: <li>
1.268 avankest 2096: <p>Let <var>document</var> be a <a
2097: href="#cookie-free-document-object">cookie-free <code>Document</code>
2098: object</a> that represents the result of parsing the response entity
2099: body into a document tree following the rules from the XML
2100: specifications. If this fails (unsupported character encoding, namespace
1.313 avankest 2101: well-formedness error et cetera) return null and terminate these steps.
1.268 avankest 2102: [<cite><a href="#ref-xml">XML</a></cite>]</p>
1.6 avankest 2103:
1.205 avankest 2104: <p class=note>Scripts in the resulting document tree will not be
2105: executed, resources referenced will not be loaded and no associated XSLT
2106: will be applied.</p>
1.76 avankest 2107:
1.205 avankest 2108: <li>
1.250 avankest 2109: <p>Return <var>document</var>.
1.205 avankest 2110: </ol>
1.76 avankest 2111:
1.250 avankest 2112: <h4 id=the-responsetext-attribute><span class=secno>3.7.6. </span>The <code
1.205 avankest 2113: title="">responseText</code> attribute</h4>
1.12 avankest 2114:
1.281 avankest 2115: <dl class=domintro>
2116: <dt><var title="">client</var> . <a
2117: href="#dom-xmlhttprequest-responsetext"><code
2118: title=dom-XMLHttpRequest-responseText>responseText</code></a>
2119:
2120: <dd>
2121: <p>Returns the <a href="#text-response-entity-body">text response entity
1.309 avankest 2122: body</a>.</p>
1.281 avankest 2123: </dl>
2124:
2125: <p>The <dfn id=dom-xmlhttprequest-responsetext
2126: title=dom-XMLHttpRequest-responseText><code>responseText</code></dfn>
1.275 avankest 2127: attribute <em class=ct>must</em> return the result of running these steps:
1.6 avankest 2128:
1.205 avankest 2129: <ol>
2130: <li>
1.277 avankest 2131: <p>If the state is not <a href="#dom-xmlhttprequest-loading"
2132: title=dom-XMLHttpRequest-LOADING>LOADING</a> or <a
2133: href="#dom-xmlhttprequest-done" title=dom-XMLHttpRequest-DONE>DONE</a>
1.205 avankest 2134: return the empty string and terminate these steps.
1.12 avankest 2135:
1.205 avankest 2136: <li>
2137: <p>Return the <a href="#text-response-entity-body">text response entity
2138: body</a>.
2139: </ol>
1.2 avankest 2140:
1.250 avankest 2141: <h4 id=the-responsexml-attribute><span class=secno>3.7.7. </span>The <code
1.205 avankest 2142: title="">responseXML</code> attribute</h4>
1.2 avankest 2143:
1.281 avankest 2144: <dl class=domintro>
2145: <dt><var title="">client</var> . <a
2146: href="#dom-xmlhttprequest-responsexml"><code
2147: title=dom-XMLHttpRequest-responseXML>responseXML</code></a>
2148:
2149: <dd>
2150: <p>Returns the <a href="#document-response-entity-body">document response
1.309 avankest 2151: entity body</a>.</p>
1.281 avankest 2152: </dl>
2153:
2154: <p>The <dfn id=dom-xmlhttprequest-responsexml
2155: title=dom-XMLHttpRequest-responseXML><code>responseXML</code></dfn>
2156: attribute <em class=ct>must</em> return the result of running these steps:
1.2 avankest 2157:
1.205 avankest 2158: <ol>
2159: <li>
1.277 avankest 2160: <p>If the state is not <a href="#dom-xmlhttprequest-done"
2161: title=dom-XMLHttpRequest-DONE>DONE</a> return null and terminate these
2162: steps.
1.2 avankest 2163:
1.205 avankest 2164: <li>
1.250 avankest 2165: <p>Return the <a href="#document-response-entity-body">document response
2166: entity body</a>.
1.291 avankest 2167: </li>
2168: <!-- XXX same object -->
1.205 avankest 2169: </ol>
1.2 avankest 2170:
1.250 avankest 2171: <h2 id=exceptions><span class=secno>4. </span>Exceptions</h2>
1.33 avankest 2172:
1.139 avankest 2173: <p>Several algorithms in this specification may result in an exception
2174: being thrown. These exceptions are all part of the group
1.186 avankest 2175: <code>ExceptionCode</code> and use the <code>DOMException</code> object,
1.139 avankest 2176: which is defined in DOM Level 3 Core. In addition this specification
2177: extends the <code>ExceptionCode</code> group with several new constants as
1.146 avankest 2178: indicated below. [<cite><a href="#ref-dom3core">DOM3Core</a></cite>]
1.139 avankest 2179:
1.194 avankest 2180: <p class=note>Thus, exceptions used by this specification and not defined
2181: in this section are defined by DOM Level 3 Core.
2182:
1.34 avankest 2183: <pre
1.139 avankest 2184: class=idl>const unsigned short <a href="#security-err">SECURITY_ERR</a> = 18;
1.200 avankest 2185: const unsigned short <a href="#network-err">NETWORK_ERR</a> = 19;
2186: const unsigned short <a href="#abort-err">ABORT_ERR</a> = 20;</pre>
1.33 avankest 2187:
1.139 avankest 2188: <p>The <dfn id=security-err><code>SECURITY_ERR</code></dfn> exception is
2189: raised if an attempt is made to perform an operation or access some data
2190: in a way that would be a security risk or a violation of the user agent's
2191: security policy.</p>
2192: <!-- http://lists.w3.org/Archives/Public/public-webapi/2006May/0027.html -->
2193:
1.35 avankest 2194: <p>The <dfn id=network-err><code>NETWORK_ERR</code></dfn> exception is
1.139 avankest 2195: raised when a network error occurs in synchronous requests.
1.122 avankest 2196:
1.139 avankest 2197: <p>The <dfn id=abort-err><code>ABORT_ERR</code></dfn> exception is raised
1.122 avankest 2198: when the user aborts a request in synchronous requests.
2199:
1.242 avankest 2200: <p class=note>These exceptions will be folded into an update of DOM Level 3
2201: Core in due course, as they are appropriate for other API specifications
1.200 avankest 2202: as well.
2203:
1.250 avankest 2204: <h2 class=no-num id=references>References</h2>
1.2 avankest 2205:
1.178 avankest 2206: <p>Unless marked "Non-normative" these references are normative.
2207:
1.7 avankest 2208: <dl>
1.232 avankest 2209: <dt>[<dfn id=ref-cookies>COOKIES</dfn>]
1.205 avankest 2210:
1.273 avankest 2211: <dd><cite><a
2212: href="http://tools.ietf.org/html/draft-ietf-httpstate-cookie">HTTP State
2213: Management Mechanism</a></cite> (work in progress), A. Barth. IETF.
1.205 avankest 2214:
1.156 avankest 2215: <dt>[<dfn id=ref-dom2events>DOM2Events</dfn>]
2216:
2217: <dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Events/">Document
1.272 avankest 2218: Object Model (DOM) Level 2 Events Specification</a></cite>, T. Pixley.
2219: W3C.
1.156 avankest 2220:
1.146 avankest 2221: <dt>[<dfn id=ref-dom3core>DOM3Core</dfn>]
1.2 avankest 2222:
1.15 avankest 2223: <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object
2224: Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. Le
1.272 avankest 2225: Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne. W3C.
1.2 avankest 2226:
1.39 avankest 2227: <dt>[<dfn id=ref-ecmascript>ECMAScript</dfn>]
1.18 avankest 2228:
2229: <dd><cite><a
2230: href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript
1.272 avankest 2231: Language Specification</a></cite>. ECMA.
1.18 avankest 2232:
1.146 avankest 2233: <dt>[<dfn id=ref-html5>HTML5</dfn>]
1.143 avankest 2234:
1.252 avankest 2235: <dd><cite><a href="http://www.w3.org/html/wg/html5/">HTML5</a></cite>
1.272 avankest 2236: (work in progress), I. Hickson. W3C.
1.172 avankest 2237:
2238: <dd><cite><a
1.295 avankest 2239: href="http://www.whatwg.org/specs/web-apps/current-work/">HTML5</a></cite>
1.272 avankest 2240: (work in progress), I. Hickson. WHATWG.
1.18 avankest 2241:
1.199 avankest 2242: <dt>[<dfn id=ref-httpverbsec>HTTPVERBSEC</dfn>]
2243:
2244: <dd>(Non-normative) <cite><a
2245: href="http://www.kb.cert.org/vuls/id/867593">Multiple vendors' web
2246: servers enable HTTP TRACE method by default</a></cite>, US-CERT.
2247:
2248: <dd>(Non-normative) <cite><a
2249: href="http://www.kb.cert.org/vuls/id/288308">Microsoft Internet
2250: Information Server (IIS) vulnerable to cross-site scripting via HTTP
2251: TRACK method</a></cite>, US-CERT.
2252:
2253: <dd>(Non-normative) <cite><a
2254: href="http://www.kb.cert.org/vuls/id/150227">HTTP proxy default
2255: configurations allow arbitrary TCP connections</a></cite>, US-CERT.
2256:
1.250 avankest 2257: <dt>[<dfn id=ref-rfc2046>RFC2046</dfn>]
2258:
2259: <dd><cite><a href="http://ietf.org/rfc/rfc2046">Multipurpose Internet Mail
2260: Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N.
1.272 avankest 2261: Borenstein. IETF.
1.250 avankest 2262:
1.146 avankest 2263: <dt>[<dfn id=ref-rfc2119>RFC2119</dfn>]
1.15 avankest 2264:
1.118 avankest 2265: <dd><cite><a href="http://ietf.org/rfc/rfc2119">Key words for use in RFCs
1.272 avankest 2266: to Indicate Requirement Levels</a></cite>, S. Bradner. IETF.
1.15 avankest 2267:
1.250 avankest 2268: <dt>[<dfn id=rfc-rfc2616>RFC2616</dfn>]
1.15 avankest 2269:
2270: <dd><cite><a href="http://ietf.org/rfc/rfc2616">Hypertext Transfer
2271: Protocol -- HTTP/1.1</a></cite>, R. Fielding, J. Gettys, J. Mogul, H.
1.272 avankest 2272: Frystyk, L. Masinter, P. Leach, T. Berners-Lee. IETF.
1.15 avankest 2273:
1.39 avankest 2274: <dt>[<dfn id=ref-rfc2617>RFC2617</dfn>]
1.15 avankest 2275:
2276: <dd><cite><a href="http://ietf.org/rfc/rfc2617">HTTP Authentication: Basic
1.93 avankest 2277: and Digest Access Authentication</a></cite>, P. Hallam-Baker, J.
1.272 avankest 2278: Hostetler, S. Lawrence, P. Leach, A. Luotonen, L. Stewart. IETF.
1.2 avankest 2279:
1.39 avankest 2280: <dt>[<dfn id=ref-rfc3986>RFC3986</dfn>]
1.2 avankest 2281:
1.15 avankest 2282: <dd><cite><a href="http://ietf.org/rfc/rfc3986">Uniform Resource
2283: Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding,
1.272 avankest 2284: L. Masinter. IETF.
1.188 avankest 2285:
1.250 avankest 2286: <dt>[<dfn id=ref-rfc3987>RFC3987</dfn>]
2287:
2288: <dd><cite><a href="http://ietf.org/rfc/rfc3987">Internationalized Resource
1.272 avankest 2289: Identifiers (IRIs)</a></cite>, M. Duerst, M. Suignard. IETF.
1.250 avankest 2290:
1.205 avankest 2291: <dt>[<dfn id=ref-webidl>WebIDL</dfn>]
1.182 avankest 2292:
1.201 avankest 2293: <dd><cite><a href="http://dev.w3.org/2006/webapi/WebIDL/">Web
1.272 avankest 2294: IDL</a></cite> (work in progress), C. McCormack. W3C.</dd>
1.252 avankest 2295: <!-- XXX add Sam -->
1.182 avankest 2296:
1.43 avankest 2297: <dt>[<dfn id=ref-xml>XML</dfn>]
2298:
2299: <dd><cite><a href="http://www.w3.org/TR/xml/">Extensible Markup Language
1.272 avankest 2300: (XML) 1.0</a></cite>, T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler,
2301: F. Yergeau. W3C.
1.43 avankest 2302:
1.272 avankest 2303: <dd><cite><a href="http://www.w3.org/TR/xml-names/">Namespaces in
2304: XML</a></cite>, T. Bray, D. Hollander, A. Layman, R. Tobin, H. S.
2305: Thompson. W3C.
1.2 avankest 2306: </dl>
2307:
1.131 avankest 2308: <h2 class=no-num id=acknowledgments>Acknowledgments</h2>
1.2 avankest 2309:
1.164 avankest 2310: <p>The editor would like to thank Addison Phillips, Ahmed Kamel, Alex
2311: Hopmann, Alex Vincent, Alexey Proskuryakov, Asbjørn Ulsberg, Boris
2312: Zbarsky, Björn Höhrmann, Cameron McCormack, Christophe Jolif,
1.250 avankest 2313: Charles McCathieNevile, Dan Winship, David Andersson, David
2314: Håsäther, David Levin, Dean Jackson, Denis Sureau, Doug
2315: Schepers, Douglas Livingstone, Elliotte Harold, Eric Lawrence, Erik
2316: Dahlström, Geoffrey Sneddon, Gideon Cohn, Gorm Haug Eriksen,
2317: Håkon Wium Lie, Hallvord R. M. Steen, Huub Schaeks, Ian Davis, Ian
2318: Hickson, Ivan Herman, Jeff Walden, Jens Lindström, Jim Deegan, Jim
2319: Ley, Joe Farro, Jonas Sicking, Julian Reschke, Karl Dubost, Lachlan Hunt,
2320: Maciej Stachowiak, Magnus Kristiansen, Marc Hadley, Marcos Caceres, Mark
1.272 avankest 2321: Baker, Mark Birbeck, Mark Nottingham, Mark S. Miller, Martin Hassman,
2322: Mohamed Zergaoui, Olli Pettay, Pawel Glowacki, Peter Michaux, Philip
1.314 avankest 2323: Taylor, Robin Berjon, Rune Halvorsen, Ruud Steltenpool, Sergiu Dumitriu,
2324: Simon Pieters, Stewart Brodie, Sunava Dutta, Thomas Roessler, Tom
2325: Magliery, and Zhenbin Xu for their contributions to this specification.
1.2 avankest 2326:
2327: <p>Special thanks to the Microsoft employees who first implemented the
1.144 avankest 2328: <code title="">XMLHttpRequest</code> interface, which was first widely
2329: deployed by the Windows Internet Explorer browser.
1.2 avankest 2330:
1.56 avankest 2331: <p>Special thanks also to the WHATWG for drafting an initial version of
1.131 avankest 2332: this specification in their Web Applications 1.0 document (now renamed to
1.252 avankest 2333: HTML5). [<cite><a href="#ref-html5">HTML5</a></cite>]
1.2 avankest 2334:
2335: <p>Thanks also to all those who have helped to improve this specification
2336: by sending suggestions and corrections. (Please, keep bugging us with your
2337: issues!)
Webmaster