tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

html_post-raw-with-headers-test-page.html (1737B)


      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 with headers test</p>
     16 
     17    <script type="text/javascript">
     18      /* exported performRequests */
     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 
     26          xhr.onreadystatechange = function() {
     27            if (this.readyState == this.DONE) {
     28              resolve();
     29            }
     30          };
     31          xhr.send(message);
     32        });
     33      }
     34 
     35      async function performRequests() {
     36        const rawData = [
     37          // Only one header
     38          [
     39            "content-type: application/x-www-form-urlencoded\r",
     40            "\r",
     41            "\r",
     42            "foo=bar&baz=123",
     43          ],
     44          // No form body content
     45          [
     46            "content-type: application/x-www-form-urlencoded\r",
     47            "\r",
     48            "\r",
     49          ],
     50          // Multiple headers
     51          [
     52            "content-type: application/x-www-form-urlencoded\r",
     53            "custom-header: hello world!\r",
     54            "\r",
     55            "\r",
     56            "foo=bar&baz=123",
     57          ],
     58        ];
     59 
     60        for (const data of rawData) {
     61          await post("sjs_simple-test-server.sjs", data.join("\n"));
     62        }
     63      }
     64    </script>
     65  </body>
     66 
     67 </html>