mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-07 16:02:55 +03:00
HTTP POST requests to static files must return 405
Fix for a bug recently introduced in a redesign of the request handling. Fix for a request method test page.
This commit is contained in:
@@ -6320,8 +6320,8 @@ static void handle_request(struct mg_connection *conn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* 13.3. everything but GET and HEAD (e.g. POST) */
|
/* 13.3. everything but GET and HEAD (e.g. POST) */
|
||||||
if (!strcmp(ri->request_method, "GET") &&
|
if (0!=strcmp(ri->request_method, "GET") &&
|
||||||
!strcmp(ri->request_method, "HEAD")) {
|
0!=strcmp(ri->request_method, "HEAD")) {
|
||||||
send_http_error(conn, 405, NULL,
|
send_http_error(conn, 405, NULL,
|
||||||
"%s method not allowed", conn->request_info.request_method);
|
"%s method not allowed", conn->request_info.request_method);
|
||||||
return;
|
return;
|
||||||
|
@@ -25,10 +25,14 @@
|
|||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
var params = getParams();
|
var params = getParams();
|
||||||
method = params["method"];
|
var method = params["method"];
|
||||||
if (!method) {
|
if (!method) {
|
||||||
method = "GET";
|
method = "GET";
|
||||||
}
|
}
|
||||||
|
var path = params["path"];
|
||||||
|
if (!path) {
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
|
||||||
var elem = document.getElementById('h1');
|
var elem = document.getElementById('h1');
|
||||||
elem.innerHTML = "HTTP method test page";
|
elem.innerHTML = "HTTP method test page";
|
||||||
@@ -36,7 +40,7 @@
|
|||||||
document.getElementById("proto_http").checked = (window.location.protocol != "https:");
|
document.getElementById("proto_http").checked = (window.location.protocol != "https:");
|
||||||
document.getElementById("proto_https").checked = (window.location.protocol == "https:");
|
document.getElementById("proto_https").checked = (window.location.protocol == "https:");
|
||||||
document.getElementById("server").value = location.host;
|
document.getElementById("server").value = location.host;
|
||||||
document.getElementById("resource").value = "path";
|
document.getElementById("resource").value = path;
|
||||||
|
|
||||||
document.getElementById("method_get").checked = true;
|
document.getElementById("method_get").checked = true;
|
||||||
document.getElementById("body_none").checked = true;
|
document.getElementById("body_none").checked = true;
|
||||||
@@ -82,7 +86,10 @@
|
|||||||
{
|
{
|
||||||
var laddr = addr
|
var laddr = addr
|
||||||
var lmeth = meth
|
var lmeth = meth
|
||||||
var blen = "\nWith " + body.length + " bytes body data"
|
var blen = ""
|
||||||
|
if (body) {
|
||||||
|
blen = "\nWith " + body.length + " bytes body data"
|
||||||
|
}
|
||||||
|
|
||||||
if (xmlhttp.readyState == 4)
|
if (xmlhttp.readyState == 4)
|
||||||
{
|
{
|
||||||
@@ -133,8 +140,8 @@ TODO: Description how to use this page.
|
|||||||
<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="*" />*none* <br />
|
<input id="body_none" type="radio" name="body" value="*" />0 Bytes <br />
|
||||||
<input id="body_10" type="radio" name="body" value="1234567890" />1234567890 <br />
|
<input id="body_10" type="radio" name="body" value="1234567890" />10 Bytes ("1234567890") <br />
|
||||||
|
|
||||||
|
|
||||||
<h3>Submit</h3>
|
<h3>Submit</h3>
|
||||||
|
Reference in New Issue
Block a user