send-conditional.htm (1341B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: send() - conditional requests</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::code[contains(text(),'Modified')]/.." /> 8 </head> 9 <body> 10 <div id="log"></div> 11 <script> 12 function request(type) { 13 test(function() { 14 var client = new XMLHttpRequest, 15 identifier = type == "tag" ? Math.random() : new Date().toGMTString(), 16 url = "resources/conditional.py?" + type + "=" + identifier 17 client.open("GET", url, false) 18 client.send(null) 19 assert_equals(client.status, 200) 20 assert_equals(client.statusText, "OK") 21 assert_equals(client.responseText, "MAYBE NOT") 22 client.open("GET", url, false) 23 client.setRequestHeader(type == "tag" ? "If-None-Match" : "If-Modified-Since", identifier) 24 client.send(null) 25 assert_equals(client.status, 304) 26 assert_equals(client.statusText, "SUPERCOOL") 27 assert_equals(client.responseText, "") 28 }, document.title + " (" + type + ")") 29 } 30 request("tag") 31 request("date") 32 </script> 33 </body> 34 </html>