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

Method open_peer

app/wizard_demo/httpd_proxy/http_transfer.cpp:93–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93bool http_transfer::open_peer(request_t& req, acl::socket_stream& conn)
94{
95 const char* host = req.getRemoteHost();
96 if (host == NULL || *host == 0) {
97 logger_error("no Host in request head");
98 return false;
99 }
100
101 acl::string buf(host);
102
103 char* ptr = strrchr(buf.c_str(), ':');
104 if (ptr != NULL && *(ptr + 1) != 0) {
105 *ptr++ = 0;
106 int port = atoi(ptr);
107 if (port > 0 && port < 65535) {
108 port_ = port;
109 }
110 }
111
112 acl::string addr;
113 addr.format("%s|%d", buf.c_str(), port_);
114
115 if (!conn.open(addr, 5, 5)) {
116 logger_error("connect %s error %s",
117 addr.c_str(), acl::last_serror());
118 return false;
119 }
120
121 logger("connect %s ok, fd=%d, use ssl=%s", addr.c_str(),
122 conn.sock_handle(), ssl_conf_ ? "yes" : "no");
123
124 if (ssl_conf_ && !setup_ssl(conn, *ssl_conf_, host)) {
125 logger_error("setup ssl error!");
126 return false;
127 }
128
129 bool is_request = true, unzip = false, fixed_stream = true;
130 client_ = new acl::http_client(&conn, is_request, unzip, fixed_stream);
131 return true;
132}
133
134bool http_transfer::transfer_request_head(acl::socket_stream& conn) {
135 acl::string header;

Callers

nothing calls this directly

Calls 7

getRemoteHostMethod · 0.80
last_serrorFunction · 0.50
setup_sslFunction · 0.50
c_strMethod · 0.45
formatMethod · 0.45
openMethod · 0.45
sock_handleMethod · 0.45

Tested by

no test coverage detected