tests/testEvent \
tests/testEventLoop \
tests/test_http_range \
- tests/testHttpParser \
+ tests/testHttp1Parser \
tests/testHttpReply \
tests/testHttpRequest \
tests/testStore \
tests_test_http_range_DEPENDENCIES = \
$(SQUID_CPPUNIT_LA)
-tests_testHttpParser_SOURCES = \
+tests_testHttp1Parser_SOURCES = \
Debug.h \
MemBuf.cc \
MemBuf.h \
tests/stub_HelperChildConfig.cc \
tools.h \
tests/stub_tools.cc \
- tests/testHttpParser.cc \
- tests/testHttpParser.h \
+ tests/testHttp1Parser.cc \
+ tests/testHttp1Parser.h \
tests/testMain.cc \
tests/stub_time.cc \
wordlist.h \
wordlist.cc
-nodist_tests_testHttpParser_SOURCES = \
+nodist_tests_testHttp1Parser_SOURCES = \
$(TESTSOURCES)
-tests_testHttpParser_LDADD= \
+tests_testHttp1Parser_LDADD= \
http/libsquid-http.la \
anyp/libanyp.la \
SquidConfig.o \
$(SQUID_CPPUNIT_LIBS) \
$(COMPAT_LIB) \
$(XTRA_LIBS)
-tests_testHttpParser_LDFLAGS = $(LIBADD_DL)
-tests_testHttpParser_DEPENDENCIES = \
+tests_testHttp1Parser_LDFLAGS = $(LIBADD_DL)
+tests_testHttp1Parser_DEPENDENCIES = \
$(SQUID_CPPUNIT_LA)
## Tests of the HttpRequest module.
#endif
static CTCB clientLifetimeTimeout;
static ClientSocketContext *parseHttpRequestAbort(ConnStateData * conn, const char *uri);
-static ClientSocketContext *parseHttpRequest(ConnStateData *, const HttpParserPointer &, HttpRequestMethod *);
+static ClientSocketContext *parseHttpRequest(ConnStateData *, const Http::Http1ParserPointer &, HttpRequestMethod *);
#if USE_IDENT
static IDCB clientIdentDone;
#endif
* \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 HttpParser
+ * \param[in] hp an Http::Http1Parser
* \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
* a ClientSocketContext structure on success or failure.
*/
static ClientSocketContext *
-parseHttpRequest(ConnStateData *csd, const HttpParserPointer &hp, HttpRequestMethod * method_p)
+parseHttpRequest(ConnStateData *csd, const Http::Http1ParserPointer &hp, HttpRequestMethod * method_p)
{
char *req_hdr = NULL;
char *end;
#endif // USE_SSL
static void
-clientProcessRequest(ConnStateData *conn, const HttpParserPointer &hp, ClientSocketContext *context, const HttpRequestMethod& method)
+clientProcessRequest(ConnStateData *conn, const Http::Http1ParserPointer &hp, ClientSocketContext *context, const HttpRequestMethod& method)
{
ClientHttpRequest *http = context->http;
HttpRequest::Pointer request;
// a) dont have one already
// b) have completed the previous request parsing already
if (!parser_ || parser_->isDone())
- parser_ = new HttpParser(in.buf, in.notYetUsed);
+ parser_ = new Http::Http1Parser(in.buf, in.notYetUsed);
else // update the buffer space being parsed
parser_->bufsiz = in.notYetUsed;
Auth::UserRequest::Pointer auth_;
#endif
- HttpParserPointer parser_;
-
- // XXX: CBDATA plays with public/private and leaves the following 'private' fields all public... :(
+ /// the parser state for current HTTP/1.x input buffer processing
+ Http::Http1ParserPointer parser_;
#if USE_SSL
bool switchedToHttps_;
#include "SquidConfig.h"
void
-HttpParser::clear()
+Http::Http1Parser::clear()
{
completedState_ = HTTP_PARSE_NONE;
request_parse_status = Http::scNone;
}
void
-HttpParser::reset(const char *aBuf, int len)
+Http::Http1Parser::reset(const char *aBuf, int len)
{
clear(); // empty the state.
completedState_ = HTTP_PARSE_NEW;
}
int
-HttpParser::parseRequestFirstLine()
+Http::Http1Parser::parseRequestFirstLine()
{
int second_word = -1; // track the suspected URI start
int first_whitespace = -1, last_whitespace = -1; // track the first and last SP byte
}
bool
-HttpParser::parseRequest()
+Http::Http1Parser::parseRequest()
{
PROF_start(HttpParserParseReqLine);
int retcode = parseRequestFirstLine();
-#ifndef _SQUID_SRC_HTTPPARSER_H
-#define _SQUID_SRC_HTTPPARSER_H
+#ifndef _SQUID_SRC_Http1Parser_H
+#define _SQUID_SRC_Http1Parser_H
#include "base/RefCount.h"
#include "http/ProtocolVersion.h"
#include "http/StatusCode.h"
+namespace Http {
+
// Parser states
#define HTTP_PARSE_NONE 0 // nothing. completely unset state.
#define HTTP_PARSE_NEW 1 // initialized, but nothing usefully parsed yet.
* \item Request Line (method, URL, protocol, version)
* \item Mime header block
*/
-class HttpParser : public RefCountable
+class Http1Parser : public RefCountable
{
public:
- typedef RefCount<HttpParser> Pointer;
+ typedef RefCount<Http1Parser> Pointer;
- HttpParser() { clear(); }
+ Http1Parser() { clear(); }
/** Initialize a new parser.
* Presenting it a buffer to work on and the current length of available
* NOTE: This is *not* the buffer size, just the parse-able data length.
* The parse routines may be called again later with more data.
*/
- HttpParser(const char *aBuf, int len) { reset(aBuf,len); };
+ Http1Parser(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).
AnyP::ProtocolVersion msgProtocol_;
};
-#endif /* _SQUID_SRC_HTTPPARSER_H */
+} // namespace Http
+
+#endif /* _SQUID_SRC_Http1Parser_H */
#define private public
#define protected public
-#include "testHttpParser.h"
+#include "testHttp1Parser.h"
#include "http/Http1Parser.h"
#include "Mem.h"
#include "MemBuf.h"
#include "SquidConfig.h"
-#include "testHttpParser.h"
+#include "testHttp1Parser.h"
-CPPUNIT_TEST_SUITE_REGISTRATION( testHttpParser );
+CPPUNIT_TEST_SUITE_REGISTRATION( testHttp1Parser );
void
-testHttpParser::globalSetup()
+testHttp1Parser::globalSetup()
{
static bool setup_done = false;
if (setup_done)
}
void
-testHttpParser::testParseRequestLineProtocols()
+testHttp1Parser::testParseRequestLineProtocols()
{
// ensure MemPools etc exist
globalSetup();
MemBuf input;
- HttpParser output;
+ Http::Http1Parser output;
input.init();
// TEST: Do we comply with RFC 1945 section 5.1 ?
}
void
-testHttpParser::testParseRequestLineStrange()
+testHttp1Parser::testParseRequestLineStrange()
{
// ensure MemPools etc exist
globalSetup();
MemBuf input;
- HttpParser output;
+ Http::Http1Parser output;
input.init();
// space padded URL
}
void
-testHttpParser::testParseRequestLineTerminators()
+testHttp1Parser::testParseRequestLineTerminators()
{
// ensure MemPools etc exist
globalSetup();
MemBuf input;
- HttpParser output;
+ Http::Http1Parser output;
input.init();
// alternative EOL sequence: NL-only
}
void
-testHttpParser::testParseRequestLineMethods()
+testHttp1Parser::testParseRequestLineMethods()
{
// ensure MemPools etc exist
globalSetup();
MemBuf input;
- HttpParser output;
+ Http::Http1Parser output;
input.init();
// RFC 2616 : . method
}
void
-testHttpParser::testParseRequestLineInvalid()
+testHttp1Parser::testParseRequestLineInvalid()
{
// ensure MemPools etc exist
globalSetup();
MemBuf input;
- HttpParser output;
+ Http::Http1Parser output;
input.init();
// no method (but in a form which is ambiguous with HTTP/0.9 simple-request)
}
void
-testHttpParser::testDripFeed()
+testHttp1Parser::testDripFeed()
{
// Simulate a client drip-feeding Squid a few bytes at a time.
// extend the size of the buffer from 0 bytes to full request length
int reqLineEnd = mb.contentSize();
mb.append("\n", 1);
- HttpParser hp(mb.content(), 0);
+ Http::Http1Parser hp(mb.content(), 0);
// only relaxed parser accepts the garbage whitespace
Config.onoff.relaxed_header_parser = 1;
-#ifndef SQUID_SRC_TESTS_TESTHTTPPARSER_H
-#define SQUID_SRC_TESTS_TESTHTTPPARSER_H
+#ifndef SQUID_SRC_TESTS_TESTHTTP1PARSER_H
+#define SQUID_SRC_TESTS_TESTHTTP1PARSER_H
#include <cppunit/extensions/HelperMacros.h>
-class testHttpParser : public CPPUNIT_NS::TestFixture
+class testHttp1Parser : public CPPUNIT_NS::TestFixture
{
- CPPUNIT_TEST_SUITE( testHttpParser );
+ CPPUNIT_TEST_SUITE( testHttp1Parser );
CPPUNIT_TEST( testParseRequestLineTerminators );
CPPUNIT_TEST( testParseRequestLineMethods );
CPPUNIT_TEST( testParseRequestLineProtocols );