Kea 2.5.8
request_parser.h
Go to the documentation of this file.
1// Copyright (C) 2016-2018,2021 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef HTTP_REQUEST_PARSER_H
8#define HTTP_REQUEST_PARSER_H
9
11#include <http/request.h>
12#include <boost/shared_ptr.hpp>
13
14namespace isc {
15namespace http {
16
17class HttpRequestParser;
18
20typedef boost::shared_ptr<HttpRequestParser> HttpRequestParserPtr;
21
55public:
56
59
60
62 static const int RECEIVE_START_ST = SM_DERIVED_STATE_MIN + 1;
63
65 static const int HTTP_METHOD_ST = SM_DERIVED_STATE_MIN + 2;
66
68 static const int HTTP_URI_ST = SM_DERIVED_STATE_MIN + 3;
69
72
75
78
81
84
87
90
93
96
99
102
105 static const int HEADER_LWS_ST = SM_DERIVED_STATE_MIN + 15;
106
108 static const int HEADER_NAME_ST = SM_DERIVED_STATE_MIN + 16;
109
112
114 static const int HEADER_VALUE_ST = SM_DERIVED_STATE_MIN + 18;
115
118
121
123 static const int HTTP_BODY_ST = SM_DERIVED_STATE_MIN + 21;
124
126
127
135 explicit HttpRequestParser(HttpRequest& request);
136
142 void initModel();
143
144private:
145
147 virtual void defineStates();
148
151
152
154 void receiveStartHandler();
155
157 void httpMethodHandler();
158
160 void uriHandler();
161
168 void versionHTTPHandler(const char expected_letter,
169 const unsigned int next_state);
170
182 void versionNumberStartHandler(const unsigned int next_state,
183 unsigned int* storage);
184
197 void versionNumberHandler(const char following_character,
198 const unsigned int next_state,
199 unsigned int* const storage);
200
213 void expectingNewLineHandler(const unsigned int next_state);
214
216 void headerLineStartHandler();
217
219 void headerLwsHandler();
220
222 void headerNameHandler();
223
225 void spaceBeforeHeaderValueHandler();
226
228 void headerValueHandler();
229
231 void bodyHandler();
232
234
236 HttpRequest& request_;
237
239 HttpRequestContextPtr context_;
240};
241
242} // namespace http
243} // namespace isc
244
245#endif // HTTP_REQUEST_PARSER_H
246
Base class for the HTTP message parsers.
A generic parser for HTTP requests.
static const int EXPECTING_NEW_LINE1_ST
Parsing first new line (after HTTP version number).
static const int HTTP_URI_ST
Parsing URI.
static const int HTTP_VERSION_MAJOR_ST
Parsing major HTTP version number.
static const int HTTP_VERSION_SLASH_ST
Parsing slash character in "HTTP/Y.X".
static const int SPACE_BEFORE_HEADER_VALUE_ST
Parsing space before header value.
static const int HTTP_BODY_ST
Parsing body of a HTTP message.
static const int HTTP_VERSION_MAJOR_START_ST
Starting to parse major HTTP version number.
static const int EXPECTING_NEW_LINE3_ST
Expecting second new line marking end of HTTP headers.
static const int HEADER_NAME_ST
Parsing header name.
static const int RECEIVE_START_ST
State indicating a beginning of parsing.
void initModel()
Initialize the state model for parsing.
static const int HEADER_LWS_ST
Parsing LWS (Linear White Space), i.e.
static const int HTTP_VERSION_MINOR_ST
Parsing minor HTTP version number.
static const int HEADER_LINE_START_ST
Starting to parse a header line.
static const int HTTP_VERSION_H_ST
Parsing letter "H" of "HTTP".
static const int HTTP_VERSION_MINOR_START_ST
Starting to parse minor HTTP version number.
static const int HTTP_METHOD_ST
Parsing HTTP method, e.g. GET, POST etc.
static const int HEADER_VALUE_ST
Parsing header value.
static const int EXPECTING_NEW_LINE2_ST
Expecting new line after parsing header value.
static const int HTTP_VERSION_P_ST
Parsing letter "P" in "HTTP".
static const int HTTP_VERSION_T2_ST
Parsing second occurrence of "T" in "HTTP".
static const int HTTP_VERSION_T1_ST
Parsing first occurrence of "T" in "HTTP".
Represents HTTP request message.
Definition: request.h:57
static const int SM_DERIVED_STATE_MIN
Value at which custom states in a derived class should begin.
Definition: state_model.h:285
boost::shared_ptr< HttpRequestParser > HttpRequestParserPtr
Pointer to the HttpRequestParser.
boost::shared_ptr< HttpRequestContext > HttpRequestContextPtr
Pointer to the HttpRequestContext.
Defines the logger used by the top-level component of kea-lfc.