mod_proxy_connect.c revision d494c1653ea615c65699f1f33b0b01586f1839c4
97a9a944b5887e91042b019776c41d5dd74557aferikabele/* Licensed to the Apache Software Foundation (ASF) under one or more
97a9a944b5887e91042b019776c41d5dd74557aferikabele * contributor license agreements. See the NOTICE file distributed with
97a9a944b5887e91042b019776c41d5dd74557aferikabele * this work for additional information regarding copyright ownership.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * The ASF licenses this file to You under the Apache License, Version 2.0
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * (the "License"); you may not use this file except in compliance with
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * the License. You may obtain a copy of the License at
b686b6a420bde7f78c416b90be11db94cb789979nd * Unless required by applicable law or agreed to in writing, software
b686b6a420bde7f78c416b90be11db94cb789979nd * distributed under the License is distributed on an "AS IS" BASIS,
b686b6a420bde7f78c416b90be11db94cb789979nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b686b6a420bde7f78c416b90be11db94cb789979nd * See the License for the specific language governing permissions and
b686b6a420bde7f78c416b90be11db94cb789979nd * limitations under the License.
b686b6a420bde7f78c416b90be11db94cb789979nd/* CONNECT method for Apache proxy */
b686b6a420bde7f78c416b90be11db94cb789979nd * This handles Netscape CONNECT method secure proxy requests.
b686b6a420bde7f78c416b90be11db94cb789979nd * A connection is opened to the specified host and data is
b686b6a420bde7f78c416b90be11db94cb789979nd * passed through between the WWW site and the browser.
b686b6a420bde7f78c416b90be11db94cb789979nd * This code is based on the INTERNET-DRAFT document
b686b6a420bde7f78c416b90be11db94cb789979nd * "Tunneling SSL Through a WWW Proxy" currently at
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * If proxyhost and proxyport are set, we send a CONNECT to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * the specified proxy..
b686b6a420bde7f78c416b90be11db94cb789979nd * FIXME: this doesn't log the number of bytes sent, but
b686b6a420bde7f78c416b90be11db94cb789979nd * that may be okay, since the data is supposed to
b686b6a420bde7f78c416b90be11db94cb789979nd * be transparent. In fact, this doesn't log at all
b686b6a420bde7f78c416b90be11db94cb789979nd * yet. 8^)
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * FIXME: doesn't check any headers initally sent from the
b686b6a420bde7f78c416b90be11db94cb789979nd * FIXME: should allow authentication, but hopefully the
b686b6a420bde7f78c416b90be11db94cb789979nd * generic proxy authentication is good enough.
b686b6a420bde7f78c416b90be11db94cb789979nd * FIXME: no check for r->assbackwards, whatever that is.
b686b6a420bde7f78c416b90be11db94cb789979ndstatic int allowed_port(proxy_server_conf *conf, int port)
b686b6a420bde7f78c416b90be11db94cb789979nd for(i = 0; i < conf->allowed_connect_ports->nelts; i++) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive/* canonicalise CONNECT URLs. */
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic int proxy_connect_canon(request_rec *r, char *url)
b686b6a420bde7f78c416b90be11db94cb789979nd/* read available data (in blocks of CONN_BLKSZ) from c_i and copy to c_o */
b686b6a420bde7f78c416b90be11db94cb789979ndstatic int proxy_connect_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd "proxy: CONNECT: error on %s - ap_pass_brigade",
b686b6a420bde7f78c416b90be11db94cb789979nd "proxy: CONNECT: error on %s - ap_get_brigade",
return rv;
const char *connectname;
int connectport = 0;
return DECLINED;
NULL));
if (proxyname) {
r->pool);
if (failed) {
if (proxyname) {
return DECLINED;
return HTTP_SERVICE_UNAVAILABLE;
return HTTP_INTERNAL_SERVER_ERROR;
if (!backconn) {
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
if (proxyport) {
ap_rflush(r);
return HTTP_INTERNAL_SERVER_ERROR;
#ifdef DEBUGGING
#ifdef DEBUGGING
#ifdef DEBUGGING
return OK;