proxy_util.c revision 7a3f81622e6b6995e0e879b1c0279ba68130b4b1
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu/* Licensed to the Apache Software Foundation (ASF) under one or more
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * contributor license agreements. See the NOTICE file distributed with
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * this work for additional information regarding copyright ownership.
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * The ASF licenses this file to You under the Apache License, Version 2.0
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * (the "License"); you may not use this file except in compliance with
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * the License. You may obtain a copy of the License at
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * http://www.apache.org/licenses/LICENSE-2.0
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * Unless required by applicable law or agreed to in writing, software
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * distributed under the License is distributed on an "AS IS" BASIS,
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * See the License for the specific language governing permissions and
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * limitations under the License.
3f5d611a1388ce3cd33f86da3f1e9b7ad68d087cMihaela Turcu/* Utility routines for Apache proxy */
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu/* Global balancer counter */
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcustatic int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maederstatic int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcustatic int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcustatic int proxy_match_word(struct dirconn_entry *This, request_rec *r);
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela TurcuAPR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu/* already called in the knowledge that the characters are hex digits */
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela TurcuPROXY_DECLARE(int) ap_proxy_hex2c(const char *x)
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu#else /*APR_CHARSET_EBCDIC*/
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * we assume that the hex value refers to an ASCII character
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * so convert to EBCDIC so that it makes sense locally;
return buf[0];
#if !APR_CHARSET_EBCDIC
int proxyreq)
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 *)
char* ndate;
if (!time) {
return date;
return date;
return ndate;
return rp;
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
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)) {
(const char **)&response,
&len,
APR_BLOCK_READ))) {
return rv;
if (len > 0) {
return APR_SUCCESS;
if (!initial) {
count++;
return url;
return url;
&proxy_module);
const char *pathp;
const char *domainp;
int ddiff = 0;
int pdiff = 0;
char *ret;
return str;
if (newpath) {
if (newdomain) {
if (newdomain) {
return ret;
const char *url)
return NULL;
return balancer;
balancer++;
return NULL;
apr_pool_t *p,
const char *url)
if (!lbmethod) {
#if APR_HAS_THREADS
return NULL;
const char *url)
int max_match = 0;
int url_length;
int min_match;
int worker_name_length;
char *url_copy;
return NULL;
char *pathstart;
worker++;
return max_worker;
#if APR_HAS_THREADS
return APR_SUCCESS;
apr_pool_t *p,
const char *url)
int rv;
#if APR_HAS_THREADS
return NULL;
return worker;
PROXY_DECLARE(void)
request_rec *r,
int access_status;
if (*worker) {
*url);
*url);
*url);
return access_status;
request_rec *r,
int access_status;
if (balancer) {
return access_status;
const char *proxy_function,
const char *backend_name,
server_rec *s,
apr_pool_t *p)
int connected = 0;
int loglevel;
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
return APR_SUCCESS;
server_rec *s)
if (ap_scoreboard_image) {
if (!score) {
if (!score) {
#if APR_HAS_THREADS
int mpm_threads;
return APR_SUCCESS;
#if APR_HAS_THREADS
#if (APR_MAJOR_VERSION > 0)
void *conn;
return rv;
server_rec *s)
return OK;
return DECLINED;
return OK;
server_rec *s)
return HTTP_SERVICE_UNAVAILABLE;
#if APR_HAS_THREADS
return HTTP_SERVICE_UNAVAILABLE;
#if APR_HAS_THREADS
return OK;
server_rec *s)
return OK;
PROXY_DECLARE(int)
char **url,
const char *proxyname,
char *server_portstr,
int server_portstr_size)
int server_port;
NULL));
if (!proxyname) {
if (proxyname) {
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
server_rec *s)
int connected = 0;
int loglevel;
conn_rec *c,
server_rec *s)
int rc;
c->bucket_alloc);
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
return rc;
return OK;
int ap_proxy_lb_workers(void)
if (!lb_workers_limit)
return lb_workers_limit;
apr_bucket *e;
if (r->main)
c->bucket_alloc);