VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
http_parser.h
1 // Copyright (c) 2018, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
10 #ifndef _UGCS_VSM_HTTP_PARSER_H_
11 #define _UGCS_VSM_HTTP_PARSER_H_
12 
13 #include <ugcs/vsm/exception.h>
14 #include <string.h>
15 #include <istream>
16 #include <map>
17 
18 namespace ugcs {
19 namespace vsm {
20 
30 public:
32  bool operator() (const std::string& lhs, const std::string& rhs) const {
33  return strcasecmp(lhs.c_str(), rhs.c_str()) < 0;
34  }
35  };
36 
40  bool
41  Parse(std::istream &in);
42 
44  bool
45  Header_exists(const std::string &name) const;
46 
51  std::string
52  Get_header_value(const std::string &name) const;
53 
56  std::string
57  Get_method() const;
58 
59  std::string parser_error;
60 
61 private:
62  std::map<std::string, std::string, string_compare_ignore_case> header_table;
63  std::string http_method;
64 };
65 
66 } /* namespace vsm */
67 } /* namespace ugcs */
68 
69 #endif /* _UGCS_VSM_HTTP_PARSER_H_ */
std::string Get_method() const
Get HTTP method name.
bool Parse(std::istream &in)
Parse http header from text stream.
bool Header_exists(const std::string &name) const
Check if the header field with the specified name exists.
VSM exceptions definition.
std::string Get_header_value(const std::string &name) const
Get string value of header.
This class implements limited HTTP parser according to RFC7230 Supports:
Definition: http_parser.h:29