This commit is contained in:
psyc://psyced.org/~lynX 2011-08-28 15:42:32 +02:00
parent ae4599ac1d
commit 6ff66c19c3
1 changed files with 19 additions and 19 deletions

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,9 +73,9 @@ parse_wait(null) { // waiting to send my error message here
} }
parse_header(input) { parse_header(input) {
if (input != "") {
string name, contents; string name, contents;
if (input == "") return process_header();
// %.0t = catch zero to endless whitespace characters // %.0t = catch zero to endless whitespace characters
sscanf(input, "%s:%1.0t%s", name, contents); sscanf(input, "%s:%1.0t%s", name, contents);
if (contents) { if (contents) {
@ -86,13 +85,14 @@ parse_header(input) {
// http_error(prot, R_BADREQUEST, // http_error(prot, R_BADREQUEST,
// "invalid header '"+ input +"'"); // "invalid header '"+ input +"'");
// QUIT; return 1; // QUIT; return 1;
P1(("Invalid HTTP header %O from %s\n", P1(("Invalid HTTP header %O from %O\n",
input, query_ip_name(ME))) input, query_ip_name(ME)))
} }
next_input_to(#'parse_header); next_input_to(#'parse_header);
return;
} }
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;