--------------------- PatchSet 6680 Date: 2008/02/03 04:38:59 Author: amosjeffries Branch: ayjwork Tag: (none) Log: More fixes of HttpRequestMethod. - drops _method_t silent conversions. - adds method id() accessor when needed to replace the conversions. - adds positive equality operators for _method_t and class-self. - documents some functions and methods. - adds TODO list items on further issues detected this update. Combined the above make HttpRequestMethod compile again and pass all existing unit-tests again. Members: src/ACLMethodData.cc:1.8.8.1->1.8.8.2 src/HttpReply.cc:1.38.4.10->1.38.4.11 src/HttpRequest.cc:1.37.4.8->1.37.4.9 src/HttpRequestMethod.cc:1.2.4.3->1.2.4.4 src/HttpRequestMethod.h:1.2.4.3->1.2.4.4 src/client_side.cc:1.119.2.12->1.119.2.13 src/client_side_reply.cc:1.90.4.14->1.90.4.15 src/client_side_request.cc:1.66.4.16->1.66.4.17 src/forward.cc:1.64.2.8->1.64.2.9 src/htcp.cc:1.29.4.5->1.29.4.6 src/http.cc:1.99.2.15->1.99.2.16 src/store_key_md5.cc:1.7.8.3->1.7.8.4 src/url.cc:1.17.4.7->1.17.4.8 src/tests/testHttpRequest.cc:1.1.18.5->1.1.18.6 src/tests/testHttpRequestMethod.cc:1.2.8.4->1.2.8.5 Index: squid3/src/ACLMethodData.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLMethodData.cc,v retrieving revision 1.8.8.1 retrieving revision 1.8.8.2 diff -u -r1.8.8.1 -r1.8.8.2 --- squid3/src/ACLMethodData.cc 22 Jan 2008 22:34:14 -0000 1.8.8.1 +++ squid3/src/ACLMethodData.cc 3 Feb 2008 04:38:59 -0000 1.8.8.2 @@ -1,5 +1,5 @@ /* - * $Id: ACLMethodData.cc,v 1.8.8.1 2008/01/22 22:34:14 amosjeffries Exp $ + * $Id: ACLMethodData.cc,v 1.8.8.2 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -54,10 +54,11 @@ delete values; } +/// todo make this a pass-by-reference now that HTTPRequestMethods a full class? bool ACLMethodData::match(HttpRequestMethod toFind) { - return values->findAndTune (toFind); + return values->findAndTune(toFind); } /* explicit instantiation required for some systems */ @@ -89,7 +90,7 @@ ; while ((t = strtokFile())) { - List *q = new List (HttpRequestMethod(t)); + List *q = new List (HttpRequestMethod(t, NULL)); *(Tail) = q; Tail = &q->next; } Index: squid3/src/HttpReply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.cc,v retrieving revision 1.38.4.10 retrieving revision 1.38.4.11 diff -u -r1.38.4.10 -r1.38.4.11 --- squid3/src/HttpReply.cc 22 Jan 2008 22:34:19 -0000 1.38.4.10 +++ squid3/src/HttpReply.cc 3 Feb 2008 04:38:59 -0000 1.38.4.11 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.38.4.10 2008/01/22 22:34:19 amosjeffries Exp $ + * $Id: HttpReply.cc,v 1.38.4.11 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -420,7 +420,7 @@ { if (sline.version.major < 1) return -1; - else if (METHOD_HEAD == method) + else if (method.id() == METHOD_HEAD) return 0; else if (sline.status == HTTP_OK) (void) 0; /* common case, continue */ Index: squid3/src/HttpRequest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.cc,v retrieving revision 1.37.4.8 retrieving revision 1.37.4.9 diff -u -r1.37.4.8 -r1.37.4.9 --- squid3/src/HttpRequest.cc 22 Jan 2008 22:34:20 -0000 1.37.4.8 +++ squid3/src/HttpRequest.cc 3 Feb 2008 04:38:59 -0000 1.37.4.9 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.37.4.8 2008/01/22 22:34:20 amosjeffries Exp $ + * $Id: HttpRequest.cc,v 1.37.4.9 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -143,13 +143,14 @@ bool HttpRequest::sanityCheckStartLine(MemBuf *buf, http_status *error) { - /* + /** * Just see if the request buffer starts with a known * HTTP request method. NOTE this whole function is somewhat * superfluous and could just go away. + \todo AYJ: Check for safely removing this function. We now accept 'unknown' request methods in HTTP. */ - if (METHOD_NONE == HttpRequestMethod(buf->content())) { + if (HttpRequestMethod(buf->content(),NULL) == METHOD_NONE) { debugs(73, 3, "HttpRequest::sanityCheckStartLine: did not find HTTP request method"); return false; } @@ -163,7 +164,7 @@ const char *t = start + strcspn(start, w_space); method = HttpRequestMethod(start, t); - if (METHOD_NONE == method) + if (method == METHOD_NONE) return false; start = t + strspn(t, w_space); Index: squid3/src/HttpRequestMethod.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequestMethod.cc,v retrieving revision 1.2.4.3 retrieving revision 1.2.4.4 diff -u -r1.2.4.3 -r1.2.4.4 --- squid3/src/HttpRequestMethod.cc 2 Feb 2008 13:12:57 -0000 1.2.4.3 +++ squid3/src/HttpRequestMethod.cc 3 Feb 2008 04:38:59 -0000 1.2.4.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequestMethod.cc,v 1.2.4.3 2008/02/02 13:12:57 amosjeffries Exp $ + * $Id: HttpRequestMethod.cc,v 1.2.4.4 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -144,6 +144,7 @@ theImage.limitInit(begin,end-begin); } +/** \todo AYJ: this _should_ be obsolete. Since all such methods fit nicely into METHOD_OTHER now. */ void HttpRequestMethod::AddExtension(const char *mstr) { @@ -193,10 +194,11 @@ return RequestMethodStr[theMethod]; } else { - if (theImage.size()>0) + if (theImage.size()>0) { return theImage.buf(); - else + } else { return "METHOD_OTHER"; + } } } Index: squid3/src/HttpRequestMethod.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequestMethod.h,v retrieving revision 1.2.4.3 retrieving revision 1.2.4.4 diff -u -r1.2.4.3 -r1.2.4.4 --- squid3/src/HttpRequestMethod.h 2 Feb 2008 13:12:57 -0000 1.2.4.3 +++ squid3/src/HttpRequestMethod.h 3 Feb 2008 04:38:59 -0000 1.2.4.4 @@ -1,5 +1,5 @@ /* - * $Id: HttpRequestMethod.h,v 1.2.4.3 2008/02/02 13:12:57 amosjeffries Exp $ + * $Id: HttpRequestMethod.h,v 1.2.4.4 2008/02/03 04:38:59 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -100,6 +100,7 @@ * - i.e. PUT, POST, GET etc. * It has a runtime extension facility to allow it to * efficiently support new methods + \ingroup POD */ class HttpRequestMethod { @@ -112,9 +113,13 @@ HttpRequestMethod(_method_t const aMethod) : theMethod(aMethod), theImage() {} - HttpRequestMethod(char const * begin, char const * end=0); - - operator _method_t() const {return theMethod; } + /** + \param begin string to convert to request method. + \param end end of the method string (relative to begin). Use NULL if this is unknown. + * + \note DO NOT give end a default (ie NULL). That will cause silent char* conversion clashes. + */ + HttpRequestMethod(char const * begin, char const * end); HttpRequestMethod & operator = (const HttpRequestMethod& aMethod) { @@ -130,17 +135,22 @@ return *this; } - bool operator == (_method_t const & aMethod) { return theMethod == aMethod;} - bool operator != (_method_t const & aMethod) { return theMethod != aMethod;} - bool operator != (HttpRequestMethod const & aMethod) - { - return ( (theMethod != aMethod) || (theImage != aMethod.theImage) ); + bool operator == (_method_t const & aMethod) const { return theMethod == aMethod; } + bool operator == (HttpRequestMethod const & aMethod) const + { + return ( (theMethod == aMethod.theMethod) || (theImage == aMethod.theImage) ); } + bool operator != (_method_t const & aMethod) const { return theMethod != aMethod; } + bool operator != (HttpRequestMethod const & aMethod) const + { + return ( (theMethod != aMethod.theMethod) || (theImage != aMethod.theImage) ); + } + + /** Iterate through the registered HTTP methods. */ HttpRequestMethod& operator++() { - if (METHOD_OTHER!=theMethod) - { + if(METHOD_OTHER != theMethod) { int tmp = (int)theMethod; _method_t tmp_m = (_method_t)(++tmp); @@ -150,7 +160,14 @@ return *this; } - /* Get a char string representation of the method. */ + /** Get an ID representation of the method. + \retval METHOD_NONE the methopd is currently unset or unknown. + \retval METHOD_UNKNOWN the method has been accepted but is not one of the registerd HTTP methods. + \retval * the method is on of the registered HTTP methods. + */ + _method_t const id() const { return theMethod; } + + /** Get a char string representation of the method. */ char const* image() const; bool isCacheble() const; @@ -162,17 +179,12 @@ String theImage; ///< Used for store METHOD_OTHER only }; -#if 0 -/* AYJ: Duplicated code. Seem an HttpRequestMethod can itself be converted to String() and - * this operator clashes with that operator. - */ inline std::ostream & operator << (std::ostream &os, HttpRequestMethod const &method) { os << method.image(); return os; } -#endif inline const char* RequestMethodStr(const _method_t m) Index: squid3/src/client_side.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v retrieving revision 1.119.2.12 retrieving revision 1.119.2.13 diff -u -r1.119.2.12 -r1.119.2.13 --- squid3/src/client_side.cc 22 Jan 2008 22:34:24 -0000 1.119.2.12 +++ squid3/src/client_side.cc 3 Feb 2008 04:38:59 -0000 1.119.2.13 @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.119.2.12 2008/01/22 22:34:24 amosjeffries Exp $ + * $Id: client_side.cc,v 1.119.2.13 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -667,7 +667,7 @@ static int clientIsContentLengthValid(HttpRequest * r) { - switch (r->method) { + switch (r->method.id()) { case METHOD_PUT: Index: squid3/src/client_side_reply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_reply.cc,v retrieving revision 1.90.4.14 retrieving revision 1.90.4.15 diff -u -r1.90.4.14 -r1.90.4.15 --- squid3/src/client_side_reply.cc 22 Jan 2008 22:34:24 -0000 1.90.4.14 +++ squid3/src/client_side_reply.cc 3 Feb 2008 04:38:59 -0000 1.90.4.15 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.90.4.14 2008/01/22 22:34:24 amosjeffries Exp $ + * $Id: client_side_reply.cc,v 1.90.4.15 2008/02/03 04:38:59 amosjeffries Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -677,8 +677,8 @@ purgeRequest(); return; } - - if (METHOD_OTHER == r->method) { + + if (r->method == METHOD_OTHER) { // invalidate all cache entries purgeAllCached(); } Index: squid3/src/client_side_request.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v retrieving revision 1.66.4.16 retrieving revision 1.66.4.17 diff -u -r1.66.4.16 -r1.66.4.17 --- squid3/src/client_side_request.cc 22 Jan 2008 22:34:28 -0000 1.66.4.16 +++ squid3/src/client_side_request.cc 3 Feb 2008 04:39:00 -0000 1.66.4.17 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.66.4.16 2008/01/22 22:34:28 amosjeffries Exp $ + * $Id: client_side_request.cc,v 1.66.4.17 2008/02/03 04:39:00 amosjeffries Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -656,8 +656,8 @@ } } } - - if (METHOD_OTHER == request->method) { + + if (request->method == METHOD_OTHER) { no_cache++; } @@ -1126,7 +1126,7 @@ xfree(uri); uri = xstrdup(urlCanonical(request)); setLogUri(this, urlCanonicalClean(request)); - assert(request->method); + assert(request->method.id()); } else if (HttpReply *new_rep = dynamic_cast(msg)) { debugs(85,3,HERE << "REQMOD reply is HTTP reply"); Index: squid3/src/forward.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/forward.cc,v retrieving revision 1.64.2.8 retrieving revision 1.64.2.9 diff -u -r1.64.2.8 -r1.64.2.9 --- squid3/src/forward.cc 22 Jan 2008 22:34:28 -0000 1.64.2.8 +++ squid3/src/forward.cc 3 Feb 2008 04:39:00 -0000 1.64.2.9 @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.64.2.8 2008/01/22 22:34:28 amosjeffries Exp $ + * $Id: forward.cc,v 1.64.2.9 2008/02/03 04:39:00 amosjeffries Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -464,13 +464,13 @@ return false; /* RFC2616 9.1 Safe and Idempotent Methods */ - switch (request->method) { + switch (request->method.id()) { /* 9.1.1 Safe Methods */ case METHOD_GET: case METHOD_HEAD: - /* 9.1.2 Indepontent Methods */ + /* 9.1.2 Idempotent Methods */ case METHOD_PUT: Index: squid3/src/htcp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/htcp.cc,v retrieving revision 1.29.4.5 retrieving revision 1.29.4.6 diff -u -r1.29.4.5 -r1.29.4.6 --- squid3/src/htcp.cc 22 Jan 2008 22:34:28 -0000 1.29.4.5 +++ squid3/src/htcp.cc 3 Feb 2008 04:39:00 -0000 1.29.4.6 @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.29.4.5 2008/01/22 22:34:28 amosjeffries Exp $ + * $Id: htcp.cc,v 1.29.4.6 2008/02/03 04:39:00 amosjeffries Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -762,7 +762,7 @@ /* * Parse the request */ - method = HttpRequestMethod(s->method); + method = HttpRequestMethod(s->method, NULL); s->request = HttpRequest::CreateFromUrlAndMethod(s->uri, method == METHOD_NONE ? HttpRequestMethod(METHOD_GET) : method); Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.99.2.15 retrieving revision 1.99.2.16 diff -u -r1.99.2.15 -r1.99.2.16 --- squid3/src/http.cc 22 Jan 2008 22:34:28 -0000 1.99.2.15 +++ squid3/src/http.cc 3 Feb 2008 04:39:01 -0000 1.99.2.16 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.99.2.15 2008/01/22 22:34:28 amosjeffries Exp $ + * $Id: http.cc,v 1.99.2.16 2008/02/03 04:39:01 amosjeffries Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -200,12 +200,8 @@ static void httpMaybeRemovePublic(StoreEntry * e, http_status status) { - - int remove - = 0; - + int remove = 0; int forbidden = 0; - StoreEntry *pe; if (!EBIT_TEST(e->flags, KEY_PRIVATE)) @@ -226,9 +222,7 @@ case HTTP_GONE: case HTTP_NOT_FOUND: - - remove - = 1; + remove = 1; break; @@ -255,16 +249,14 @@ */ if (status >= 200 && status < 300) - remove - = 1; + remove = 1; #endif break; } - if (!remove - && !forbidden) + if (!remove && !forbidden) return; assert(e->mem_obj); @@ -279,7 +271,7 @@ pe->release(); } - /* + /** \par * Also remove any cached HEAD response in case the object has * changed. */ @@ -296,7 +288,9 @@ if (forbidden) return; - switch (e->mem_obj->method) { + /// \todo AYJ: given the coment below + new behaviour of accepting METHOD_UNKNOWN, should we invert this test + /// removing the object unless the method is nown to be safely kept? + switch (e->mem_obj->method.id()) { case METHOD_PUT: @@ -311,8 +305,8 @@ case METHOD_BMOVE: case METHOD_BDELETE: - /* - * Remove any cached GET object if it is beleived that the + /** \par + * Remove any cached GET object if it is believed that the * object may have changed as a result of other methods */ Index: squid3/src/store_key_md5.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store_key_md5.cc,v retrieving revision 1.7.8.3 retrieving revision 1.7.8.4 diff -u -r1.7.8.3 -r1.7.8.4 --- squid3/src/store_key_md5.cc 22 Jan 2008 22:34:30 -0000 1.7.8.3 +++ squid3/src/store_key_md5.cc 3 Feb 2008 04:39:02 -0000 1.7.8.4 @@ -1,6 +1,6 @@ /* - * $Id: store_key_md5.cc,v 1.7.8.3 2008/01/22 22:34:30 amosjeffries Exp $ + * $Id: store_key_md5.cc,v 1.7.8.4 2008/02/03 04:39:02 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager MD5 Cache Keys * AUTHOR: Duane Wessels @@ -117,7 +117,7 @@ storeKeyPublic(const char *url, const HttpRequestMethod& method) { static cache_key digest[SQUID_MD5_DIGEST_LENGTH]; - unsigned char m = (unsigned char) method; + unsigned char m = (unsigned char) method.id(); SquidMD5_CTX M; SquidMD5Init(&M); SquidMD5Update(&M, &m, sizeof(m)); @@ -136,7 +136,7 @@ storeKeyPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method) { static cache_key digest[SQUID_MD5_DIGEST_LENGTH]; - unsigned char m = (unsigned char) method; + unsigned char m = (unsigned char) method.id(); const char *url = urlCanonical(request); SquidMD5_CTX M; SquidMD5Init(&M); Index: squid3/src/url.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/url.cc,v retrieving revision 1.17.4.7 retrieving revision 1.17.4.8 diff -u -r1.17.4.7 -r1.17.4.8 --- squid3/src/url.cc 22 Jan 2008 22:34:32 -0000 1.17.4.7 +++ squid3/src/url.cc 3 Feb 2008 04:39:02 -0000 1.17.4.8 @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.17.4.7 2008/01/22 22:34:32 amosjeffries Exp $ + * $Id: url.cc,v 1.17.4.8 2008/02/03 04:39:02 amosjeffries Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -430,6 +430,7 @@ urlCanonical(HttpRequest * request) { LOCAL_ARRAY(char, portbuf, 32); +/// \todo AYJ: Performance: making this a ptr and allocating when needed will be better than a write and future xstrdup(). LOCAL_ARRAY(char, urlbuf, MAX_URL); if (request->canonical) @@ -438,7 +439,8 @@ if (request->protocol == PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.buf()); } else { - switch (request->method) { +/// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier. + switch (request->method.id()) { case METHOD_CONNECT: snprintf(urlbuf, MAX_URL, "%s:%d", request->GetHost(), request->port); @@ -465,6 +467,10 @@ return (request->canonical = xstrdup(urlbuf)); } +/** \todo AYJ: Performance: This is an *almost* duplicate of urlCanoncical. But elides the query-string. + * After copying it on in the first place! Would be less code to merge the two with a flag parameter. + * and never copy the query-string part in the first place + */ char * urlCanonicalClean(const HttpRequest * request) { @@ -476,7 +482,8 @@ if (request->protocol == PROTO_URN) { snprintf(buf, MAX_URL, "urn:%s", request->urlpath.buf()); } else { - switch (request->method) { +/// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier. + switch (request->method.id()) { case METHOD_CONNECT: snprintf(buf, MAX_URL, "%s:%d", Index: squid3/src/tests/testHttpRequest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tests/testHttpRequest.cc,v retrieving revision 1.1.18.5 retrieving revision 1.1.18.6 diff -u -r1.1.18.5 -r1.1.18.6 --- squid3/src/tests/testHttpRequest.cc 2 Feb 2008 13:12:57 -0000 1.1.18.5 +++ squid3/src/tests/testHttpRequest.cc 3 Feb 2008 04:39:03 -0000 1.1.18.6 @@ -36,7 +36,7 @@ expected_port = 90; HttpRequest *nullRequest = NULL; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); - CPPUNIT_ASSERT(METHOD_GET == aRequest->method); + CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); @@ -48,7 +48,7 @@ aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_PUT); expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); - CPPUNIT_ASSERT(METHOD_PUT == aRequest->method); + CPPUNIT_ASSERT(aRequest->method == METHOD_PUT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); Index: squid3/src/tests/testHttpRequestMethod.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tests/testHttpRequestMethod.cc,v retrieving revision 1.2.8.4 retrieving revision 1.2.8.5 diff -u -r1.2.8.4 -r1.2.8.5 --- squid3/src/tests/testHttpRequestMethod.cc 2 Feb 2008 13:12:57 -0000 1.2.8.4 +++ squid3/src/tests/testHttpRequestMethod.cc 3 Feb 2008 04:39:03 -0000 1.2.8.5 @@ -17,10 +17,10 @@ testHttpRequestMethod::testConstructCharStart() { /* parse an empty string -> METHOD_NONE */ - CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL)); + CPPUNIT_ASSERT(HttpRequestMethod(NULL,NULL) == METHOD_NONE); /* parsing a literal should work */ - CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL)); - CPPUNIT_ASSERT(METHOD_OTHER == HttpRequestMethod("QWERTY", NULL)); + CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET); + CPPUNIT_ASSERT(HttpRequestMethod("QWERTY", NULL) == METHOD_OTHER); } /* @@ -31,12 +31,12 @@ { char const * buffer; /* parse an empty string -> METHOD_NONE */ - CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL)); + CPPUNIT_ASSERT(HttpRequestMethod(NULL, NULL) == METHOD_NONE); /* parsing a literal should work */ - CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL)); + CPPUNIT_ASSERT(HttpRequestMethod("GET", NULL) == METHOD_GET); /* parsing with an explicit end should work */ buffer = "POSTPLUS"; - CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4)); + CPPUNIT_ASSERT(HttpRequestMethod(buffer, buffer + 4) == METHOD_POST); } /* @@ -80,7 +80,7 @@ void testHttpRequestMethod::testImage() { - CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post").image())); + CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post",NULL).image())); } /* @@ -92,8 +92,8 @@ { CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) == METHOD_NONE); CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) == METHOD_GET)); - CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod(METHOD_GET)); - CPPUNIT_ASSERT(not (METHOD_SEARCH == HttpRequestMethod(METHOD_TRACE))); + CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) == METHOD_GET); + CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_TRACE) == METHOD_SEARCH)); } /* @@ -104,8 +104,8 @@ { CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) != METHOD_GET); CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) != METHOD_POST)); - CPPUNIT_ASSERT(METHOD_NONE != HttpRequestMethod(METHOD_GET)); - CPPUNIT_ASSERT(not (METHOD_SEARCH != HttpRequestMethod(METHOD_SEARCH))); + CPPUNIT_ASSERT(HttpRequestMethod(METHOD_GET) != METHOD_NONE); + CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_SEARCH) != METHOD_SEARCH)); } /* @@ -115,6 +115,6 @@ testHttpRequestMethod::testStream() { std::ostringstream buffer; - buffer << HttpRequestMethod("get"); + buffer << HttpRequestMethod("get",NULL); CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str())); }