| 91 | } |
| 92 | |
| 93 | bool 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 | |
| 134 | bool http_transfer::transfer_request_head(acl::socket_stream& conn) { |
| 135 | acl::string header; |
nothing calls this directly
no test coverage detected