36 typedef struct ssl_ctx_st SSL_CTX;
37 typedef struct x509_st X509;
38 typedef struct X509_name_st X509_NAME;
39 typedef struct evp_pkey_st EVP_PKEY;
59 HTTPClient(
const HTTPClient ©);
60 void operator = (
const HTTPClient ©);
63 static void init_random_seed();
65 void set_proxy_spec(
const std::string &proxy_spec);
66 std::string get_proxy_spec()
const;
68 void set_direct_host_spec(
const std::string &direct_host_spec);
69 std::string get_direct_host_spec()
const;
71 INLINE
void set_try_all_direct(
bool try_all_direct);
72 INLINE
bool get_try_all_direct()
const;
75 void add_proxy(
const std::string &scheme,
const URLSpec &proxy);
76 void clear_direct_host();
77 void add_direct_host(
const std::string &hostname);
79 std::string get_proxies_for_url(
const URLSpec &url)
const;
81 void set_username(
const std::string &server,
const std::string &realm,
const std::string &username);
82 std::string get_username(
const std::string &server,
const std::string &realm)
const;
84 void set_cookie(
const HTTPCookie &cookie);
85 bool clear_cookie(
const HTTPCookie &cookie);
86 void clear_all_cookies();
87 bool has_cookie(
const HTTPCookie &cookie)
const;
88 HTTPCookie get_cookie(
const HTTPCookie &cookie)
const;
89 void copy_cookies_from(
const HTTPClient &other);
91 void write_cookies(std::ostream &out)
const;
92 void send_cookies(std::ostream &out,
const URLSpec &url);
94 INLINE
void set_client_certificate_filename(
const Filename &filename);
95 INLINE
void set_client_certificate_pem(
const std::string &pem);
96 INLINE
void set_client_certificate_passphrase(
const std::string &passphrase);
97 bool load_client_certificate();
99 bool add_preapproved_server_certificate_filename(
const URLSpec &url,
const Filename &filename);
100 bool add_preapproved_server_certificate_pem(
const URLSpec &url,
const std::string &pem);
101 bool add_preapproved_server_certificate_name(
const URLSpec &url,
const std::string &name);
102 void clear_preapproved_server_certificates(
const URLSpec &url);
103 void clear_all_preapproved_server_certificates();
105 INLINE
void set_http_version(HTTPEnum::HTTPVersion version);
106 INLINE HTTPEnum::HTTPVersion get_http_version()
const;
107 std::string get_http_version_string()
const;
108 static HTTPEnum::HTTPVersion parse_http_version_string(
const std::string &version);
110 bool load_certificates(
const Filename &filename);
118 INLINE
void set_verify_ssl(VerifySSL verify_ssl);
119 INLINE VerifySSL get_verify_ssl()
const;
121 INLINE
void set_cipher_list(
const std::string &cipher_list);
122 INLINE
const std::string &get_cipher_list()
const;
124 PT(HTTPChannel) make_channel(
bool persistent_connection);
125 BLOCKING PT(HTTPChannel) post_form(
const URLSpec &url,
const std::string &body);
126 BLOCKING PT(HTTPChannel) get_document(
const URLSpec &url);
127 BLOCKING PT(HTTPChannel) get_header(
const URLSpec &url);
129 INLINE
static std::string base64_encode(
const std::string &s);
130 INLINE
static std::string base64_decode(
const std::string &s);
132 static HTTPClient *get_global_ptr();
137 SSL_CTX *get_ssl_ctx();
140 void check_preapproved_server_certificate(
const URLSpec &url, X509 *cert,
141 bool &cert_preapproved,
bool &cert_name_preapproved)
const;
143 bool get_proxies_for_scheme(
const std::string &scheme,
146 void add_http_username(
const std::string &http_username);
147 std::string select_username(
const URLSpec &url,
bool is_proxy,
148 const std::string &realm)
const;
150 HTTPAuthorization *select_auth(
const URLSpec &url,
bool is_proxy,
151 const std::string &last_realm);
152 PT(HTTPAuthorization) generate_auth(
const URLSpec &url,
bool is_proxy,
153 const std::string &challenge);
155 void unload_client_certificate();
157 static X509_NAME *parse_x509_name(
const std::string &source);
158 static bool x509_name_subset(X509_NAME *name_a, X509_NAME *name_b);
160 static void split_whitespace(std::string &a, std::string &b,
const std::string &c);
164 ProxiesByScheme _proxies_by_scheme;
166 DirectHosts _direct_hosts;
167 bool _try_all_direct;
169 HTTPEnum::HTTPVersion _http_version;
170 VerifySSL _verify_ssl;
171 std::string _cipher_list;
174 Usernames _usernames;
176 typedef pmap<std::string, PT(HTTPAuthorization)> Realms;
182 Domains _proxy_domains, _www_domains;
188 Filename _client_certificate_filename;
189 std::string _client_certificate_pem;
190 std::string _client_certificate_passphrase;
193 bool _client_certificate_loaded;
194 X509 *_client_certificate_pub;
195 EVP_PKEY *_client_certificate_priv;
199 class PreapprovedServerCert {
201 ~PreapprovedServerCert();
204 ServerCertNames _cert_names;
208 PreapprovedServerCerts _preapproved_server_certs;
210 static PT(HTTPClient) _global_ptr;
212 friend class HTTPChannel;
217 #endif // HAVE_OPENSSL