Annotation of 2006/webapi/XMLHttpRequest/Overview.html, revision 1.255

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

Webmaster