--------------------- PatchSet 5035 Date: 2002/09/18 12:38:21 Author: rbcollins Branch: fixrange Tag: (none) Log: extract methods from httpParseRequestLine Members: src/client_side.c:1.72.2.27->1.72.2.28 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.27 retrieving revision 1.72.2.28 diff -u -r1.72.2.27 -r1.72.2.28 --- squid/src/client_side.c 18 Sep 2002 12:28:31 -0000 1.72.2.27 +++ squid/src/client_side.c 18 Sep 2002 12:38:21 -0000 1.72.2.28 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.27 2002/09/18 12:28:31 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.28 2002/09/18 12:38:21 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -153,6 +153,13 @@ static void clientSocketContextPushDeferredIfNeeded(clientSocketContext *deferredRequest, ConnStateData *conn); static void clientUpdateSocketStats (log_type logType, size_t size); +static clientSocketContext * clientCheckRequestLineIsParseable(char *inbuf, size_t req_sz, ConnStateData *conn); +static clientSocketContext * clientParseRequestMethod(char *inbuf, method_t * method_p, ConnStateData * conn); +static char * skipLeadingSpace(char *aString); +static char *findTrailingHTTPVersion(char *uriAndHTTPVersion); +static void trimTrailingSpaces(char *aString, size_t len); +static clientSocketContext * parseURIandHTTPVersion(char **url_p, http_version_t * http_ver_p, ConnStateData * conn); + clientStreamNode * getTail (clientSocketContext *context) { @@ -876,47 +883,53 @@ *(endPointer--) = '\0'; } -/* Utility function to perform part of request parsing */ -static clientSocketContext * -clientParseHttpRequestLine(char *inbuf, size_t req_sz, ConnStateData * conn, - method_t * method_p, char **url_p, http_version_t * http_ver_p) +clientSocketContext * +parseURIandHTTPVersion(char **url_p, http_version_t * http_ver_p, + ConnStateData * conn) { - char *url = NULL; - char *token = NULL; - clientSocketContext *result = NULL; - if ((result = clientCheckRequestLineIsParseable (inbuf, req_sz, conn)) - || (result = clientParseRequestMethod(inbuf, method_p, conn))) - return result; - + char *url; + char *token; /* look for URL+HTTP/x.x */ if ((url = strtok(NULL, "\n")) == NULL) { debug(33, 1) ("parseHttpRequest: Missing URL\n"); return parseHttpRequestAbort(conn, "error:missing-url"); } url = skipLeadingSpace(url); - token = findTrailingHTTPVersion (url); + token = findTrailingHTTPVersion (url); trimTrailingSpaces (url, token - url - 1); - + debug(33, 5) ("parseHttpRequest: URI is '%s'\n", url); *url_p = url; if (token == NULL) { debug(33, 3) ("parseHttpRequest: Missing HTTP identifier\n"); #if RELAXED_HTTP_PARSER - httpBuildVersion(http_ver_p, 0, 9); /* wild guess */ + httpBuildVersion(http_ver_p, 0, 9); /* wild guess */ #else return parseHttpRequestAbort(conn, "error:missing-http-ident"); #endif } else { if (sscanf(token + 5, "%d.%d", &http_ver_p->major, - &http_ver_p->minor) != 2) { + &http_ver_p->minor) != 2) { debug(33, 3) ("parseHttpRequest: Invalid HTTP identifier.\n"); return parseHttpRequestAbort(conn, "error: invalid HTTP-ident"); } debug(33, 6) ("parseHttpRequest: Client HTTP version %d.%d.\n", http_ver_p->major, http_ver_p->minor); } + return NULL; +} + +/* Utility function to perform part of request parsing */ +static clientSocketContext * +clientParseHttpRequestLine(char *inbuf, size_t req_sz, ConnStateData * conn, + method_t * method_p, char **url_p, http_version_t * http_ver_p) +{ + clientSocketContext *result = NULL; + if ((result = clientCheckRequestLineIsParseable (inbuf, req_sz, conn)) + || (result = clientParseRequestMethod(inbuf, method_p, conn)) + || (result = parseURIandHTTPVersion(url_p, http_ver_p, conn))) + return result; - /* everything was ok */ return NULL; }