46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// $Id: HttpHandler.h,v 1.16 2003/07/17 07:03:08 douglas Exp $ |
49 |
> |
// $Id: HttpHandler.h,v 1.17 2003/07/18 07:17:10 douglas Exp $ |
50 |
|
|
51 |
|
#ifndef _HttpHandler_h_ |
52 |
|
#define _HttpHandler_h_ |
64 |
|
typedef int SOCKET; |
65 |
|
#endif // _WIN32 |
66 |
|
|
67 |
+ |
#ifdef _OpenSSL_ |
68 |
+ |
#include <openssl/ssl.h> |
69 |
+ |
#include <openssl/err.h> |
70 |
+ |
#include <openssl/rand.h> |
71 |
+ |
#endif |
72 |
+ |
|
73 |
|
class HttpHandler |
74 |
|
{ |
75 |
|
private: |
80 |
|
#endif // _WIN32 |
81 |
|
SOCKET http; |
82 |
|
#ifdef _OpenSSL_ |
83 |
+ |
SSL_CTX* ctx; |
84 |
+ |
SSL* ssl; |
85 |
|
bool tls; |
86 |
|
#endif |
87 |
|
char* buffer; |
88 |
< |
string page; |
88 |
> |
bool binary; |
89 |
> |
stringstream page; |
90 |
|
string type; |
91 |
|
unsigned length; |
92 |
|
string location; |
95 |
|
void putline(const string line = ""); |
96 |
|
string getline(); |
97 |
|
void error(const string& prefix, bool host = false); |
98 |
+ |
#ifdef _OpenSSL_ |
99 |
+ |
void error(const string& prefix, int number); |
100 |
+ |
bool starttls(); |
101 |
+ |
#endif |
102 |
|
public: |
103 |
|
HttpHandler(); |
104 |
|
~HttpHandler(); |
105 |
|
bool handle(URL& url, const string referer = "", bool head = false); |
106 |
< |
HttpHandler& getline(string& line, char endline = '\n'); |
107 |
< |
bool good() { return (page.length() > 0); } |
106 |
> |
istream& pageStream() { return page; } |
107 |
> |
istream& getline(string& line) { return std::getline(page, line); } |
108 |
> |
istream& getline(string& line, char end) { return std::getline(page, line, |
109 |
> |
end); } |
110 |
> |
bool good() { return page.good(); } |
111 |
|
void clear(); |
112 |
|
string contentType() { return type; } |
113 |
|
unsigned contentLength() { return length; } |