mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-10 14:23:00 +03:00
Improve HTTP method test
Format whitespaces, add random post data
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
<title>HTTP method test</title>
|
<title>HTTP method test</title>
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
@@ -51,7 +52,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setRadioValue(elmname, value) {
|
function setRadioValue(elmname, value) {
|
||||||
|
|
||||||
var elms = document.getElementsByName(elmname);
|
var elms = document.getElementsByName(elmname);
|
||||||
var len = elms.length;
|
var len = elms.length;
|
||||||
var ret = false;
|
var ret = false;
|
||||||
@@ -88,24 +88,33 @@
|
|||||||
xmlhttp = new XMLHttpRequest();
|
xmlhttp = new XMLHttpRequest();
|
||||||
if (!xmlhttp) {
|
if (!xmlhttp) {
|
||||||
alert("XMLHttpRequest not available");
|
alert("XMLHttpRequest not available");
|
||||||
window.history.back()
|
window.history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlhttp.open(meth,addr,true);
|
xmlhttp.open(meth,addr,true);
|
||||||
|
|
||||||
if (body != '*') {
|
if (body == '*') {
|
||||||
xmlhttp.setRequestHeader("Content-Length", body.length);
|
|
||||||
} else {
|
|
||||||
body = null;
|
body = null;
|
||||||
|
} else {
|
||||||
|
if (body == '**') {
|
||||||
|
var body_bytes = document.getElementById("body_bytes").value;
|
||||||
|
body_bytes = parseInt(Number(body_bytes) || 0) || 0;
|
||||||
|
body = "";
|
||||||
|
for (var i=0; i<body_bytes; i++) {
|
||||||
|
var ascii = Math.floor((Math.random() * 94) + 32);
|
||||||
|
body = body + String.fromCharCode(ascii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.setRequestHeader("Content-Length", body.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlhttp.onreadystatechange = function()
|
xmlhttp.onreadystatechange = function()
|
||||||
{
|
{
|
||||||
var laddr = addr
|
var laddr = addr;
|
||||||
var lmeth = meth
|
var lmeth = meth;
|
||||||
var blen = ""
|
var blen = "";
|
||||||
if (body) {
|
if (body) {
|
||||||
blen = "\nWith " + body.length + " bytes body data"
|
blen = "\nWith " + body.length + " bytes body data";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmlhttp.readyState == 4)
|
if (xmlhttp.readyState == 4)
|
||||||
@@ -120,23 +129,19 @@
|
|||||||
|
|
||||||
]]></script>
|
]]></script>
|
||||||
|
|
||||||
</head><body onload="load()">
|
</head>
|
||||||
|
<body onload="load()">
|
||||||
|
|
||||||
<h1 id='h1'>Fatal error: Javascript not available!</h1>
|
<h1 id='h1'>Fatal error: Javascript not available!</h1>
|
||||||
<h2>Usage</h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
TODO: Description how to use this page.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h2>Test parameters</h2>
|
<h2>Test parameters</h2>
|
||||||
<form lass="cform">
|
<form lass="cform">
|
||||||
|
|
||||||
<h3>Protocol</h3>
|
<h3>Protocol</h3>
|
||||||
<input id="proto_http" type="radio" name="protocol" value="http" />http <br />
|
<input id="proto_http" type="radio" name="protocol" value="http" /> http <br />
|
||||||
<input id="proto_https" type="radio" name="protocol" value="https" />https
|
<input id="proto_https" type="radio" name="protocol" value="https" /> https
|
||||||
|
|
||||||
<h3>Server</h3>
|
<h3>Server/Host</h3>
|
||||||
<input id="server" type="text" name="server" value="" />
|
<input id="server" type="text" name="server" value="" />
|
||||||
|
|
||||||
<h3>Resource</h3>
|
<h3>Resource</h3>
|
||||||
@@ -144,21 +149,22 @@ TODO: Description how to use this page.
|
|||||||
|
|
||||||
<h3>Method</h3>
|
<h3>Method</h3>
|
||||||
<!-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html -->
|
<!-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html -->
|
||||||
<input id="method_opt" type="radio" name="method" value="OPTIONS" />OPTIONS <br />
|
<input id="method_opt" type="radio" name="method" value="OPTIONS" onclick="noBody()" /> OPTIONS <br />
|
||||||
<input id="method_get" type="radio" name="method" value="GET" />GET <br />
|
<input id="method_get" type="radio" name="method" value="GET" onclick="noBody()" /> GET <br />
|
||||||
<input id="method_hea" type="radio" name="method" value="HEAD" />HEAD <br />
|
<input id="method_hea" type="radio" name="method" value="HEAD" onclick="noBody()" /> HEAD <br />
|
||||||
<input id="method_pos" type="radio" name="method" value="POST" />POST <br />
|
<input id="method_pos" type="radio" name="method" value="POST" /> POST <br />
|
||||||
<input id="method_put" type="radio" name="method" value="PUT" />PUT <br />
|
<input id="method_put" type="radio" name="method" value="PUT" /> PUT <br />
|
||||||
<input id="method_del" type="radio" name="method" value="DELETE" />DELETE <br />
|
<input id="method_del" type="radio" name="method" value="DELETE" /> DELETE <br />
|
||||||
<input id="method_tra" type="radio" name="method" value="TRACE" />TRACE <br />
|
<input id="method_tra" type="radio" name="method" value="TRACE" /> TRACE <br />
|
||||||
<input id="method_con" type="radio" name="method" value="CONNECT" />CONNECT <br />
|
<input id="method_con" type="radio" name="method" value="CONNECT" /> CONNECT <br />
|
||||||
<input id="method_mkc" type="radio" name="method" value="MKCOL" />MKCOL <br />
|
<input id="method_mkc" type="radio" name="method" value="MKCOL" /> MKCOL <br />
|
||||||
<input id="method_pro" type="radio" name="method" value="PROPFIND" />PROPFIND <br />
|
<input id="method_pro" type="radio" name="method" value="PROPFIND" /> PROPFIND <br />
|
||||||
<input id="method_inv" type="radio" name="method" value="INVALID" />*INVALID*
|
<input id="method_inv" type="radio" name="method" value="INVALID" /> *INVALID*
|
||||||
|
|
||||||
<h3>Body data</h3>
|
<h3>Body data</h3>
|
||||||
<input id="body_none" type="radio" name="body" value="*" />0 Bytes <br />
|
<input id="body_none" type="radio" name="body" value="*" /> No body data <br />
|
||||||
<input id="body_10" type="radio" name="body" value="1234567890" />10 Bytes ("1234567890") <br />
|
<input id="body_10" type="radio" name="body" value="1234567890" /> 10 Bytes ("1234567890") <br />
|
||||||
|
<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 />
|
||||||
|
|
||||||
<h3>Submit</h3>
|
<h3>Submit</h3>
|
||||||
<input id="send" type="button" onclick="sendreq()" value="Send request" />
|
<input id="send" type="button" onclick="sendreq()" value="Send request" />
|
||||||
|
Reference in New Issue
Block a user