[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squid-cvs
Subject:    /bzr/squid3/trunk/ r13369: SBuf: convert HttpMethod internals
From:       Amos Jeffries <squid3 () treenet ! co ! nz>
Date:       2014-04-22 2:47:09
Message-ID: 20140422025009.51356.qmail () squid-cache ! org
[Download RAW message or body]

--===============1125395252==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------
revno: 13369
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: trunk
timestamp: Mon 2014-04-21 19:47:09 -0700
message:
  SBuf: convert HttpMethod internals
  
  Update the internal string/image representation of an HTTP
  method to be an SBuf string. Including the global registered
  methods index.
  
  Also,
   * remove RequestMethodStr() wrapper functions
   * remove remainders of obsolete extension_methods feature
   * remove remainders of obsolete RequestMethodStr[] array
   * fix potential cache key error from http/MethodType.h
     enum ordering.
   * polished many debugs involving method
modified:
  src/AccessLogEntry.h
  src/FwdState.cc
  src/HttpRequest.cc
  src/HttpRequestMethod.cc
  src/HttpRequestMethod.h
  src/Makefile.am
  src/MemObject.cc
  src/Server.cc
  src/acl/MethodData.cc
  src/auth/digest/UserRequest.cc
  src/cache_diff.cc
  src/client_side.cc
  src/client_side_reply.cc
  src/client_side_request.cc
  src/errorpage.cc
  src/external_acl.cc
  src/format/Format.cc
  src/htcp.cc
  src/http.cc
  src/http/Makefile.am
  src/http/MethodType.h
  src/log/FormatHttpdCombined.cc
  src/log/FormatHttpdCommon.cc
  src/log/FormatSquidNative.cc
  src/log/access_log.cc
  src/mgr/ActionParams.cc
  src/mk-string-arrays.awk
  src/peer_select.cc
  src/store_log.cc
  src/test_cache_digest.cc
  src/tests/testHttpRequestMethod.cc
  src/tunnel.cc

--===============1125395252==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; name="r13369.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

=== modified file 'src/AccessLogEntry.h'
--- a/src/AccessLogEntry.h	2014-03-30 12:00:34 +0000
+++ b/src/AccessLogEntry.h	2014-04-22 02:47:09 +0000
@@ -223,8 +223,7 @@
 #endif
 
     // Why is this a sub-class and not a set of real "private:" fields?
-    // It looks like its duplicating HTTPRequestMethod anyway!
-    // TODO: shuffle this to the relevant protocol section OR replace with \
request->method +    // TODO: shuffle this to the relevant ICP/HTCP protocol section
     class Private
     {
 

=== modified file 'src/FwdState.cc'
--- a/src/FwdState.cc	2014-04-14 17:01:18 +0000
+++ b/src/FwdState.cc	2014-04-22 02:47:09 +0000
@@ -1203,7 +1203,7 @@
 void
 FwdState::dispatch()
 {
-    debugs(17, 3, HERE << clientConn << ": Fetching '" << \
RequestMethodStr(request->method) << " " << entry->url() << "'"); +    debugs(17, 3, \
clientConn << ": Fetching " << request->method << ' ' << entry->url());  /*
      * Assert that server_fd is set.  This is to guarantee that fwdState
      * is attached to something and will be deallocated when server_fd

=== modified file 'src/HttpRequest.cc'
--- a/src/HttpRequest.cc	2014-03-15 02:50:12 +0000
+++ b/src/HttpRequest.cc	2014-04-22 02:47:09 +0000
@@ -391,8 +391,8 @@
 {
     assert(p);
     /* pack request-line */
-    packerPrintf(p, "%s " SQUIDSTRINGPH " HTTP/%d.%d\r\n",
-                 RequestMethodStr(method), SQUIDSTRINGPRINT(urlpath),
+    packerPrintf(p, SQUIDSBUFPH " " SQUIDSTRINGPH " HTTP/%d.%d\r\n",
+                 SQUIDSBUFPRINT(method.image()), SQUIDSTRINGPRINT(urlpath),
                  http_ver.major, http_ver.minor);
     /* headers */
     header.packInto(p);
@@ -414,7 +414,7 @@
 int
 HttpRequest::prefixLen()
 {
-    return strlen(RequestMethodStr(method)) + 1 +
+    return method.image().length() + 1 +
            urlpath.size() + 1 +
            4 + 1 + 3 + 2 +
            header.len + 2;
@@ -524,8 +524,8 @@
 void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const
 {
     // form HTTP request-line
-    packerPrintf(p, "%s %s HTTP/%d.%d\r\n",
-                 RequestMethodStr(method),
+    packerPrintf(p, SQUIDSBUFPH " %s HTTP/%d.%d\r\n",
+                 SQUIDSBUFPRINT(method.image()),
                  packableURI(full_uri),
                  http_ver.major, http_ver.minor);
 }

=== modified file 'src/HttpRequestMethod.cc'
--- a/src/HttpRequestMethod.cc	2013-12-18 00:48:33 +0000
+++ b/src/HttpRequestMethod.cc	2014-04-22 02:47:09 +0000
@@ -20,21 +20,12 @@
  * or from a range of chars, * such as "GET" from "GETFOOBARBAZ"
  * (pass in pointer to G and pointer to F.)
  */
-HttpRequestMethod::HttpRequestMethod(char const *begin, char const *end) : theMethod \
(Http::METHOD_NONE) +HttpRequestMethod::HttpRequestMethod(char const *begin, char \
const *end) : theMethod(Http::METHOD_NONE)  {
     if (begin == NULL)
         return;
 
     /*
-     * This check for '%' makes sure that we don't
-     * match one of the extension method placeholders,
-     * which have the form %EXT[0-9][0-9]
-     */
-
-    if (*begin == '%')
-        return;
-
-    /*
      * if e is NULL, b must be NULL terminated and we
      * make e point to the first whitespace character
      * after b.
@@ -42,40 +33,40 @@
     if (NULL == end)
         end = begin + strcspn(begin, w_space);
 
-    if (end == begin) {
-        theMethod = Http::METHOD_NONE;
+    if (end == begin)
         return;
-    }
 
+    // TODO: Optimize this linear search.
     for (++theMethod; theMethod < Http::METHOD_ENUM_END; ++theMethod) {
         // RFC 2616 section 5.1.1 - Method names are case-sensitive
         // NP: this is not a HTTP_VIOLATIONS case since there is no MUST/SHOULD \
                involved.
-        if (0 == strncasecmp(begin, Http::MethodType_str[theMethod], end-begin)) {
+        if (0 == image().caseCmp(begin, end-begin)) {
 
             // relaxed parser allows mixed-case and corrects them on output
             if (Config.onoff.relaxed_header_parser)
                 return;
 
-            if (0 == strncmp(begin, Http::MethodType_str[theMethod], end-begin))
+            if (0 == image().cmp(begin, end-begin))
                 return;
         }
     }
 
     // if method not found and method string is not null then it is other method
     theMethod = Http::METHOD_OTHER;
-    theImage.limitInit(begin,end-begin);
+    theImage.assign(begin, end-begin);
 }
 
-char const*
+const SBuf &
 HttpRequestMethod::image() const
 {
+    static const SBuf methodOther("METHOD_OTHER");
     if (Http::METHOD_OTHER != theMethod) {
-        return Http::MethodType_str[theMethod];
+        return Http::MethodType_sb[theMethod];
     } else {
-        if (theImage.size()>0) {
-            return theImage.termedBuf();
+        if (!theImage.isEmpty()) {
+            return theImage;
         } else {
-            return "METHOD_OTHER";
+            return methodOther;
         }
     }
 }

=== modified file 'src/HttpRequestMethod.h'
--- a/src/HttpRequestMethod.h	2012-10-26 11:36:45 +0000
+++ b/src/HttpRequestMethod.h	2014-04-22 02:47:09 +0000
@@ -2,8 +2,7 @@
 #define SQUID_HTTPREQUESTMETHOD_H
 
 #include "http/MethodType.h"
-#include "SquidString.h"
-#include "SquidString.h"
+#include "SBuf.h"
 
 class SquidConfig;
 
@@ -41,7 +40,7 @@
 
     HttpRequestMethod & operator = (Http::MethodType const aMethod) {
         theMethod = aMethod;
-        theImage.clean();
+        theImage.clear();
         return *this;
     }
 
@@ -73,8 +72,8 @@
      */
     Http::MethodType id() const { return theMethod; }
 
-    /** Get a char string representation of the method. */
-    char const * image() const;
+    /** Get a string representation of the method. */
+    const SBuf &image() const;
 
     /// Whether this method is defined as a "safe" in HTTP/1.1
     /// see RFC 2616 section 9.1.1
@@ -112,10 +111,8 @@
     bool purgesOthers() const;
 
 private:
-    static const char *RequestMethodStr[];
-
     Http::MethodType theMethod; ///< Method type
-    String theImage;     ///< Used for storing the Http::METHOD_OTHER only. A copy \
of the parsed method text. +    SBuf theImage;     ///< Used for storing the \
Http::METHOD_OTHER only. A copy of the parsed method text.  };
 
 inline std::ostream &
@@ -125,16 +122,4 @@
     return os;
 }
 
-inline const char*
-RequestMethodStr(const Http::MethodType m)
-{
-    return HttpRequestMethod(m).image();
-}
-
-inline const char*
-RequestMethodStr(const HttpRequestMethod& m)
-{
-    return m.image();
-}
-
 #endif /* SQUID_HTTPREQUESTMETHOD_H */

=== modified file 'src/Makefile.am'
--- a/src/Makefile.am	2014-04-08 15:52:58 +0000
+++ b/src/Makefile.am	2014-04-22 02:47:09 +0000
@@ -3804,6 +3804,9 @@
 	fatal.h \
 	tests/stub_fatal.cc \
 	tests/stub_MemBuf.cc \
+	$(SBUF_SOURCE) \
+	SBufDetailedStats.h \
+	tests/stub_SBufDetailedStats.cc \
 	StatHist.cc \
 	StatHist.h \
 	String.cc \
@@ -3822,6 +3825,7 @@
 	repl_modules.h \
 	tests/stub_store.cc \
 	tests/stub_store_stats.cc \
+	time.cc \
 	tools.h \
 	tests/stub_tools.cc \
 	tests/testMain.cc \

=== modified file 'src/MemObject.cc'
--- a/src/MemObject.cc	2013-12-31 18:49:41 +0000
+++ b/src/MemObject.cc	2014-04-22 02:47:09 +0000
@@ -243,8 +243,7 @@
 void
 MemObject::stat(MemBuf * mb) const
 {
-    mb->Printf("\t%s %s\n",
-               RequestMethodStr(method), logUri());
+    mb->Printf("\t" SQUIDSBUFPH " %s\n", SQUIDSBUFPRINT(method.image()), logUri());
     if (vary_headers)
         mb->Printf("\tvary_headers: %s\n", vary_headers);
     mb->Printf("\tinmem_lo: %" PRId64 "\n", inmem_lo);

=== modified file 'src/Server.cc'
--- a/src/Server.cc	2014-01-01 19:20:49 +0000
+++ b/src/Server.cc	2014-04-22 02:47:09 +0000
@@ -517,7 +517,7 @@
 
     // XXX: should we use originalRequest() here?
     const char *reqUrl = urlCanonical(request);
-    debugs(88, 5, "maybe purging due to " << RequestMethodStr(request->method) << ' \
' << reqUrl); +    debugs(88, 5, "maybe purging due to " << request->method << ' ' << \
reqUrl);  purgeEntriesByUrl(request, reqUrl);
     purgeEntriesByHeader(request, reqUrl, theFinalReply, HDR_LOCATION);
     purgeEntriesByHeader(request, reqUrl, theFinalReply, HDR_CONTENT_LOCATION);

=== modified file 'src/acl/MethodData.cc'
--- a/src/acl/MethodData.cc	2014-04-12 13:29:42 +0000
+++ b/src/acl/MethodData.cc	2014-04-22 02:47:09 +0000
@@ -74,7 +74,7 @@
     CbDataList<HttpRequestMethod> *data = values;
 
     while (data != NULL) {
-        sl.push_back(SBuf(RequestMethodStr(data->element)));
+        sl.push_back(data->element.image());
         data = data->next;
     }
 

=== modified file 'src/auth/digest/UserRequest.cc'
--- a/src/auth/digest/UserRequest.cc	2014-02-21 02:19:52 +0000
+++ b/src/auth/digest/UserRequest.cc	2014-04-22 02:47:09 +0000
@@ -102,9 +102,10 @@
                   authenticateDigestNonceNonceb64(digest_request->nonce),
                   digest_request->cnonce,
                   digest_user->HA1, SESSIONKEY);
+    SBuf sTmp = request->method.image();
     DigestCalcResponse(SESSIONKEY, \
                authenticateDigestNonceNonceb64(digest_request->nonce),
                        digest_request->nc, digest_request->cnonce, \
                digest_request->qop,
-                       RequestMethodStr(request->method), digest_request->uri, HA2, \
Response); +                       sTmp.c_str(), digest_request->uri, HA2, Response);
 
     debugs(29, 9, "\nResponse = '" << digest_request->response << "'\nsquid is = '" \
<< Response << "'");  
@@ -123,9 +124,10 @@
              * widespread and such broken browsers no longer are commonly
              * used.
              */
+            sTmp = HttpRequestMethod(Http::METHOD_GET).image();
             DigestCalcResponse(SESSIONKEY, \
                authenticateDigestNonceNonceb64(digest_request->nonce),
                                digest_request->nc, digest_request->cnonce, \
                digest_request->qop,
-                               RequestMethodStr(Http::METHOD_GET), \
digest_request->uri, HA2, Response); +                               sTmp.c_str(), \
digest_request->uri, HA2, Response);  
             if (strcasecmp(digest_request->response, Response)) {
                 auth_user->credentials(Auth::Failed);

=== modified file 'src/cache_diff.cc'
--- a/src/cache_diff.cc	2012-09-01 14:38:36 +0000
+++ b/src/cache_diff.cc	2014-04-22 02:47:09 +0000
@@ -59,18 +59,6 @@
     unsigned char key_arr[SQUID_MD5_DIGEST_LENGTH];
 } CacheEntry;
 
-/* copied from url.c */
-const char *RequestMethodStr[] = {
-    "NONE",
-    "GET",
-    "POST",
-    "PUT",
-    "HEAD",
-    "CONNECT",
-    "TRACE",
-    "PURGE"
-};
-
 static int cacheIndexScan(CacheIndex * idx, const char *fname, FILE * file);
 
 static CacheEntry *

=== modified file 'src/client_side.cc'
--- a/src/client_side.cc	2014-03-31 06:57:27 +0000
+++ b/src/client_side.cc	2014-04-22 02:47:09 +0000
@@ -898,10 +898,8 @@
 {
     HttpRequest *request = http->request;
 
-    debugs(33, 3, "clientSetKeepaliveFlag: http_ver = " <<
-           request->http_ver.major << "." << request->http_ver.minor);
-    debugs(33, 3, "clientSetKeepaliveFlag: method = " <<
-           RequestMethodStr(request->method));
+    debugs(33, 3, "http_ver = " << request->http_ver);
+    debugs(33, 3, "method = " << request->method);
 
     // TODO: move to HttpRequest::hdrCacheInit, just like HttpReply.
     request->flags.proxyKeepalive = request->persistent();

=== modified file 'src/client_side_reply.cc'
--- a/src/client_side_reply.cc	2014-03-31 06:57:27 +0000
+++ b/src/client_side_reply.cc	2014-04-22 02:47:09 +0000
@@ -631,7 +631,7 @@
     char *url = http->uri;
     HttpRequest *r = http->request;
     ErrorState *err = NULL;
-    debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr(r->method) << " " << \
url << "'"); +    debugs(88, 4, r->method << ' ' << url);
 
     /**
      * We might have a left-over StoreEntry from a failed cache hit
@@ -708,8 +708,7 @@
 void
 clientReplyContext::processOnlyIfCachedMiss()
 {
-    debugs(88, 4, "clientProcessOnlyIfCachedMiss: '" <<
-           RequestMethodStr(http->request->method) << " " << http->uri << "'");
+    debugs(88, 4, http->request->method << ' ' << http->uri);
     http->al->http.code = Http::scGatewayTimeout;
     ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, \
                Http::scGatewayTimeout, NULL,
                                        http->getConn()->clientConnection->remote, \
http->request); @@ -835,7 +834,7 @@
     for (HttpRequestMethod m(Http::METHOD_NONE); m != Http::METHOD_ENUM_END; ++m) {
         if (m.respMaybeCacheable()) {
             if (StoreEntry *entry = storeGetPublic(url, m)) {
-                debugs(88, 5, "purging " << *entry << ' ' << RequestMethodStr(m) << \
' ' << url); +                debugs(88, 5, "purging " << *entry << ' ' << m << ' ' \
<< url);  #if USE_HTCP
                 neighborsHtcpClear(entry, url, req, m, HTCP_CLR_INVALIDATION);
                 if (m == Http::METHOD_GET || m == Http::METHOD_HEAD) {
@@ -1995,9 +1994,9 @@
 void
 clientReplyContext::processReplyAccessResult(const allow_t &accessAllowed)
 {
-    debugs(88, 2, "The reply for " << RequestMethodStr(http->request->method)
-           << " " << http->uri << " is " << accessAllowed << ", because it matched \
                '"
-           << (AclMatchedName ? AclMatchedName : "NO ACL's") << "'" );
+    debugs(88, 2, "The reply for " << http->request->method
+           << ' ' << http->uri << " is " << accessAllowed << ", because it matched "
+           << (AclMatchedName ? AclMatchedName : "NO ACL's"));
 
     if (accessAllowed != ACCESS_ALLOWED) {
         ErrorState *err;

=== modified file 'src/client_side_request.cc'
--- a/src/client_side_request.cc	2014-03-31 06:57:27 +0000
+++ b/src/client_side_request.cc	2014-04-22 02:47:09 +0000
@@ -758,8 +758,7 @@
     acl_checklist = NULL;
     err_type page_id;
     Http::StatusCode status;
-    debugs(85, 2, "The request " <<
-           RequestMethodStr(http->request->method) << " " <<
+    debugs(85, 2, "The request " << http->request->method << ' ' <<
            http->uri << " is " << answer <<
            "; last ACL checked: " << (AclMatchedName ? AclMatchedName : "[none]"));
 
@@ -1516,7 +1515,7 @@
 void
 ClientHttpRequest::processRequest()
 {
-    debugs(85, 4, "clientProcessRequest: " << RequestMethodStr(request->method) << " \
'" << uri << "'"); +    debugs(85, 4, request->method << ' ' << uri);
 
     if (request->method == Http::METHOD_CONNECT && !redirect.status) {
 #if USE_OPENSSL

=== modified file 'src/errorpage.cc'
--- a/src/errorpage.cc	2014-03-31 06:57:27 +0000
+++ b/src/errorpage.cc	2014-04-22 02:47:09 +0000
@@ -764,8 +764,8 @@
         else
             urlpath_or_slash = "/";
 
-        str.Printf("%s " SQUIDSTRINGPH " %s/%d.%d\n",
-                   RequestMethodStr(request->method),
+        str.Printf(SQUIDSBUFPH " " SQUIDSTRINGPH " %s/%d.%d\n",
+                   SQUIDSBUFPRINT(request->method.image()),
                    SQUIDSTRINGPRINT(urlpath_or_slash),
                    AnyP::ProtocolType_str[request->http_ver.protocol],
                    request->http_ver.major, request->http_ver.minor);
@@ -940,10 +940,11 @@
         break;
 
     case 'M':
-        if (request)
-            p = RequestMethodStr(request->method);
-        else if (!building_deny_info_url)
-            p= "[unknown method]";
+        if (request) {
+           const SBuf &m = request->method.image();
+           mb.append(m.rawContent(), m.length());
+        } else if (!building_deny_info_url)
+            p = "[unknown method]";
         break;
 
     case 'o':
@@ -983,8 +984,8 @@
             else
                 urlpath_or_slash = "/";
 
-            mb.Printf("%s " SQUIDSTRINGPH " %s/%d.%d\n",
-                      RequestMethodStr(request->method),
+            mb.Printf(SQUIDSBUFPH " " SQUIDSTRINGPH " %s/%d.%d\n",
+                      SQUIDSBUFPRINT(request->method.image()),
                       SQUIDSTRINGPRINT(urlpath_or_slash),
                       AnyP::ProtocolType_str[request->http_ver.protocol],
                       request->http_ver.major, request->http_ver.minor);

=== modified file 'src/external_acl.cc'
--- a/src/external_acl.cc	2014-04-12 09:11:20 +0000
+++ b/src/external_acl.cc	2014-04-22 02:47:09 +0000
@@ -1058,7 +1058,11 @@
             break;
 
         case _external_acl_format::EXT_ACL_METHOD:
-            str = RequestMethodStr(request->method);
+            {
+                const SBuf &s = request->method.image();
+                sb.append(s.rawContent(), s.length());
+            }
+            str = sb.termedBuf();
             break;
 
         case _external_acl_format::EXT_ACL_HEADER_REQUEST:

=== modified file 'src/format/Format.cc'
--- a/src/format/Format.cc	2014-03-30 12:00:34 +0000
+++ b/src/format/Format.cc	2014-04-22 02:47:09 +0000
@@ -916,7 +916,9 @@
 
         case LFT_CLIENT_REQ_METHOD:
             if (al->request) {
-                out = al->request->method.image();
+                const SBuf &s = al->request->method.image();
+                sb.append(s.rawContent(), s.length());
+                out = sb.termedBuf();
                 quote = 1;
             }
             break;
@@ -952,7 +954,14 @@
             break;
 
         case LFT_REQUEST_METHOD:
-            out = al->_private.method_str;
+            if (al->_private.method_str) // ICP, HTCP method code
+                out = al->_private.method_str;
+            else {
+                const SBuf &s = al->http.method.image();
+                sb.append(s.rawContent(), s.length());
+                out = sb.termedBuf();
+                quote = 1;
+            }
             break;
 
         case LFT_REQUEST_URI:
@@ -967,7 +976,9 @@
 
         case LFT_SERVER_REQ_METHOD:
             if (al->adapted_request) {
-                out = al->adapted_request->method.image();
+                const SBuf &s = al->adapted_request->method.image();
+                sb.append(s.rawContent(), s.length());
+                out = sb.termedBuf();
                 quote = 1;
             }
             break;

=== modified file 'src/htcp.cc'
--- a/src/htcp.cc	2013-10-25 00:13:46 +0000
+++ b/src/htcp.cc	2014-04-22 02:47:09 +0000
@@ -168,7 +168,7 @@
 
     void setFrom(Ip::Address &from);
     void setDataHeader(htcpDataHeader *);
-    char *method;
+    const char *method;
     char *uri;
     char *version;
     char *req_hdrs;
@@ -1577,7 +1577,8 @@
     stuff.f1 = 1;
     stuff.response = 0;
     stuff.msg_id = ++msg_id_counter;
-    stuff.S.method = (char *) RequestMethodStr(req->method);
+    SBuf sb = req->method.image();
+    stuff.S.method = sb.c_str();
     stuff.S.uri = (char *) e->url();
     stuff.S.version = vbuf;
     HttpStateData::httpBuildRequestHeader(req, e, NULL, &hdr, flags);
@@ -1640,7 +1641,8 @@
         stuff.reason = 0;
         break;
     }
-    stuff.S.method = (char *) RequestMethodStr(req->method);
+    SBuf sb = req->method.image();
+    stuff.S.method = sb.c_str();
     if (e == NULL || e->mem_obj == NULL) {
         if (uri == NULL) {
             return;

=== modified file 'src/http.cc'
--- a/src/http.cc	2014-03-31 06:57:27 +0000
+++ b/src/http.cc	2014-04-22 02:47:09 +0000
@@ -1046,7 +1046,7 @@
      * connection.
      */
     if (!flags.request_sent) {
-        debugs(11, 2, "statusIfComplete: Request not yet fully sent \"" << \
RequestMethodStr(request->method) << " " << entry->url() << "\"" ); +        \
debugs(11, 2, "Request not yet fully sent " << request->method << ' ' << \
entry->url());  return COMPLETE_NONPERSISTENT_MSG;
     }
 
@@ -2117,8 +2117,8 @@
         url = urlCanonical(request);
     else
         url = request->urlpath.termedBuf();
-    mb->Printf("%s %s %s/%d.%d\r\n",
-               RequestMethodStr(request->method),
+    mb->Printf(SQUIDSBUFPH " %s %s/%d.%d\r\n",
+               SQUIDSBUFPRINT(request->method.image()),
                url && *url ? url : "/",
                AnyP::ProtocolType_str[httpver.protocol],
                httpver.major,httpver.minor);
@@ -2269,7 +2269,7 @@
 void
 httpStart(FwdState *fwd)
 {
-    debugs(11, 3, "httpStart: \"" << RequestMethodStr(fwd->request->method) << " " \
<< fwd->entry->url() << "\"" ); +    debugs(11, 3, fwd->request->method << ' ' << \
fwd->entry->url());  AsyncJob::Start(new HttpStateData(fwd));
 }
 

=== modified file 'src/http/Makefile.am'
--- a/src/http/Makefile.am	2013-03-18 04:55:51 +0000
+++ b/src/http/Makefile.am	2014-04-22 02:47:09 +0000
@@ -13,7 +13,7 @@
 	StatusLine.h
 
 MethodType.cc: MethodType.h $(top_srcdir)/src/mk-string-arrays.awk
-	($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk < $(srcdir)/MethodType.h | \
+	($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk sbuf=1 < $(srcdir)/MethodType.h | \
\  sed -e 's%METHOD_%%' -e 's%_C%-C%' >$@) || ($(RM) -f $@ && exit 1)
 
 CLEANFILES += MethodType.cc

=== modified file 'src/http/MethodType.h'
--- a/src/http/MethodType.h	2014-03-31 10:28:35 +0000
+++ b/src/http/MethodType.h	2014-04-22 02:47:09 +0000
@@ -1,6 +1,8 @@
 #ifndef SQUID_SRC_HTTP_METHODTYPE_H
 #define SQUID_SRC_HTTP_METHODTYPE_H
 
+#include "SBuf.h"
+
 namespace Http
 {
 
@@ -11,12 +13,6 @@
 typedef enum _method_t {
     METHOD_NONE = 0,
 
-#if NO_SPECIAL_HANDLING
-    // RFC 2068
-    METHOD_LINK,
-    METHOD_UNLINK,
-#endif
-
     // RFC 2616 (HTTP)
     METHOD_GET,
     METHOD_POST,
@@ -27,6 +23,12 @@
     METHOD_OPTIONS,
     METHOD_DELETE,
 
+#if NO_SPECIAL_HANDLING
+    // RFC 2068
+    METHOD_LINK,
+    METHOD_UNLINK,
+#endif
+
     // RFC 3253
     METHOD_CHECKOUT,
     METHOD_CHECKIN,
@@ -83,12 +85,12 @@
     METHOD_ENUM_END  // MUST be last, (yuck) this is used as an array-initialization \
index constant!  } MethodType;
 
-extern const char *MethodType_str[];
+extern const SBuf MethodType_sb[];
 
-inline const char*
+inline const SBuf &
 MethodStr(const MethodType m)
 {
-    return MethodType_str[m];
+    return MethodType_sb[m];
 }
 
 }; // namespace Http

=== modified file 'src/log/FormatHttpdCombined.cc'
--- a/src/log/FormatHttpdCombined.cc	2013-11-11 12:09:44 +0000
+++ b/src/log/FormatHttpdCombined.cc	2014-04-22 02:47:09 +0000
@@ -67,12 +67,18 @@
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %" PRId64 " \"%s\" \
\"%s\" %s%s:%s%s", +    static SBuf method;
+    if (al->_private.method_str)
+        method.assign(al->_private.method_str);
+    else
+        method = al->http.method.image();
+
+    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" \
PRId64 " \"%s\" \"%s\" %s%s:%s%s",  clientip,
                   user_ident ? user_ident : dash_str,
                   user_auth ? user_auth : dash_str,
                   Time::FormatHttpd(squid_curtime),
-                  al->_private.method_str,
+                  SQUIDSBUFPRINT(method),
                   al->url,
                   AnyP::ProtocolType_str[al->http.version.protocol],
                   al->http.version.major, al->http.version.minor,

=== modified file 'src/log/FormatHttpdCommon.cc'
--- a/src/log/FormatHttpdCommon.cc	2013-11-11 12:09:44 +0000
+++ b/src/log/FormatHttpdCommon.cc	2014-04-22 02:47:09 +0000
@@ -54,12 +54,18 @@
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %" PRId64 " \
%s%s:%s%s", +    static SBuf method;
+    if (al->_private.method_str)
+        method.assign(al->_private.method_str);
+    else
+        method = al->http.method.image();
+
+    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" \
PRId64 " %s%s:%s%s",  clientip,
                   user_ident ? user_ident : dash_str,
                   user_auth ? user_auth : dash_str,
                   Time::FormatHttpd(squid_curtime),
-                  al->_private.method_str,
+                  SQUIDSBUFPRINT(method),
                   al->url,
                   AnyP::ProtocolType_str[al->http.version.protocol],
                   al->http.version.major, al->http.version.minor,

=== modified file 'src/log/FormatSquidNative.cc'
--- a/src/log/FormatSquidNative.cc	2014-03-30 12:00:34 +0000
+++ b/src/log/FormatSquidNative.cc	2014-04-22 02:47:09 +0000
@@ -70,7 +70,13 @@
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    logfilePrintf(logfile, "%9ld.%03d %6d %s %s%s/%03d %" PRId64 " %s %s %s %s%s/%s \
%s%s", +    static SBuf method;
+    if (al->_private.method_str)
+        method.assign(al->_private.method_str);
+    else
+        method = al->http.method.image();
+
+    logfilePrintf(logfile, "%9ld.%03d %6d %s %s%s/%03d %" PRId64 " " SQUIDSBUFPH " \
%s %s %s%s/%s %s%s",  (long int) current_time.tv_sec,
                   (int) current_time.tv_usec / 1000,
                   al->cache.msec,
@@ -79,7 +85,7 @@
                   al->http.statusSfx(),
                   al->http.code,
                   al->http.clientReplySz.messageTotal(),
-                  al->_private.method_str,
+                  SQUIDSBUFPRINT(method),
                   al->url,
                   user ? user : dash_str,
                   al->hier.ping.timedout ? "TIMEOUT_" : "",

=== modified file 'src/log/access_log.cc'
--- a/src/log/access_log.cc	2013-10-25 00:13:46 +0000
+++ b/src/log/access_log.cc	2014-04-22 02:47:09 +0000
@@ -109,7 +109,7 @@
     else if (al->htcp.opcode)
         al->_private.method_str = al->htcp.opcode;
     else
-        al->_private.method_str = RequestMethodStr(al->http.method);
+        al->_private.method_str = NULL;
 
     if (al->hier.host[0] == '\0')
         xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN);

=== modified file 'src/mgr/ActionParams.cc'
--- a/src/mgr/ActionParams.cc	2013-03-21 21:06:48 +0000
+++ b/src/mgr/ActionParams.cc	2014-04-22 02:47:09 +0000
@@ -33,7 +33,7 @@
 Mgr::ActionParams::pack(Ipc::TypedMsgHdr &msg) const
 {
     msg.putString(httpUri);
-    String foo(httpMethod.image());
+    String foo(httpMethod.image().toString());
     msg.putString(foo);
     msg.putPod(httpFlags);
     msg.putString(httpOrigin);

=== modified file 'src/mk-string-arrays.awk'
--- a/src/mk-string-arrays.awk	2012-01-20 18:55:04 +0000
+++ b/src/mk-string-arrays.awk	2014-04-22 02:47:09 +0000
@@ -21,7 +21,7 @@
 }
 
 # when namespace is encountered store it
-/^namespace [a-zA-Z]+/	{
+/^namespace *[a-zA-Z]+/	{
 	nspath = tolower($2) "/"		# nested folder
 	namespace = $2				# code namespace reconstruct
 	next
@@ -33,7 +33,8 @@
 
 /^[ \t]*[A-Z]/ {
 	split($1, t, ",")			# remove ,
-	Element[++e] = t[1]
+	if (sbuf) Element[++e] = "SBuf(\"" t[1] "\")"
+	else Element[++e] = "\"" t[1] "\""
 	next
 }
 
@@ -49,18 +50,20 @@
 	type = t[1]
         codeSkip = 1
 
+	if (sbuf) print "#include \"SBuf.h\""
 	print "#include \"" nspath type ".h\""
 
 	# if namesapce is not empty ??
 	if (namespace) print "namespace " namespace
 	if (namespace) print "{"
 
-	print "\nconst char *" type "_str[] = {"
+	if (sbuf) print "\nconst SBuf " type "_sb[] = {"
+	else print "\nconst char * " type "_str[] = {"
 	for ( i = 1; i < e; ++i)
 		if (Wrapper[i]) print Wrapper[i]
-		else print "\t\"" Element[i] "\","
+		else print "\t" Element[i] ","
 
-	print "\t\"" Element[i] "\""
+	print "\t" Element[i]
 	print "};"
 	if (namespace) print "}; // namespace " namespace
 	next

=== modified file 'src/peer_select.cc'
--- a/src/peer_select.cc	2014-04-21 15:07:31 +0000
+++ b/src/peer_select.cc	2014-04-22 02:47:09 +0000
@@ -156,9 +156,9 @@
     ps_state *psstate;
 
     if (entry)
-        debugs(44, 3, "peerSelect: " << entry->url()  );
+        debugs(44, 3, *entry << ' ' << entry->url());
     else
-        debugs(44, 3, "peerSelect: " << RequestMethodStr(request->method));
+        debugs(44, 3, request->method);
 
     psstate = new ps_state;
 
@@ -459,7 +459,7 @@
 
     StoreEntry *entry = ps->entry;
     HttpRequest *request = ps->request;
-    debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr(request->method) << " " << \
request->GetHost() << "'"); +    debugs(44, 3, request->method << ' ' << \
request->GetHost());  
     /** If we don't know whether DIRECT is permitted ... */
     if (ps->direct == DIRECT_UNKNOWN) {
@@ -703,7 +703,7 @@
     CachePeer *p;
     HttpRequest *request = ps->request;
     hier_code code = HIER_NONE;
-    debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr(request->method) << " " \
<< request->GetHost()); +    debugs(44, 3, request->method << ' ' << \
request->GetHost());  
     if (ps->direct == DIRECT_YES)
         return;

=== modified file 'src/store_log.cc'
--- a/src/store_log.cc	2013-12-06 23:52:26 +0000
+++ b/src/store_log.cc	2014-04-22 02:47:09 +0000
@@ -80,7 +80,7 @@
         String ctype=(reply->content_type.size() ? reply->content_type.termedBuf() : \
str_unknown);  
         logfileLineStart(storelog);
-        logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d " \
SQUIDSTRINGPH " %" PRId64 "/%" PRId64 " %s %s\n", +        logfilePrintf(storelog, \
"%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d " SQUIDSTRINGPH " %" PRId64 "/%" PRId64 " \
" SQUIDSBUFPH " %s\n",  (int) current_time.tv_sec,
                       (int) current_time.tv_usec / 1000,
                       storeLogTags[tag],
@@ -94,7 +94,7 @@
                       SQUIDSTRINGPRINT(ctype),
                       reply->content_length,
                       e->contentLen(),
-                      RequestMethodStr(mem->method),
+                      SQUIDSBUFPRINT(mem->method.image()),
                       mem->logUri());
         logfileLineEnd(storelog);
     } else {

=== modified file 'src/test_cache_digest.cc'
--- a/src/test_cache_digest.cc	2012-09-01 14:38:36 +0000
+++ b/src/test_cache_digest.cc	2014-04-22 02:47:09 +0000
@@ -103,18 +103,6 @@
 static time_t cur_time = -1;	/* timestamp of the current log entry */
 
 /* copied from url.c */
-const char *RequestMethodStr[] = {
-    "NONE",
-    "GET",
-    "POST",
-    "PUT",
-    "HEAD",
-    "CONNECT",
-    "TRACE",
-    "PURGE"
-};
-
-/* copied from url.c */
 static HttpRequestMethod
 methodStrToId(const char *s)
 {

=== modified file 'src/tests/testHttpRequestMethod.cc'
--- a/src/tests/testHttpRequestMethod.cc	2014-02-21 10:46:19 +0000
+++ b/src/tests/testHttpRequestMethod.cc	2014-04-22 02:47:09 +0000
@@ -84,15 +84,15 @@
 {
     // relaxed RFC-compliance parse HTTP methods are upgraded to correct case
     Config.onoff.relaxed_header_parser = 1;
-    CPPUNIT_ASSERT_EQUAL(String("POST"), \
                String(HttpRequestMethod("POST",NULL).image()));
-    CPPUNIT_ASSERT_EQUAL(String("POST"), \
                String(HttpRequestMethod("pOsT",NULL).image()));
-    CPPUNIT_ASSERT_EQUAL(String("POST"), \
String(HttpRequestMethod("post",NULL).image())); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("POST"), HttpRequestMethod("POST",NULL).image()); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("POST"), HttpRequestMethod("pOsT",NULL).image()); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("POST"), HttpRequestMethod("post",NULL).image());  
     // strict RFC-compliance parse HTTP methods are case sensitive
     Config.onoff.relaxed_header_parser = 0;
-    CPPUNIT_ASSERT_EQUAL(String("POST"), \
                String(HttpRequestMethod("POST",NULL).image()));
-    CPPUNIT_ASSERT_EQUAL(String("pOsT"), \
                String(HttpRequestMethod("pOsT",NULL).image()));
-    CPPUNIT_ASSERT_EQUAL(String("post"), \
String(HttpRequestMethod("post",NULL).image())); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("POST"), HttpRequestMethod("POST",NULL).image()); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("pOsT"), HttpRequestMethod("pOsT",NULL).image()); +    \
CPPUNIT_ASSERT_EQUAL(SBuf("post"), HttpRequestMethod("post",NULL).image());  }
 
 /*

=== modified file 'src/tunnel.cc'
--- a/src/tunnel.cc	2014-04-16 17:40:17 +0000
+++ b/src/tunnel.cc	2014-04-22 02:47:09 +0000
@@ -863,7 +863,7 @@
         }
     }
 
-    debugs(26, 3, HERE << "'" << RequestMethodStr(request->method) << " " << url << \
" " << request->http_ver << "'"); +    debugs(26, 3, request->method << ' ' << url << \
' ' << request->http_ver);  ++statCounter.server.all.requests;
     ++statCounter.server.other.requests;
 


--===============1125395252==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic