From: Amos Jeffries Date: Tue, 20 May 2014 03:45:00 +0000 (-0700) Subject: Cleanup debug output X-Git-Tag: merge-candidate-3-v1~506^2~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d0613b273a03d7c388a97a70cb62dbc0adbd853;p=thirdparty%2Fsquid.git Cleanup debug output * 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. --- diff --git a/src/client_side.cc b/src/client_side.cc index 81f927545d..a410567d45 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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); diff --git a/src/http/Http1Parser.h b/src/http/Http1Parser.h index a863ad7588..5dbf4e5200 100644 --- a/src/http/Http1Parser.h +++ b/src/http/Http1Parser.h @@ -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