]> git.ipfire.org Git - thirdparty/squid.git/blame - src/http/one/RequestParser.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / http / one / RequestParser.h
CommitLineData
eac61ce1 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
eac61ce1
AJ
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
c99510dd
AJ
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#include "http/StatusCode.h"
15
16namespace Http {
17namespace One {
18
19/** HTTP/1.x protocol request parser
20 *
21 * Works on a raw character I/O buffer and tokenizes the content into
22 * the major CRLF delimited segments of an HTTP/1 request message:
23 *
24 * \item request-line (method, URL, protocol, version)
25 * \item mime-header (set of RFC2616 syntax header fields)
26 */
27class RequestParser : public Http1::Parser
28{
c99510dd 29public:
f9688132
AJ
30 RequestParser();
31 virtual ~RequestParser() {}
32
c99510dd 33 /* Http::One::Parser API */
f9688132 34 virtual void clear() {*this = RequestParser();}
8e677087 35 virtual Http1::Parser::size_type firstLineSize() const {return req.end - req.start + 1;}
c99510dd
AJ
36 virtual bool parse(const SBuf &aBuf);
37
38 /// the HTTP method if this is a request message
39 const HttpRequestMethod & method() const {return method_;}
40
41 /// the request-line URI if this is a request message, or an empty string.
42 const SBuf &requestUri() const {return uri_;}
43
44 /** HTTP status code to be used on the invalid-request error page.
45 * Http::scNone indicates incomplete parse,
46 * Http::scOkay indicates no error.
47 */
48 Http::StatusCode request_parse_status;
49
50private:
51 void skipGarbageLines();
52 int parseRequestFirstLine();
53
a4c74dd8 54 /// Offsets for pieces of the (HTTP request) Request-Line as per RFC 7230 section 3.1.1.
c99510dd
AJ
55 /// only valid before and during parse stage HTTP_PARSE_FIRST
56 struct request_offsets {
57 int start, end;
58 int m_start, m_end; // method
59 int u_start, u_end; // url
60 int v_start, v_end; // version (full text)
61 } req;
62
63 /// what request method has been found on the first line
64 HttpRequestMethod method_;
65
f9688132 66 /// raw copy of the original client reqeust-line URI field
c99510dd
AJ
67 SBuf uri_;
68};
69
70} // namespace One
71} // namespace Http
72
73#endif /* _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H */
f53969cc 74