html_post-json-test-page.html (1371B)
1 <!-- Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ --> 3 <!doctype html> 4 5 <html> 6 <head> 7 <meta charset="utf-8"/> 8 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> 9 <meta http-equiv="Pragma" content="no-cache" /> 10 <meta http-equiv="Expires" content="0" /> 11 <title>Network Monitor test page</title> 12 </head> 13 14 <body> 15 <p>POST raw test</p> 16 17 <script type="text/javascript"> 18 /* exported performRequests, performLargePostDataRequest */ 19 "use strict"; 20 21 function post(address, message) { 22 return new Promise(resolve => { 23 const xhr = new XMLHttpRequest(); 24 xhr.open("POST", address, true); 25 xhr.setRequestHeader("Content-Type", "application/json"); 26 27 xhr.onreadystatechange = function() { 28 if (this.readyState == this.DONE) { 29 resolve(); 30 } 31 }; 32 xhr.send(message); 33 }); 34 } 35 36 async function performRequests() { 37 await post("sjs_simple-test-server.sjs", JSON.stringify({a: 1})); 38 } 39 40 async function performLargePostDataRequest() { 41 const limit = 1048576; 42 const data = "x".repeat(2 * limit); 43 await post("sjs_simple-test-server.sjs", JSON.stringify(data)); 44 } 45 </script> 46 </body> 47 48 </html>