My Project
 All Classes Functions Variables Pages
HttpParser.h
1 /*
2  * HttpParser.h
3  *
4  * Created on: Aug 28, 2017
5  * Author: kolban
6  */
7 
8 #ifndef CPP_UTILS_HTTPPARSER_H_
9 #define CPP_UTILS_HTTPPARSER_H_
10 #include <string>
11 #include <map>
12 #include "Socket.h"
13 
14 class HttpParser {
15 public:
16  HttpParser();
17  virtual ~HttpParser();
18  std::string getBody();
19  std::string getHeader(const std::string& name);
20  std::map<std::string, std::string> getHeaders();
21  std::string getMethod();
22  std::string getURL();
23  std::string getVersion();
24  std::string getStatus();
25  std::string getReason();
26  bool hasHeader(const std::string& name);
27  void parse(std::string message);
28  void parse(Socket s);
29  void parseResponse(std::string message);
30 
31 private:
32  std::string m_method;
33  std::string m_url;
34  std::string m_version;
35  std::string m_body;
36  std::string m_status;
37  std::string m_reason;
38  std::map<std::string, std::string> m_headers;
39  void dump();
40  void parseRequestLine(std::string& line);
41  void parseStatusLine(std::string& line);
42 
43 };
44 
45 #endif /* CPP_UTILS_HTTPPARSER_H_ */
bool hasHeader(const std::string &name)
Determine if we have a header of the given name.
Definition: HttpParser.cpp:182
Encapsulate a socket.
Definition: Socket.h:62
std::string getHeader(const std::string &name)
Retrieve the value of the named header.
Definition: HttpParser.cpp:141
void parseResponse(std::string message)
Parse a response message.
Definition: HttpParser.cpp:275
Definition: HttpParser.h:14