Create Http::One:: / Http1:: namespace accordingly.
TODO: rename files once APi shuffling has been completed.
#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
}
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;
}
static void
-prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1Parser &hp)
+prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http1::RequestParser &hp)
{
static char ipbuf[MAX_IPSTRLEN];
* \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
* 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 */
#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;
// 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;
#endif
/// the parser state for current HTTP/1.x input buffer processing
- Http::Http1ParserPointer parser_;
+ Http1::RequestParserPointer parser_;
#if USE_SSL
bool switchedToHttps_;
#include "SquidConfig.h"
void
-Http::Http1Parser::clear()
+Http1::RequestParser::clear()
{
completedState_ = HTTP_PARSE_NONE;
request_parse_status = Http::scNone;
}
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;
* \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
* \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
}
bool
-Http::Http1Parser::parseRequest()
+Http1::RequestParser::parseRequest()
{
// stage 1: locate the request-line
if (completedState_ == HTTP_PARSE_NEW) {
#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;
-#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"
#include "SBuf.h"
namespace Http {
+namespace One {
// Parser states
#define HTTP_PARSE_NONE 0 // nothing. completely unset state.
* \item Request Line (method, URL, protocol, version)
* \item Mime header block
*/
-class Http1Parser : public RefCountable
+class RequestParser : public RefCountable
{
public:
- typedef RefCount<Http1Parser> Pointer;
-
- Http1Parser() { clear(); }
+ RequestParser() { 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.
*/
- 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).
SBuf mimeHeaderBlock_;
};
+} // namespace One
} // namespace Http
#endif /* _SQUID_SRC_HTTP_HTTP1PARSER_H */
namespace Http {
-class Http1Parser;
-typedef RefCount<Http1Parser> Http1ParserPointer;
-
-//class ParserBase;
-//typedef RefCount<Http::ParserBase> HttpParserPointer;
+namespace One {
+class RequestParser;
+typedef RefCount<Http::One::RequestParser> RequestParserPointer;
+} // namespace One
} // namespace Http
+namespace Http1 = Http::One;
+
#endif /* SQUID_SRC_HTTP_FORWARD_H */
globalSetup();
MemBuf input;
- Http::Http1Parser output;
+ Http1::RequestParser output;
input.init();
// TEST: Do we comply with RFC 1945 section 5.1 ?
globalSetup();
MemBuf input;
- Http::Http1Parser output;
+ Http1::RequestParser output;
input.init();
// space padded URL
globalSetup();
MemBuf input;
- Http::Http1Parser output;
+ Http1::RequestParser output;
input.init();
// alternative EOL sequence: NL-only
globalSetup();
MemBuf input;
- Http::Http1Parser output;
+ Http1::RequestParser output;
input.init();
// RFC 2616 : . method
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)
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;