Kea 2.7.5
response_parser.h
Go to the documentation of this file.
1// Copyright (C) 2017-2023 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_RESPONSE_PARSER_H
8#define HTTP_RESPONSE_PARSER_H
9
11#include <http/response.h>
12#include <boost/shared_ptr.hpp>
13
14namespace isc {
15namespace http {
16
17class HttpResponseParser;
18
20typedef boost::shared_ptr<HttpResponseParser> HttpResponseParserPtr;
21
44public:
45
48
49
51 static const int RECEIVE_START_ST = SM_DERIVED_STATE_MIN + 101;
52
54 static const int HTTP_VERSION_H_ST = SM_DERIVED_STATE_MIN + 102;
55
57 static const int HTTP_VERSION_T1_ST = SM_DERIVED_STATE_MIN + 103;
58
60 static const int HTTP_VERSION_T2_ST = SM_DERIVED_STATE_MIN + 104;
61
63 static const int HTTP_VERSION_P_ST = SM_DERIVED_STATE_MIN + 105;
64
67
70
73
76
79
82
84 static const int HTTP_STATUS_CODE_ST = SM_DERIVED_STATE_MIN + 112;
85
88
90 static const int HTTP_PHRASE_ST = SM_DERIVED_STATE_MIN + 114;
91
94
96
99 static const int HEADER_LWS_ST = SM_DERIVED_STATE_MIN + 117;
100
102 static const int HEADER_NAME_ST = SM_DERIVED_STATE_MIN + 118;
103
106
108 static const int HEADER_VALUE_ST = SM_DERIVED_STATE_MIN + 120;
109
112
115
117 static const int HTTP_BODY_ST = SM_DERIVED_STATE_MIN + 123;
118
120
128 explicit HttpResponseParser(HttpResponse& response);
129
135 void initModel();
136
137private:
138
140 virtual void defineStates();
141
144
145
147 void receiveStartHandler();
148
155 void versionHTTPHandler(const char expected_letter,
156 const unsigned int next_state);
157
170 void numberStartHandler(const unsigned int next_state,
171 const std::string& number_name,
172 unsigned int* const storage);
173
188 void numberHandler(const char following_character,
189 const unsigned int next_state,
190 const std::string& number_name,
191 unsigned int* const storage);
192
194 void phraseStartHandler();
195
197 void phraseHandler();
198
211 void expectingNewLineHandler(const unsigned int next_state);
212
214 void headerLineStartHandler();
215
217 void headerLwsHandler();
218
220 void headerNameHandler();
221
223 void spaceBeforeHeaderValueHandler();
224
226 void headerValueHandler();
227
229 void bodyHandler();
230
232
234 HttpResponse& response_;
235
237 HttpResponseContextPtr context_;
238};
239
240} // end of namespace isc::http
241} // end of namespace isc
242
243#endif
Base class for the HTTP message parsers.
A generic parser for HTTP responses.
static const int EXPECTING_NEW_LINE1_ST
Parsing first new line (after HTTP status phrase).
HttpResponseParser(HttpResponse &response)
Constructor.
static const int HTTP_VERSION_T1_ST
Parsing first occurrence of "T" in "HTTP".
static const int HEADER_VALUE_ST
Parsing header value.
static const int HTTP_VERSION_MAJOR_START_ST
Starting to parse major HTTP version number.
static const int HTTP_BODY_ST
Parsing body of a HTTP message.
static const int HTTP_VERSION_T2_ST
Parsing second occurrence of "T" in "HTTP".
static const int HEADER_NAME_ST
Parsing header name.
void initModel()
Initialize the state model for parsing.
static const int HTTP_VERSION_H_ST
Parsing letter "H" of "HTTP".
static const int HTTP_STATUS_CODE_START_ST
Starting to parse HTTP status code.
static const int EXPECTING_NEW_LINE3_ST
Expecting second new line marking end of HTTP headers.
static const int RECEIVE_START_ST
State indicating a beginning of parsing.
static const int HTTP_VERSION_P_ST
Parsing letter "P" in "HTTP".
static const int HTTP_VERSION_MINOR_START_ST
Starting to parse minor HTTP version number.
static const int HEADER_LINE_START_ST
static const int HTTP_PHRASE_ST
Parsing HTTP status phrase.
static const int HEADER_LWS_ST
Parsing LWS (Linear White Space), i.e.
static const int SPACE_BEFORE_HEADER_VALUE_ST
Parsing space before header value.
static const int HTTP_VERSION_MAJOR_ST
Parsing major HTTP version number.
static const int HTTP_STATUS_CODE_ST
Parsing HTTP status code.
static const int EXPECTING_NEW_LINE2_ST
Expecting new line after parsing header value.
static const int HTTP_VERSION_MINOR_ST
Parsing minor HTTP version number.
static const int HTTP_VERSION_SLASH_ST
Parsing slash character in "HTTP/Y.X".
static const int HTTP_PHRASE_START_ST
Starting to parse HTTP status phrase.
Represents HTTP response message.
Definition response.h:98
static const int SM_DERIVED_STATE_MIN
Value at which custom states in a derived class should begin.
boost::shared_ptr< HttpResponseParser > HttpResponseParserPtr
Pointer to the HttpResponseParser.
boost::shared_ptr< HttpResponseContext > HttpResponseContextPtr
Pointer to the HttpResponseContext.
Defines the logger used by the top-level component of kea-lfc.