1 #ifndef HTTP_HEADER_P_H
2 #define HTTP_HEADER_P_H
4 #include "api/api_global.h"
16 HttpHeader(const std::string& s);
17 virtual ~HttpHeader(void);
19 // HttpHeader interface
22 // header field=>value access
23 bool ContainsKey(const std::string& key) const;
24 std::string GetValue(const std::string& key) const;
25 void RemoveField(const std::string& key);
26 void SetField(const std::string& key, const std::string& value);
28 // get formatted header string
29 virtual std::string ToString(void) const;
31 // query HTTP version used
32 int GetMajorVersion(void) const;
33 int GetMinorVersion(void) const;
35 // see if header was parsed OK
36 bool IsValid(void) const;
40 void Parse(const std::string& s);
41 virtual bool ParseLine(const std::string& line, int lineNumber);
42 void SetValid(bool ok);
43 void SetVersion(int major, int minor);
47 std::map<std::string, std::string> m_fields;
49 bool m_isValid; // should usually be true, only false if error processing a header line
54 class HttpRequestHeader : public HttpHeader {
58 HttpRequestHeader(const std::string& method, // "GET", "PUT", etc
59 const std::string& resource, // filename
60 int majorVersion = 1, // version info
61 int minorVersion = 1);
62 ~HttpRequestHeader(void);
64 // HttpRequestHeader interface
66 std::string GetMethod(void) const;
67 std::string GetResource(void) const;
69 // HttpHeader implementation
71 std::string ToString(void) const;
73 bool ParseLine(const std::string& line, int lineNumber);
78 std::string m_resource;
81 class HttpResponseHeader : public HttpHeader {
85 HttpResponseHeader(const int statusCode, // 200, 404, etc
86 const std::string& reason = std::string(), // 'reason phrase' for code
87 int majorVersion = 1, // version info
88 int minorVersion = 1);
89 HttpResponseHeader(const std::string& s);
90 ~HttpResponseHeader(void);
92 // HttpRequestHeader interface
94 std::string GetReason(void) const;
95 int GetStatusCode(void) const;
97 // HttpHeader implementation
99 std::string ToString(void) const;
101 bool ParseLine(const std::string& line, int lineNumber);
106 std::string m_reason;
109 } // namespace Internal
110 } // namespace BamTools
112 #endif // HTTP_HEADER_P_H