MCPcopy Create free account
hub / github.com/apache/httpd / proxy_connect_handler

Function proxy_connect_handler

modules/proxy/mod_proxy_connect.c:147–381  ·  view source on GitHub ↗

CONNECT handler */

Source from the content-addressed store, hash-verified

145
146/* CONNECT handler */
147static 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,

Callers

nothing calls this directly

Calls 14

ap_get_module_configFunction · 0.85
ap_proxyerrorFunction · 0.85
allowed_portFunction · 0.85
ap_proxy_ssl_engineFunction · 0.85
ap_fprintfFunction · 0.85
ap_get_server_bannerFunction · 0.85
ap_fflushFunction · 0.85
ap_xlate_proto_to_asciiFunction · 0.85
ap_rflushFunction · 0.85
ap_proxy_tunnel_createFunction · 0.85

Tested by

no test coverage detected