1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00
This commit is contained in:
psyc://psyced.org/~lynX 2011-08-28 15:42:32 +02:00
parent ae4599ac1d
commit 6ff66c19c3

View file

@ -22,9 +22,8 @@ quit() {
// gets called from async apps // gets called from async apps
done() { quit(); } done() { quit(); }
// this could be improved to implement HTTP/1.1
parse_nothing(input) { parse_nothing(input) {
P2(("=== HTTP ignored %O from %s\n", input, query_ip_name(ME))) P2(("=== HTTP ignored %O from %O\n", input, query_ip_name(ME)))
next_input_to(#'parse_nothing); next_input_to(#'parse_nothing);
} }
parse_body_length(input) { parse_body_length(input) {
@ -74,25 +73,26 @@ parse_wait(null) { // waiting to send my error message here
} }
parse_header(input) { parse_header(input) {
if (input != "") { string name, contents;
string name, contents;
// %.0t = catch zero to endless whitespace characters if (input == "") return process_header();
sscanf(input, "%s:%1.0t%s", name, contents); // %.0t = catch zero to endless whitespace characters
if (contents) { sscanf(input, "%s:%1.0t%s", name, contents);
P3(("headers[%O] = %O\n",name,contents)) if (contents) {
headers[lower_case(name)] = contents; P3(("headers[%O] = %O\n",name,contents))
} else { headers[lower_case(name)] = contents;
// http_error(prot, R_BADREQUEST, } else {
// "invalid header '"+ input +"'"); // http_error(prot, R_BADREQUEST,
// QUIT; return 1; // "invalid header '"+ input +"'");
P1(("Invalid HTTP header %O from %s\n", // QUIT; return 1;
input, query_ip_name(ME))) P1(("Invalid HTTP header %O from %O\n",
input, query_ip_name(ME)))
}
next_input_to(#'parse_header);
return;
} }
next_input_to(#'parse_header);
}
process_header() {
#if 0 #if 0
if (method == "post" && (length = to_int(headers["content-length"])) && if (method == "post" && (length = to_int(headers["content-length"])) &&
headers["content-type"] == "application/x-www-form-urlencoded") headers["content-type"] == "application/x-www-form-urlencoded")
@ -113,7 +113,7 @@ parse_header(input) {
} }
parse_request(input) { parse_request(input) {
P2(("=== HTTP got: %O from %s\n", input, query_ip_name(ME))) P2(("=== HTTP got: %O from %O\n", input, query_ip_name(ME)))
// reset state. in case we support HTTP/1.1. do we? // reset state. in case we support HTTP/1.1. do we?
method = item = url = prot = qs = 0; method = item = url = prot = qs = 0;