--------------------- PatchSet 2888 Date: 2001/08/28 16:21:14 Author: adri Branch: newhttp Tag: (none) Log: * actually advance the str position variable in getnext() * parser fixes - more useful debugging, return useful values depending on how sucessful or not the parse attempt was Members: src/modules/new_http_client/http_request.c:1.1.2.6->1.1.2.7 Index: squid/src/modules/new_http_client/http_request.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/modules/new_http_client/Attic/http_request.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid/src/modules/new_http_client/http_request.c 24 Aug 2001 23:45:11 -0000 1.1.2.6 +++ squid/src/modules/new_http_client/http_request.c 28 Aug 2001 16:21:14 -0000 1.1.2.7 @@ -80,6 +80,7 @@ if (pos->nodeofs < pos->node->len) { /* Yes, advance to the next char, return */ pos->nodeofs++; + pos->strofs++; return 1; } @@ -88,6 +89,7 @@ /* Yes, advance to the next node */ pos->node = pos->node->node.next->data; pos->nodeofs = 0; + pos->strofs++; /* Assert there's data _in_ this node */ assert(pos->node->len != 0); /* Return */ @@ -170,12 +172,6 @@ ch = stmem_ref_pos_getchar(&stpos); debug(1, 1)("offset %d, char %c\n", stpos.strofs, ch); - /* If we have a CR or an LF, its the end .. */ - if (ch == '\r' || ch == '\n') { - debug(1, 1) ("Got a CRLF, breaking..\n"); - gotcrlf = 1; - break; - } /* Now, do the per-state magic */ debug(1, 1) ("Mode: %d\n", mode); @@ -232,10 +228,10 @@ break; case HTTP_VERSION: /* - * If we've hit a whitespace char, upgrade - * the state + * If we've hit a whitespace char or CRLF, + * upgrade the state */ - if (ch == ' ' || ch == '\t') { + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') { version_end = stpos; mode = HTTP_CRLF; } @@ -248,6 +244,13 @@ default: fatal("Unknown HTTP parse state!"); } + + /* If we have a CR or an LF, its the end .. */ + if (ch == '\r' || ch == '\n') { + debug(1, 1) ("Got a CRLF, breaking..\n"); + gotcrlf = 1; + break; + } /* Finally, advance characters */ if (oldmode == mode && stmem_ref_pos_getnext(&stpos) == 0) { @@ -259,23 +262,31 @@ break; } } + + stmem_ref_pos_print(&method_start); + stmem_ref_pos_print(&method_end); + stmem_ref_pos_print(&url_start); + stmem_ref_pos_print(&url_end); + stmem_ref_pos_print(&version_start); + stmem_ref_pos_print(&version_end); /* Now, check the current mode - if we have a CRLF but we're not * at the CRLF state, we hit a parse error */ + if (gotcrlf == 1 && mode != HTTP_CRLF) { + debug(1, 1) ("Parsing: Have a CRLF but not at the state, so ERROR\n"); + return HTTP_REQUEST_ERROR; + } /* If we're not at the CRLF state but we get here, we've parsed * a partial buffer, so return that */ + if (!gotcrlf) { + debug(1, 1) ("Parsing: Don't have a CRLF yet, so PARTIAL\n"); + return HTTP_REQUEST_PARTIAL; + } /* If we're at the CRLF *and* we're at the CRLF state, we've got * a potentially valid buffer */ - - - stmem_ref_pos_print(&method_start); - stmem_ref_pos_print(&method_end); - stmem_ref_pos_print(&url_start); - stmem_ref_pos_print(&url_end); - stmem_ref_pos_print(&version_start); - stmem_ref_pos_print(&version_end); + debug(1, 1) ("Parsing: Doing ok..\n"); /* At this stage we've got a request but we don't know if its valid */