2 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 <meta http-equiv=
"content-type" content=
"text/html; charset=UTF-8" />
5 <title>HTTP method test
</title>
6 <style type=
"text/css" media=
"screen">
7 body {background:#eee; margin:
0%; padding:
0%; padding-top:
0%; padding-left:
1%}
8 .cform {margin:
0%; padding:
0%; padding-top:
0%; padding-left:
2%;}
9 h3 {margin:
0%; padding:
0%; padding-top:
0%; padding-left:
0%;}
10 td {vertical-align:top; text-align:left;}
12 <script type=
"text/javascript"><![CDATA[
14 function getParams() {
16 var kvPairs = location.search.slice(
1).split('&');
20 kvPair = kvPair.split('=');
21 result[kvPair[
0]] = kvPair[
1] || '';
29 document.getElementById(
"body_none").checked = true;
33 var params = getParams();
34 var method = params[
"method"];
38 var path = params[
"path"];
43 var elem = document.getElementById('h1');
44 elem.innerHTML =
"HTTP method test page";
46 document.getElementById(
"proto_http").checked = (window.location.protocol !=
"https:");
47 document.getElementById(
"proto_https").checked = (window.location.protocol ==
"https:");
48 document.getElementById(
"server").value = location.host;
49 document.getElementById(
"resource").value = path;
51 setRadioValue(
"method", method);
55 function setRadioValue(elmname, value) {
56 var elms = document.getElementsByName(elmname);
57 var len = elms.length;
60 for (var i=
0; i
<len; i++) {
61 elms[i].checked = (elms[i].value == value);
62 ret |= elms[i].checked;
67 function getRadioValue(elmname) {
69 var elms = document.getElementsByName(elmname);
70 var len = elms.length;
73 for (var i=
0; i
<len; i++) {
74 if (elms[i].checked) {
82 var proto = getRadioValue(
"protocol");
83 var host = document.getElementById(
"server").value;
84 var res = document.getElementById(
"resource").value;
85 var addr = proto +
"://" + host +
"/" + res;
86 var meth = getRadioValue(
"method");
87 var body = getRadioValue(
"body");
89 xmlhttp = new XMLHttpRequest();
91 alert(
"XMLHttpRequest not available");
92 window.history.back();
95 xmlhttp.open(meth,addr,true);
101 var body_bytes = document.getElementById(
"body_bytes").value;
102 body_bytes = parseInt(Number(body_bytes) ||
0) ||
0;
104 for (var i=
0; i
<body_bytes; i++) {
105 var ascii = Math.floor((Math.random() *
94) +
32);
106 body = body + String.fromCharCode(ascii);
109 xmlhttp.setRequestHeader(
"Content-Length", body.length);
112 xmlhttp.onreadystatechange = function()
118 blen =
"\nWith " + body.length +
" bytes body data";
121 if (xmlhttp.readyState ==
4)
123 alert(lmeth +
" " + laddr + blen +
"\n\nResponse: " + xmlhttp.status +
"\n\n" + xmlhttp.responseText);
134 <body onload=
"load()">
136 <h1 id='h1'
>Fatal error: Javascript not available!
</h1>
138 <h2>Test parameters
</h2>
142 <input id=
"proto_http" type=
"radio" name=
"protocol" value=
"http" /> http
<br />
143 <input id=
"proto_https" type=
"radio" name=
"protocol" value=
"https" /> https
146 <input id=
"server" type=
"text" name=
"server" value=
"" />
149 <input id=
"resource" type=
"text" name=
"resource" value=
"" />
152 <!-- http://www.restpatterns.org/HTTP_Methods -->
153 <!-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html -->
154 <table style=
"border-spacing:15px 0px;">
156 <td><a href=
"http://tools.ietf.org/html/rfc7231#section-4.2.1">Save Methods
</a></td>
157 <td>"Unsave" <a href=
"http://tools.ietf.org/html/rfc7231#section-4.2.2">Idempotent Methods
</a></td>
158 <td>Non-Idempotent Methods
</td>
163 <input id=
"method_opt" type=
"radio" name=
"method" value=
"OPTIONS" onclick=
"noBody()" /> OPTIONS
<br />
164 <input id=
"method_get" type=
"radio" name=
"method" value=
"GET" onclick=
"noBody()" /> GET
<br />
165 <input id=
"method_hea" type=
"radio" name=
"method" value=
"HEAD" onclick=
"noBody()" /> HEAD
<br />
166 <input id=
"method_tra" type=
"radio" name=
"method" value=
"TRACE" /> TRACE
<br />
167 <input id=
"method_pro" type=
"radio" name=
"method" value=
"PROPFIND" /> PROPFIND
<br />
170 <input id=
"method_put" type=
"radio" name=
"method" value=
"PUT" /> PUT
<br />
171 <input id=
"method_del" type=
"radio" name=
"method" value=
"DELETE" /> DELETE
<br />
172 <input id=
"method_cop" type=
"radio" name=
"method" value=
"COPY" /> COPY
<br />
173 <input id=
"method_cop" type=
"radio" name=
"method" value=
"MOVE" /> MOVE
<br />
174 <input id=
"method_ppa" type=
"radio" name=
"method" value=
"PROPPATCH" /> PROPPATCH
<br />
175 <input id=
"method_unl" type=
"radio" name=
"method" value=
"UNLOCK" /> UNLOCK
<br />
178 <input id=
"method_pos" type=
"radio" name=
"method" value=
"POST" /> POST
<br />
179 <input id=
"method_pat" type=
"radio" name=
"method" value=
"PATCH" /> PATCH
<br />
180 <input id=
"method_mkc" type=
"radio" name=
"method" value=
"MKCOL" /> MKCOL
<br />
181 <input id=
"method_loc" type=
"radio" name=
"method" value=
"LOCK" /> LOCK
<br />
184 <input id=
"method_con" type=
"radio" name=
"method" value=
"CONNECT" /> CONNECT
<br />
185 <input id=
"method_userdef" type=
"radio" name=
"method" value=
"INVALID" /> <input id=
"method_name" type=
"text" name=
"method_name" value=
"INVALID" oninput=
"var elem = document.getElementById('method_userdef'); elem.checked = true; elem.value=value" /> <br />
191 <input id=
"body_none" type=
"radio" name=
"body" value=
"*" /> No body data
<br />
192 <input id=
"body_10" type=
"radio" name=
"body" value=
"1234567890" /> 10 Bytes (
"1234567890")
<br />
193 <input id=
"body_rnd" type=
"radio" name=
"body" value=
"**" /> <input id=
"body_bytes" type=
"number" name=
"body_bytes" value=
"100" min=
"0" step=
"0" max=
"999999999" oninput=
"document.getElementById('body_rnd').checked = true" /> Bytes random data
<br />
196 <input id=
"send" type=
"button" onclick=
"sendreq()" value=
"Send request" />