From: Amos Jeffries Date: Sat, 4 Jan 2014 13:05:51 +0000 (-0800) Subject: Audit followup: rename Http1Parser Http1::RequestParser X-Git-Tag: merge-candidate-3-v1~506^2~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b51ee7bcd06625428c9d4bc21ed94f5fc4db059;p=thirdparty%2Fsquid.git Audit followup: rename Http1Parser Http1::RequestParser Create Http::One:: / Http1:: namespace accordingly. TODO: rename files once APi shuffling has been completed. --- diff --git a/src/client_side.cc b/src/client_side.cc index 9a6d8c0f3c..cff753a68c 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -206,7 +206,7 @@ static IOACB httpsAccept; #endif static CTCB clientLifetimeTimeout; static ClientSocketContext *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static ClientSocketContext *parseHttpRequest(ConnStateData *, Http::Http1Parser &); +static ClientSocketContext *parseHttpRequest(ConnStateData *, Http1::RequestParser &); #if USE_IDENT static IDCB clientIdentDone; #endif @@ -2080,7 +2080,7 @@ setLogUri(ClientHttpRequest * http, char const *uri, bool cleanUrl) } static void -prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1Parser &hp) +prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http1::RequestParser &hp) { int vhost = conn->port->vhost; int vport = conn->port->vport; @@ -2172,7 +2172,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1 } static void -prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1Parser &hp) +prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http1::RequestParser &hp) { static char ipbuf[MAX_IPSTRLEN]; @@ -2205,7 +2205,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1 * \note Sets result->flags.parsed_ok to 0 if failed to parse the request, * to 1 if the request was correctly parsed. * \param[in] csd a ConnStateData. The caller must make sure it is not null - * \param[in] hp an Http::Http1Parser + * \param[in] hp an Http1::RequestParser * \param[out] mehtod_p will be set as a side-effect of the parsing. * Pointed-to value will be set to Http::METHOD_NONE in case of * parsing failure @@ -2214,7 +2214,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1 * a ClientSocketContext structure on success or failure. */ static ClientSocketContext * -parseHttpRequest(ConnStateData *csd, Http::Http1Parser &hp) +parseHttpRequest(ConnStateData *csd, Http1::RequestParser &hp) { /* NP: don't be tempted to move this down or remove again. * It's the only DDoS protection old-String has against long URL */ @@ -2591,7 +2591,7 @@ bool ConnStateData::serveDelayedError(ClientSocketContext *context) #endif // USE_SSL static void -clientProcessRequest(ConnStateData *conn, Http::Http1Parser &hp, ClientSocketContext *context) +clientProcessRequest(ConnStateData *conn, Http1::RequestParser &hp, ClientSocketContext *context) { ClientHttpRequest *http = context->http; HttpRequest::Pointer request; @@ -2943,7 +2943,7 @@ ConnStateData::clientParseRequests() // a) dont have one already // b) have completed the previous request parsing already if (!parser_ || parser_->isDone()) - parser_ = new Http::Http1Parser(in.buf, in.notYetUsed); + parser_ = new Http1::RequestParser(in.buf, in.notYetUsed); else // update the buffer space being parsed parser_->bufsiz = in.notYetUsed; diff --git a/src/client_side.h b/src/client_side.h index a198a65527..a5f5cbe012 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -399,7 +399,7 @@ private: #endif /// the parser state for current HTTP/1.x input buffer processing - Http::Http1ParserPointer parser_; + Http1::RequestParserPointer parser_; #if USE_SSL bool switchedToHttps_; diff --git a/src/http/Http1Parser.cc b/src/http/Http1Parser.cc index 0b16f7f526..90b7ec2247 100644 --- a/src/http/Http1Parser.cc +++ b/src/http/Http1Parser.cc @@ -7,7 +7,7 @@ #include "SquidConfig.h" void -Http::Http1Parser::clear() +Http1::RequestParser::clear() { completedState_ = HTTP_PARSE_NONE; request_parse_status = Http::scNone; @@ -24,7 +24,7 @@ Http::Http1Parser::clear() } void -Http::Http1Parser::reset(const char *aBuf, int len) +Http1::RequestParser::reset(const char *aBuf, int len) { clear(); // empty the state. completedState_ = HTTP_PARSE_NEW; @@ -52,7 +52,7 @@ Http::Http1Parser::reset(const char *aBuf, int len) * \return true if garbage whitespace was found */ bool -Http::Http1Parser::skipGarbageLines() +Http1::RequestParser::skipGarbageLines() { req.start = parseOffset_; // avoid re-parsing any portion we managed to complete @@ -105,7 +105,7 @@ Http::Http1Parser::skipGarbageLines() * \retval 0 more data is needed to complete the parse */ int -Http::Http1Parser::parseRequestFirstLine() +Http1::RequestParser::parseRequestFirstLine() { int second_word = -1; // track the suspected URI start int first_whitespace = -1, last_whitespace = -1; // track the first and last SP byte @@ -315,7 +315,7 @@ Http::Http1Parser::parseRequestFirstLine() } bool -Http::Http1Parser::parseRequest() +Http1::RequestParser::parseRequest() { // stage 1: locate the request-line if (completedState_ == HTTP_PARSE_NEW) { @@ -369,7 +369,7 @@ Http::Http1Parser::parseRequest() #define GET_HDR_SZ 1024 char * -Http::Http1Parser::getHeaderField(const char *name) +Http1::RequestParser::getHeaderField(const char *name) { LOCAL_ARRAY(char, header, GET_HDR_SZ); const char *p = NULL; diff --git a/src/http/Http1Parser.h b/src/http/Http1Parser.h index bb6a6855f5..055afa9eff 100644 --- a/src/http/Http1Parser.h +++ b/src/http/Http1Parser.h @@ -1,5 +1,5 @@ -#ifndef _SQUID_SRC_HTTP_HTTP1PARSER_H -#define _SQUID_SRC_HTTP_HTTP1PARSER_H +#ifndef _SQUID_SRC_HTTP_ONEREQUESTPARSER_H +#define _SQUID_SRC_HTTP_ONEREQUESTPARSER_H #include "base/RefCount.h" #include "http/forward.h" @@ -9,6 +9,7 @@ #include "SBuf.h" namespace Http { +namespace One { // Parser states #define HTTP_PARSE_NONE 0 // nothing. completely unset state. @@ -25,12 +26,10 @@ namespace Http { * \item Request Line (method, URL, protocol, version) * \item Mime header block */ -class Http1Parser : public RefCountable +class RequestParser : public RefCountable { public: - typedef RefCount Pointer; - - Http1Parser() { clear(); } + RequestParser() { clear(); } /** Initialize a new parser. * Presenting it a buffer to work on and the current length of available @@ -38,7 +37,7 @@ public: * NOTE: This is *not* the buffer size, just the parse-able data length. * The parse routines may be called again later with more data. */ - Http1Parser(const char *aBuf, int len) { reset(aBuf,len); }; + RequestParser(const char *aBuf, int len) { reset(aBuf,len); }; /// Set this parser back to a default state. /// Will DROP any reference to a buffer (does not free). @@ -131,6 +130,7 @@ private: SBuf mimeHeaderBlock_; }; +} // namespace One } // namespace Http #endif /* _SQUID_SRC_HTTP_HTTP1PARSER_H */ diff --git a/src/http/forward.h b/src/http/forward.h index 80258dc7ed..adee4c3e85 100644 --- a/src/http/forward.h +++ b/src/http/forward.h @@ -15,12 +15,13 @@ typedef RefCount HttpReplyPointer; namespace Http { -class Http1Parser; -typedef RefCount Http1ParserPointer; - -//class ParserBase; -//typedef RefCount HttpParserPointer; +namespace One { +class RequestParser; +typedef RefCount RequestParserPointer; +} // namespace One } // namespace Http +namespace Http1 = Http::One; + #endif /* SQUID_SRC_HTTP_FORWARD_H */ diff --git a/src/tests/testHttp1Parser.cc b/src/tests/testHttp1Parser.cc index 86acac2d92..8e38503f77 100644 --- a/src/tests/testHttp1Parser.cc +++ b/src/tests/testHttp1Parser.cc @@ -34,7 +34,7 @@ testHttp1Parser::testParseRequestLineProtocols() globalSetup(); MemBuf input; - Http::Http1Parser output; + Http1::RequestParser output; input.init(); // TEST: Do we comply with RFC 1945 section 5.1 ? @@ -384,7 +384,7 @@ testHttp1Parser::testParseRequestLineStrange() globalSetup(); MemBuf input; - Http::Http1Parser output; + Http1::RequestParser output; input.init(); // space padded URL @@ -473,7 +473,7 @@ testHttp1Parser::testParseRequestLineTerminators() globalSetup(); MemBuf input; - Http::Http1Parser output; + Http1::RequestParser output; input.init(); // alternative EOL sequence: NL-only @@ -687,7 +687,7 @@ testHttp1Parser::testParseRequestLineMethods() globalSetup(); MemBuf input; - Http::Http1Parser output; + Http1::RequestParser output; input.init(); // RFC 2616 : . method @@ -896,7 +896,7 @@ testHttp1Parser::testParseRequestLineInvalid() globalSetup(); MemBuf input; - Http::Http1Parser output; + Http1::RequestParser output; input.init(); // no method (but in a form which is ambiguous with HTTP/0.9 simple-request) @@ -1184,7 +1184,7 @@ testHttp1Parser::testDripFeed() int reqLineEnd = mb.contentSize(); mb.append("Host: example.com\r\n\r\n.", 22); - Http::Http1Parser hp(mb.content(), 0); + Http1::RequestParser hp(mb.content(), 0); // only relaxed parser accepts the garbage whitespace Config.onoff.relaxed_header_parser = 1;