File: xhr_headers.html

package info (click to toggle)
qutebrowser 3.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,432 kB
  • sloc: python: 72,411; javascript: 31,862; sh: 874; xml: 149; makefile: 52
file content (30 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>XHR headers test</title>
        <script>
            function xhr_headers() {
                const xhr = new XMLHttpRequest();
                xhr.open("GET", "/headers");
                xhr.setRequestHeader("X-Qute-Test", "from XHR");
                xhr.setRequestHeader("Accept-Language", "from XHR");

                const elem = document.getElementById("output");
                xhr.addEventListener("load", function(event) {
                    if (xhr.status == 200) {
                        elem.textContent = xhr.responseText;
                        console.log("Got headers via XHR")
                    } else {
                        elem.textContent = xhr.statusText;
                        console.warn(xhr.statusText, xhr.responseText);
                    }
                });
                xhr.send();
            }
        </script>
    </head>
    <body onload="xhr_headers()">
        <pre id="output">unknown</pre>
    </body>
</html>