RequestParser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H
10 #define _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H
11 
12 #include "http/one/Parser.h"
13 #include "http/RequestMethod.h"
14 
15 namespace Parser {
16 class Tokenizer;
17 }
18 
19 namespace Http {
20 namespace One {
21 
31 {
32 public:
33  RequestParser() = default;
34  RequestParser(bool preserveParsed) { preserveParsed_ = preserveParsed; }
35  RequestParser(const RequestParser &) = default;
36  RequestParser &operator =(const RequestParser &) = default;
37  RequestParser(RequestParser &&) = default;
38  RequestParser &operator =(RequestParser &&) = default;
39  virtual ~RequestParser() {}
40 
41  /* Http::One::Parser API */
42  virtual void clear() {*this = RequestParser();}
44  virtual bool parse(const SBuf &aBuf);
45 
47  const HttpRequestMethod & method() const {return method_;}
48 
50  const SBuf &requestUri() const {return uri_;}
51 
53  const SBuf &parsed() const { Must(preserveParsed_); return parsed_; }
54 
55 private:
56  void skipGarbageLines();
59  bool doParse(const SBuf &aBuf);
60 
61  /* all these return false and set parseStatusCode on parsing failures */
65  bool skipDelimiter(const size_t count, const char *where);
67 
68  bool http0() const {return !msgProtocol_.major;}
69  static const CharacterSet &RequestTargetCharacters();
70 
73 
76 
80  bool preserveParsed_ = false;
81 };
82 
83 } // namespace One
84 } // namespace Http
85 
86 #endif /* _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H */
87 
AnyP::ProtocolVersion msgProtocol_
what protocol label has been found in the first line (if any)
Definition: Parser.h:152
bool parseMethodField(Http1::Tokenizer &)
bool skipTrailingCrs(Http1::Tokenizer &tok)
Parse CRs at the end of request-line, just before the terminating LF.
Definition: SBuf.h:87
SBuf::size_type size_type
Definition: Parser.h:42
const SBuf & requestUri() const
the request-line URI if this is a request message, or an empty string.
Definition: RequestParser.h:50
bool parseUriField(Http1::Tokenizer &)
bool parseHttpVersionField(Http1::Tokenizer &)
const HttpRequestMethod & method() const
the HTTP method if this is a request message
Definition: RequestParser.h:47
virtual bool parse(const SBuf &aBuf)
unsigned int major
major version number
RequestParser & operator=(const RequestParser &)=default
bool preserveParsed_
whether to accumulate parsed bytes (in parsed_)
Definition: RequestParser.h:80
optimized set of C chars, with quick membership test and merge support
Definition: CharacterSet.h:17
Definition: parse.c:160
virtual Http1::Parser::size_type firstLineSize() const
size in bytes of the first line including CRLF terminator
HttpRequestMethod method_
what request method has been found on the first line
Definition: RequestParser.h:72
#define Must(cond)
Definition: TextException.h:89
bool skipDelimiter(const size_t count, const char *where)
RequestParser(bool preserveParsed)
Definition: RequestParser.h:34
bool doParse(const SBuf &aBuf)
called from parse() to do the parsing
const SBuf & parsed() const
the accumulated parsed bytes
Definition: RequestParser.h:53
SBuf uri_
raw copy of the original client request-line URI field
Definition: RequestParser.h:75
static const CharacterSet & RequestTargetCharacters()
characters which Squid will accept in the HTTP request-target (URI)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors