]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup debug output
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 20 May 2014 03:45:00 +0000 (20:45 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 20 May 2014 03:45:00 +0000 (20:45 -0700)
* fix debug display of sections parsed, hiding followup bytes in buffer.

* removes several duplicate dumps of message bytes.

* add mimeHeader() accessor to reduce c_str() usage when accessing mime
  header content.

src/client_side.cc
src/http/Http1Parser.h

index 81f927545d55e5b967c085ab0a9b08fcd20cef2b..a410567d45f16f2f801f65686ebc99f4ba11838e 100644 (file)
@@ -2217,32 +2217,33 @@ parseHttpRequest(ConnStateData *csd, Http1::RequestParser &hp)
         }
     }
 
-    /* We know the whole request is in hp.buf now */
+    /* We know the whole request is in parser now */
+    debugs(11, 2, "HTTP Client " << csd->clientConnection);
+    debugs(11, 2, "HTTP Client REQUEST:\n---------\n" <<
+           hp.method() << " " << hp.requestUri() << " " << hp.messageProtocol() << "\n" <<
+           hp.mimeHeader() <<
+           "\n----------");
 
     /* deny CONNECT via accelerated ports */
     if (hp.method() == Http::METHOD_CONNECT && csd->port && csd->port->flags.accelSurrogate) {
         debugs(33, DBG_IMPORTANT, "WARNING: CONNECT method received on " << csd->port->transport.protocol << " Accelerator port " << csd->port->s.port());
-        /* XXX need a way to say "this many character length string" */
-        debugs(33, DBG_IMPORTANT, "WARNING: for request: " << hp.buf);
+        debugs(33, DBG_IMPORTANT, "WARNING: for request: " << hp.method() << " " << hp.requestUri() << " " << hp.messageProtocol());
         hp.request_parse_status = Http::scMethodNotAllowed;
         return parseHttpRequestAbort(csd, "error:method-not-allowed");
     }
 
     if (hp.method() == Http::METHOD_NONE) {
-        /* XXX need a way to say "this many character length string" */
-        debugs(33, DBG_IMPORTANT, "clientParseRequestMethod: Unsupported method in request '" << hp.buf << "'");
+        debugs(33, DBG_IMPORTANT, "WARNING: Unsupported method: " << hp.method() << " " << hp.requestUri() << " " << hp.messageProtocol());
         hp.request_parse_status = Http::scMethodNotAllowed;
         return parseHttpRequestAbort(csd, "error:unsupported-request-method");
     }
 
-    /*
-     * Process headers after request line
-     * TODO: Use httpRequestParse here.
-     */
-    debugs(33, 3, Raw("req_hdr", hp.rawHeaderBuf(), hp.headerBlockSize()));
-    debugs(33, 3, "prefix_sz = " << hp.messageHeaderSize() <<
+    // Process headers after request line
+    debugs(33, 3, "complete request received. " <<
+           "prefix_sz = " << hp.messageHeaderSize() <<
            ", request-line-size=" << hp.firstLineSize() <<
-           ", mime-header-size=" << hp.headerBlockSize());
+           ", mime-header-size=" << hp.headerBlockSize() <<
+           "mime header block:\n" << hp.mimeHeader() << "\n----------");
 
     /* Ok, all headers are received */
     ClientHttpRequest *http = new ClientHttpRequest(csd);
@@ -2260,8 +2261,6 @@ parseHttpRequest(ConnStateData *csd, Http1::RequestParser &hp)
                      clientReplyStatus, newServer, clientSocketRecipient,
                      clientSocketDetach, newClient, tempBuffer);
 
-    debugs(33, 5, "parseHttpRequest: Request Header is\n" << hp.rawHeaderBuf());
-
     /* set url */
     const char *url = SBuf(hp.requestUri()).c_str();
 
@@ -2303,15 +2302,6 @@ parseHttpRequest(ConnStateData *csd, Http1::RequestParser &hp)
         strcpy(http->uri, url);
     }
 
-    debugs(33, 5, "parseHttpRequest: Complete request received");
-
-    // XXX: crop this dump at the end of headers. No need for extras
-    debugs(11, 2, "HTTP Client " << csd->clientConnection);
-    debugs(11, 2, "HTTP Client REQUEST:\n---------\n" <<
-           hp.method() << " " << hp.requestUri() << " " << hp.messageProtocol() << "\n" <<
-           hp.rawHeaderBuf() <<
-           "\n----------");
-
     result->flags.parsed_ok = 1;
     return result;
 }
@@ -2576,7 +2566,7 @@ clientProcessRequest(ConnStateData *conn, Http1::RequestParser &hp, ClientSocket
     /* compile headers */
     if (http_ver.major >= 1 && !request->parseHeader(hp)) {
         clientStreamNode *node = context->getClientReplyContext();
-        debugs(33, 5, "Failed to parse request headers:\n" << hp.rawHeaderBuf());
+        debugs(33, 5, "Failed to parse request headers:\n" << hp.mimeHeader());
         conn->quitAfterError(request.getRaw());
         // setLogUri should called before repContext->setReplyToError
         setLogUri(http, http->uri,  true);
index a863ad7588bf6c3179b4ff462a27ce42bf38c7fa..5dbf4e52001f178d2f70ebfda46431f057ae33dd 100644 (file)
@@ -69,6 +69,9 @@ public:
     int64_t messageHeaderSize() const {return firstLineSize() + headerBlockSize();}
 
     /// buffer containing HTTP mime headers, excluding message first-line.
+    const SBuf mimeHeader() const {return mimeHeaderBlock_;}
+
+    /// char* version of mimeHeader()
     const char *rawHeaderBuf() {return mimeHeaderBlock_.c_str();}
 
     /// attempt to parse a message from the buffer