78 |
|
class HttpHandler |
79 |
|
{ |
80 |
|
private: |
81 |
< |
enum code {ok = 200, choices = 300, moved = 301, found = 302, notfound = |
82 |
< |
404, internal = 500}; |
81 |
> |
enum Code { ok = 200, choices = 300, moved, found, notfound = 404, |
82 |
> |
internal = 500 }; |
83 |
|
#ifdef _WIN32 |
84 |
|
WSADATA data; |
85 |
|
#endif // _WIN32 |
97 |
|
string location; |
98 |
|
bool chunked; |
99 |
|
void populate(); |
100 |
< |
void putline(const string line = ""); |
100 |
> |
void putline(const string& line = ""); |
101 |
|
string getline(); |
102 |
|
void error(const string& prefix, bool host = false); |
103 |
|
#ifdef _OpenSSL_ |
107 |
|
public: |
108 |
|
HttpHandler(); |
109 |
|
~HttpHandler(); |
110 |
< |
bool handle(URL& url, const string referer = "", bool head = false); |
110 |
> |
bool handle(URL& url, const string& referer = "", bool head = false); |
111 |
|
iostream& pageStream() { return page; } |
112 |
|
istream& getline(string& line) { return std::getline(page, line); } |
113 |
< |
istream& getline(string& line, char end) { return std::getline(page, line, |
114 |
< |
end); } |
113 |
> |
istream& getline(string& line, char end) |
114 |
> |
{ return std::getline(page, line, end); } |
115 |
|
bool good() const { return page.good(); } |
116 |
|
void clear(); |
117 |
|
const string& contentType() const { return type; } |
118 |
|
unsigned contentLength() const { return length; } |
119 |
|
const string& redirect() const { return location; } |
120 |
|
// friends: |
121 |
< |
friend istream& operator>>(istream& is, code& data) { int number; is |
122 |
< |
>> number; data = code(number); return is; } |
121 |
> |
friend istream& operator>>(istream& is, Code& data) |
122 |
> |
{ |
123 |
> |
int number; |
124 |
> |
|
125 |
> |
is >> number; |
126 |
> |
|
127 |
> |
data = Code(number); |
128 |
> |
|
129 |
> |
return is; |
130 |
> |
} |
131 |
|
}; |
132 |
|
|
133 |
|
#endif // _HttpHandler_hpp_ |