| 193 | } |
| 194 | |
| 195 | bool http_request::try_open(bool* reuse_conn) |
| 196 | { |
| 197 | if (client_) { |
| 198 | client_->reset(); |
| 199 | *reuse_conn = true; |
| 200 | return true; |
| 201 | } |
| 202 | |
| 203 | *reuse_conn = false; |
| 204 | |
| 205 | client_ = NEW http_client(); |
| 206 | |
| 207 | if (!client_->open(addr_, conn_timeout_, rw_timeout_, unzip_)) { |
| 208 | logger_error("connect server(%s) error(%s)", |
| 209 | addr_, last_serror()); |
| 210 | close(); |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | if (ssl_conf_ == NULL) { |
| 215 | return true; |
| 216 | } |
| 217 | |
| 218 | sslbase_io* ssl = ssl_conf_->create(false); |
| 219 | const char* host; |
| 220 | if (sni_host_.empty()) { |
| 221 | host = header_.get_host(); |
| 222 | } else { |
| 223 | host = sni_host_.c_str(); |
| 224 | } |
| 225 | if (host && *host) { |
| 226 | ssl->set_sni_host(host, |
| 227 | sni_prefix_.empty() ? NULL : sni_prefix_.c_str(), |
| 228 | sni_suffix_.empty() ? NULL : sni_suffix_.c_str()); |
| 229 | } |
| 230 | if (client_->get_stream().setup_hook(ssl) == ssl) { |
| 231 | logger_error("open client ssl error to: %s", addr_); |
| 232 | ssl->destroy(); |
| 233 | close(); |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | http_header& http_request::request_header() |
| 241 | { |
nothing calls this directly
no test coverage detected