proxy_util.c revision 08df8c976ef7d6c1362cba072cadf0e1e6c91975
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta/* Copyright 1999-2004 The Apache Software Foundation
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * Licensed under the Apache License, Version 2.0 (the "License");
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * you may not use this file except in compliance with the License.
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * You may obtain a copy of the License at
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * Unless required by applicable law or agreed to in writing, software
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * distributed under the License is distributed on an "AS IS" BASIS,
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * See the License for the specific language governing permissions and
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * limitations under the License.
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta/* Utility routines for Apache proxy */
1a7d1977037864e52858058777af8ff8401547ddJan Cholastastatic int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
1a7d1977037864e52858058777af8ff8401547ddJan Cholastastatic int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
1a7d1977037864e52858058777af8ff8401547ddJan Cholastastatic int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
1a7d1977037864e52858058777af8ff8401547ddJan Cholastastatic int proxy_match_word(struct dirconn_entry *This, request_rec *r);
1a7d1977037864e52858058777af8ff8401547ddJan CholastaAPR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
2d6836a90bd326391782a5753f70e8ba666b5defJan Cholasta/* already called in the knowledge that the characters are hex digits */
3882325ff60f89d0c312e9519bdfd1351978fd73Jan CholastaPROXY_DECLARE(int) ap_proxy_hex2c(const char *x)
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta#else /*APR_CHARSET_EBCDIC*/
19d8bc19b5b5597427878645644fa354ef6cb54dMichal Zidek /* we assume that the hex value refers to an ASCII character
1a7d1977037864e52858058777af8ff8401547ddJan Cholasta * so convert to EBCDIC so that it makes sense locally;
3ac7c4fe618ede980a4df8d90341ef1fd0f1f62fWilliam B * client specifies %20 in URL to refer to a space char;
3ac7c4fe618ede980a4df8d90341ef1fd0f1f62fWilliam B * at this point we're called with EBCDIC "20"; after turning
3ac7c4fe618ede980a4df8d90341ef1fd0f1f62fWilliam B * EBCDIC "20" into binary 0x20, we then need to assume that 0x20
3ac7c4fe618ede980a4df8d90341ef1fd0f1f62fWilliam B * represents an ASCII char and convert 0x20 to EBCDIC, yielding
3882325ff60f89d0c312e9519bdfd1351978fd73Jan Cholasta#endif /*APR_CHARSET_EBCDIC*/
2d6836a90bd326391782a5753f70e8ba666b5defJan CholastaPROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x)
int isenc)
int i, j, ch;
if (t == enc_path)
else if (t == enc_search)
else if (t == enc_user)
else if (t == enc_fpath)
if (t == enc_path)
else if (t == enc_search)
for (i = 0, j = 0; i < len; i++, j++) {
ch = x[i];
y[j] = ch;
return NULL;
y[j] = ch;
PROXY_DECLARE(char *)
return NULL;
PROXY_DECLARE(const char *)
return rp;
PROXY_DECLARE(apr_table_t *)ap_proxy_read_headers(request_rec *r, request_rec *rr, char *buffer, int size, conn_rec *c)
int len;
int saw_headers = 0;
return NULL;
if (saw_headers) {
return headers_out;
return NULL;
++value;
return headers_out;
int len, i;
if (p != NULL) {
i = p - list;
while (apr_isspace(*p));
list = p;
int len, i;
if (p != NULL) {
i = p - list;
while (apr_isspace(*p));
if (new)
list = p;
return new;
int i, ch;
ch = x[i];
int i, ch;
return statuscode;
return r->hostname;
return NULL;
url = apr_pstrdup(r->pool, &url[1]); /* make it point to "//", which is what proxy_canon_netloc expects */
int i, quads;
long bits;
char *tmp;
char *tmp;
++addr;
--quads;
/* "IP Address should be given in dotted-quad form, optionally followed by a netmask (e.g., 192.168.111.0/24)"; */
#if DEBUGGING
#if DEBUGGING
!= APR_SUCCESS) {
#if DEBUGGING
host);
while (reqaddr) {
#if DEBUGGING
#if DEBUGGING
--d_len;
--h_len;
int h2_len;
int h1_len;
while (addr) {
--h2_len;
--h1_len;
return HTTP_FORBIDDEN;
while (conf_addr) {
while (uri_addr) {
char *conf_ip;
char *uri_ip;
return HTTP_FORBIDDEN;
return OK;
return OK;
* ap_rgetline() in protocol.c. Deprecate this function and use ap_rgetline()
apr_bucket *e;
char *response;
int found = 0;
buff[0] = 0;
*eos = 0;
while (!found) {
return rv;
while (!found) {
return APR_ECONNABORTED;
if (APR_BUCKET_IS_EOS(e)) {
return rv;
if (len > 0) {
return APR_SUCCESS;
if (!initial) {
count++;
const char *proxy_function,
const char *backend_name,
server_rec *s,
apr_pool_t *p)
int connected = 0;
int loglevel;