MCPcopy Create free account
hub / github.com/acl-dev/acl / try_open

Method try_open

lib_acl_cpp/src/http/http_request.cpp:195–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195bool 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
240http_header& http_request::request_header()
241{

Callers

nothing calls this directly

Calls 12

set_sni_hostMethod · 0.80
http_clientClass · 0.50
last_serrorFunction · 0.50
closeFunction · 0.50
resetMethod · 0.45
openMethod · 0.45
createMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
setup_hookMethod · 0.45
get_streamMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected