CONNECT handler */
| 145 | |
| 146 | /* CONNECT handler */ |
| 147 | static int proxy_connect_handler(request_rec *r, proxy_worker *worker, |
| 148 | proxy_server_conf *conf, |
| 149 | char *url, const char *proxyname, |
| 150 | apr_port_t proxyport) |
| 151 | { |
| 152 | connect_conf *c_conf = |
| 153 | ap_get_module_config(r->server->module_config, &proxy_connect_module); |
| 154 | |
| 155 | apr_pool_t *p = r->pool; |
| 156 | apr_socket_t *sock; |
| 157 | conn_rec *c = r->connection; |
| 158 | conn_rec *backconn; |
| 159 | |
| 160 | apr_status_t rv; |
| 161 | apr_size_t nbytes; |
| 162 | char buffer[HUGE_STRING_LEN]; |
| 163 | |
| 164 | apr_bucket_brigade *bb; |
| 165 | proxy_tunnel_rec *tunnel; |
| 166 | int failed, rc; |
| 167 | |
| 168 | apr_uri_t uri; |
| 169 | const char *connectname; |
| 170 | apr_port_t connectport = 0; |
| 171 | apr_sockaddr_t *nexthop; |
| 172 | |
| 173 | apr_interval_time_t current_timeout; |
| 174 | |
| 175 | /* is this for us? */ |
| 176 | if (r->method_number != M_CONNECT) { |
| 177 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "declining URL %s", url); |
| 178 | return DECLINED; |
| 179 | } |
| 180 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "serving URL %s", url); |
| 181 | |
| 182 | |
| 183 | /* |
| 184 | * Step One: Determine Who To Connect To |
| 185 | * |
| 186 | * Break up the URL to determine the host to connect to |
| 187 | */ |
| 188 | |
| 189 | /* we break the URL into host, port, uri */ |
| 190 | if (APR_SUCCESS != apr_uri_parse_hostinfo(p, url, &uri)) { |
| 191 | return ap_proxyerror(r, HTTP_BAD_REQUEST, |
| 192 | apr_pstrcat(p, "URI cannot be parsed: ", url, |
| 193 | NULL)); |
| 194 | } |
| 195 | |
| 196 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01019) |
| 197 | "connecting %s to %s:%d", url, uri.hostname, uri.port); |
| 198 | |
| 199 | /* Determine host/port of next hop; from request URI or of a proxy. */ |
| 200 | connectname = proxyname ? proxyname : uri.hostname; |
| 201 | connectport = proxyname ? proxyport : uri.port; |
| 202 | |
| 203 | /* Do a DNS lookup for the next hop */ |
| 204 | rv = apr_sockaddr_info_get(&nexthop, connectname, APR_UNSPEC, |
nothing calls this directly
no test coverage detected