proxy_util.c revision c85eff31536e6bfef1537b2435564d48665435d3
2605N/A#include "mod_proxy.h"
2605N/A#include "scoreboard.h"
2605N/A#include "apr_version.h"
2605N/A#include "apr_hash.h"
6033N/A#include "proxy_util.h"
2605N/A/* Keep synced with mod_proxy.h! */
2605N/Astatic int lb_workers_limit = 0;
2605N/A return APR_EGENERAL;
6033N/A return APR_SUCCESS;
4070N/A return APR_SUCCESS;
2605N/A return APR_EGENERAL;
4070N/A else if (t == enc_search) {
2900N/A else if (t == enc_search) {
2605N/APROXY_DECLARE(char *)
6033N/A return statuscode;
2605N/A url = apr_pstrdup(r->pool, &url[1]); /* make it point to "//", which is what proxy_canon_netloc expects */
2900N/A /* "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;
if (!addr)
return HTTP_FORBIDDEN;
return OK;
return OK;
return url;
int n, l3 = 0;
if (urlpart) {
* BalancerMember balancer://alias http://example.com/foo
* translate url http://example.com/foo/bar/that to /bash/that
if (urlpart) {
--l2;
NULL);
worker++;
if (part) {
if (part) {
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,
int care)
return NULL;
return balancer;
balancer++;
return NULL;
const char *url)
if (!url) {
return NULL;
return NULL;
const char *url,
const char *alias,
int do_malloc)
const char *sname;
if (do_malloc)
&sname);
return APR_EINVAL;
if (lbmethod) {
return APR_EINVAL;
return rv;
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balancer, server_rec *s, apr_pool_t *p)
unsigned int num;
if (!storage) {
return APR_EGENERAL;
return APR_EGENERAL;
return rv;
return APR_EGENERAL;
return rv;
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
if (conn->r) {
return APR_SUCCESS;
apr_pool_clear(p);
return APR_SUCCESS;
request_rec *r)
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
* Based loosely on sections of wildmat.c by Rich Salz
apr_size_t x, y;
for (x = 0, y = 0; expected[y]; ++y, ++x) {
if (!expected[y])
while (str[x]) {
int ret;
return ret;
if (!expected[++y])
const char *url)
int max_match = 0;
int url_length;
int min_match;
int worker_name_length;
char *url_copy;
if (!url) {
return NULL;
return NULL;
char *pathstart;
if (balancer) {
worker_name_length) == 0)
worker_name_length) == 0)
return max_worker;
const char *url,
int do_malloc)
int rv;
* require format: unix:/path/foo/bar.sock|http://ignored/path2/
if (ptr) {
if (sockpath) {
* ProxyPass / http://www.example.com
if (balancer) {
} else if (conf) {
if (do_malloc)
if (sockpath) {
return NULL;
const char *url,
int do_malloc)
char *err;
if (err) {
return err;
return NULL;
return APR_EINVAL;
if (pool) {
return APR_SUCCESS;
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s, apr_pool_t *p)
int mpm_threads;
return rv;
return APR_EGENERAL;
void *conn;
return rv;
server_rec *s)
return OK;
return DECLINED;
return OK;
request_rec *r,
int access_status;
if (*worker) {
char *ptr;
char *ptr2;
return access_status;
request_rec *r,
if (balancer) {
return access_status;
const char *proxy_function,
const char *backend_name,
request_rec *r)
int connected = 0;
int loglevel;
server_rec *s)
return HTTP_SERVICE_UNAVAILABLE;
return HTTP_SERVICE_UNAVAILABLE;
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;
const char *uds_path;
NULL));
if (!proxyname) {
if (uds_path) {
if (proxyname) {
const char *proxy_auth;
if (!will_reuse) {
if (will_reuse) {
return HTTP_INTERNAL_SERVER_ERROR;
const char *ssl_hostname;
ssl_hostname) != 0)) ||
return OK;
server_rec *s)
int status;
int complete = 0;
int len = 0;
if (!complete) {
buffer);
code_str);
return(status);
const char *uds_path,
apr_pool_t *p)
return rv;
return rv;
return rv;
return APR_SUCCESS;
server_rec *s)
int connected = 0;
int loglevel;
sizeof(apr_sockaddr_t));
if (!c->aborted) {
if (saved_timeout) {
(void)ap_shutdown_conn(c, 0);
if (saved_timeout) {
return APR_SUCCESS;
conn_rec *c,
server_rec *s)
int rc;
return OK;
0, NULL,
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);
PROXY_DECLARE(unsigned int)
unsigned int hash;
return hash;
unsigned int hash;
return hash;
if (set)
return APR_SUCCESS;
pwt++;
return APR_EINVAL;
pwt++;
if (PROXY_WORKER_IS_USABLE(w))
return ret;
int index;
return APR_SUCCESS;
if (lbmethod) {
return APR_EINVAL;
int found;
return APR_EGENERAL;
found = 0;
if (!found) {
return rv;
if (b->s->need_reset) {
b->s->need_reset = 0;
return APR_SUCCESS;
unsigned int *index)
unsigned int i, limit;
for (i = 0; i < limit; i++) {
return NULL;
*index = i;
return shm;
return NULL;
unsigned int *index)
unsigned int i, limit;
for (i = 0; i < limit; i++) {
return NULL;
*index = i;
return shm;
return NULL;
typedef struct header_connection {
const char *error;
int is_req;
return !x->error;
int closed = 0;
if (x.error) {
if (x.array) {
name);
return closed;
request_rec *r,
char **old_cl_val,
char **old_te_val)
int counter;
char *buf;
apr_bucket *e;
int do_100_continue;
const char *fpr1;
&& !(fpr1)
&& ap_request_has_body(r));
if (fpr1) {
if (r->expecting_100) {
return HTTP_EXPECTATION_FAILED;
if (!hostname) {
if (do_100_continue) {
const char *val;
if (!r->expecting_100) {
const char *buf;
r->useragent_ip);
proxy_run_fixups(r);
return HTTP_BAD_REQUEST;
if (r->main) {
NULL);
return OK;
int flush)
if (flush) {
const char *ssl_note;
return HTTP_GATEWAY_TIME_OUT;
return HTTP_BAD_REQUEST;
return OK;
typedef struct proxy_schemes_t {
const char *name;
} proxy_schemes_t ;
if (scheme) {
return port;