You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2011/12/03 19:02:25 UTC

svn commit: r1209960 - in /httpd/httpd/branches/2.4.x: ./ include/ modules/cache/ modules/proxy/

Author: minfrin
Date: Sat Dec  3 18:02:24 2011
New Revision: 1209960

URL: http://svn.apache.org/viewvc?rev=1209960&view=rev
Log:
Backport:
mod_proxy: Remove dead code from the public API, move single use code out
of the public API, remove redundant code from the public API.
mod_cache: Remove redundant code from the public API.

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/modules/cache/cache_util.c
    httpd/httpd/branches/2.4.x/modules/cache/mod_cache.c
    httpd/httpd/branches/2.4.x/modules/cache/mod_cache.h
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ftp.c
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_http.c
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  3 18:02:24 2011
@@ -1,3 +1,3 @@
 /httpd/httpd/branches/revert-ap-ldap:1150158-1150173
 /httpd/httpd/branches/wombat-integration:723609-723841
-/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202236,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1206850,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603,1209618,1209623,1209741,1209754
+/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202236,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1206850,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603,1209618,1209623,1209741,1209754,1209776,1209797-1209798,1209811-1209812,1209814,1209908,1209910,1209913,1209916-1209917,1209947,1209952

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Sat Dec  3 18:02:24 2011
@@ -374,14 +374,23 @@
  * 20111201.0 (2.5.0-dev)  Add invalidate_entity() to the cache provider.
  * 20111202.0 (2.5.0-dev)  Use apr_status_t across mod_session API.
  * 20111202.1 (2.5.0-dev)  add APLOGNO()
+ * 20111303.0 (2.5.0-dev)  Optional ap_proxy_retry_worker(), remove
+ *                         ap_proxy_string_read(), ap_cache_liststr(),
+ *                         ap_proxy_buckets_lifetime_transform(),
+ *                         ap_proxy_date_canon(), ap_proxy_is_ipaddr(),
+ *                         ap_proxy_is_domainname(), ap_proxy_is_hostname(),
+ *                         ap_proxy_is_word(), ap_proxy_hex2sec(),
+ *                         ap_proxy_sec2hex(), ap_proxy_make_fake_req(),
+ *                         ap_proxy_strmatch_path, ap_proxy_strmatch_domain,
+ *                         ap_proxy_table_unmerge().
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20111202
+#define MODULE_MAGIC_NUMBER_MAJOR 20111203
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.4.x/modules/cache/cache_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cache/cache_util.c?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cache/cache_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/cache/cache_util.c Sat Dec  3 18:02:24 2011
@@ -737,109 +737,6 @@ int cache_check_freshness(cache_handle_t
 
 }
 
-/*
- * list is a comma-separated list of case-insensitive tokens, with
- * optional whitespace around the tokens.
- * The return returns 1 if the token val is found in the list, or 0
- * otherwise.
- */
-CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
-                                    const char *key, char **val)
-{
-    apr_size_t key_len;
-    const char *next;
-
-    if (!list) {
-        return 0;
-    }
-
-    key_len = strlen(key);
-    next = list;
-
-    for (;;) {
-
-        /* skip whitespace and commas to find the start of the next key */
-        while (*next && (apr_isspace(*next) || (*next == ','))) {
-            next++;
-        }
-
-        if (!*next) {
-            return 0;
-        }
-
-        if (!strncasecmp(next, key, key_len)) {
-            /* this field matches the key (though it might just be
-             * a prefix match, so make sure the match is followed
-             * by either a space or an equals sign)
-             */
-            next += key_len;
-            if (!*next || (*next == '=') || apr_isspace(*next) ||
-                (*next == ',')) {
-                /* valid match */
-                if (val) {
-                    while (*next && (*next != '=') && (*next != ',')) {
-                        next++;
-                    }
-                    if (*next == '=') {
-                        next++;
-                        while (*next && apr_isspace(*next )) {
-                            next++;
-                        }
-                        if (!*next) {
-                            *val = NULL;
-                        }
-                        else {
-                            const char *val_start = next;
-                            while (*next && !apr_isspace(*next) &&
-                                   (*next != ',')) {
-                                /* EAT QUOTED STRING */
-                                if (*next == '"' || *next == '\'') {
-                                    char delim = *next;
-                                    while (*++next != delim) {
-                                        if (!*next) {
-                                            return 0;
-                                        }
-                                        else if (*next == '\\') {
-                                            ++next;
-                                        }
-                                    }
-                                }
-                                next++;
-                            }
-                            *val = apr_pstrmemdup(p, val_start,
-                                                  next - val_start);
-                        }
-                    }
-                    else {
-                        *val = NULL;
-                    }
-                }
-                return 1;
-            }
-        }
-
-        /* skip to the next field */
-        do {
-            /* EAT QUOTED STRING */
-            if (*next == '"' || *next == '\'') {
-                char delim = *next;
-                while (*++next != delim) {
-                    if (!*next) {
-                        return 0;
-                    }
-                    else if (*next == '\\') {
-                        ++next;
-                    }
-                }
-            }
-            next++;
-            if (!*next) {
-                return 0;
-            }
-        } while (*next != ',');
-    }
-}
-
 /* return each comma separated token, one at a time */
 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list,
                                            const char **str)

Modified: httpd/httpd/branches/2.4.x/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cache/mod_cache.c?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cache/mod_cache.c (original)
+++ httpd/httpd/branches/2.4.x/modules/cache/mod_cache.c Sat Dec  3 18:02:24 2011
@@ -983,9 +983,7 @@ static int cache_save_filter(ap_filter_t
          */
         reason = "Authorization required";
     }
-    else if (ap_cache_liststr(NULL,
-                              apr_table_get(r->headers_out, "Vary"),
-                              "*", NULL)) {
+    else if (ap_find_token(NULL, apr_table_get(r->headers_out, "Vary"), "*")) {
         reason = "Vary header contains '*'";
     }
     else if (apr_table_get(r->subprocess_env, "no-cache") != NULL) {

Modified: httpd/httpd/branches/2.4.x/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cache/mod_cache.h?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cache/mod_cache.h (original)
+++ httpd/httpd/branches/2.4.x/modules/cache/mod_cache.h Sat Dec  3 18:02:24 2011
@@ -136,8 +136,6 @@ CACHE_DECLARE(void) ap_cache_usec2hex(ap
 CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels,
                                              int dirlength,
                                              const char *name);
-CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
-                                    const char *key, char **val);
 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);
 
 /* Create a new table consisting of those elements from an

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h Sat Dec  3 18:02:24 2011
@@ -483,13 +483,6 @@ struct proxy_balancer_method {
 #define PROXY_DECLARE_DATA             __declspec(dllimport)
 #endif
 
-/**
- * Hook an optional proxy hook.  Unlike static hooks, this uses a macro
- * instead of a function.
- */
-#define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \
-        APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order)
-
 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
                           proxy_worker *worker, proxy_server_conf *conf, char *url,
                           const char *proxyhost, apr_port_t proxyport))
@@ -530,26 +523,15 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, 
 /* proxy_util.c */
 
 PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, size_t dlen);
-PROXY_DECLARE(request_rec *) ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
 PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
 PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
                                        int forcedec, int proxyreq);
 PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
                                            char **passwordp, char **hostp, apr_port_t *port);
-PROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x);
-PROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val);
-PROXY_DECLARE(int) ap_proxy_hex2sec(const char *x);
-PROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y);
 PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
-PROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
-PROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
-PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
-PROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
 PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
 PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
-PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
-PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
 /* DEPRECATED (will be replaced with ap_proxy_connect_backend */
 PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, request_rec *);
 PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
@@ -837,28 +819,6 @@ PROXY_DECLARE(void) ap_proxy_backend_bro
                                            apr_bucket_brigade *brigade);
 
 /**
- * Transform buckets from one bucket allocator to another one by creating a
- * transient bucket for each data bucket and let it use the data read from
- * the old bucket. Metabuckets are transformed by just recreating them.
- * Attention: Currently only the following bucket types are handled:
- *
- * All data buckets
- * FLUSH
- * EOS
- *
- * If an other bucket type is found its type is logged as a debug message
- * and APR_EGENERAL is returned.
- * @param r    current request record of client request. Only used for logging
- *             purposes
- * @param from the brigade that contains the buckets to transform
- * @param to   the brigade that will receive the transformed buckets
- * @return     APR_SUCCESS if all buckets could be transformed APR_EGENERAL
- *             otherwise
- */
-PROXY_DECLARE(apr_status_t) ap_proxy_buckets_lifetime_transform(request_rec *r,
-                                                                apr_bucket_brigade *from,
-                                                                apr_bucket_brigade *to);
-/**
  * Return a hash based on the passed string
  * @param str     string to produce hash from
  * @param method  hashing method to use
@@ -925,12 +885,7 @@ PROXY_DECLARE(int) ap_proxy_trans_match(
  */
 int ap_proxy_lb_workers(void);
 
-/* For proxy_util */
 extern module PROXY_DECLARE_DATA proxy_module;
 
-extern int PROXY_DECLARE_DATA proxy_lb_workers;
-extern const apr_strmatch_pattern PROXY_DECLARE_DATA *ap_proxy_strmatch_path;
-extern const apr_strmatch_pattern PROXY_DECLARE_DATA *ap_proxy_strmatch_domain;
-
 #endif /*MOD_PROXY_H*/
 /** @} */

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ftp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ftp.c?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ftp.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ftp.c Sat Dec  3 18:02:24 2011
@@ -210,6 +210,80 @@ static int ftp_check_string(const char *
 }
 
 /*
+ * converts a series of buckets into a string
+ * XXX: BillS says this function performs essentially the same function as
+ * ap_rgetline() in protocol.c. Deprecate this function and use ap_rgetline()
+ * instead? I think ftp_string_read() will not work properly on non ASCII
+ * (EBCDIC) machines either.
+ */
+static apr_status_t ftp_string_read(conn_rec *c, apr_bucket_brigade *bb,
+        char *buff, apr_size_t bufflen, int *eos)
+{
+    apr_bucket *e;
+    apr_status_t rv;
+    char *pos = buff;
+    char *response;
+    int found = 0;
+    apr_size_t len;
+
+    /* start with an empty string */
+    buff[0] = 0;
+    *eos = 0;
+
+    /* loop through each brigade */
+    while (!found) {
+        /* get brigade from network one line at a time */
+        if (APR_SUCCESS != (rv = ap_get_brigade(c->input_filters, bb,
+                                                AP_MODE_GETLINE,
+                                                APR_BLOCK_READ,
+                                                0))) {
+            return rv;
+        }
+        /* loop through each bucket */
+        while (!found) {
+            if (*eos || APR_BRIGADE_EMPTY(bb)) {
+                /* The connection aborted or timed out */
+                return APR_ECONNABORTED;
+            }
+            e = APR_BRIGADE_FIRST(bb);
+            if (APR_BUCKET_IS_EOS(e)) {
+                *eos = 1;
+            }
+            else {
+                if (APR_SUCCESS != (rv = apr_bucket_read(e,
+                                                         (const char **)&response,
+                                                         &len,
+                                                         APR_BLOCK_READ))) {
+                    return rv;
+                }
+                /*
+                 * is string LF terminated?
+                 * XXX: This check can be made more efficient by simply checking
+                 * if the last character in the 'response' buffer is an ASCII_LF.
+                 * See ap_rgetline() for an example.
+                 */
+                if (memchr(response, APR_ASCII_LF, len)) {
+                    found = 1;
+                }
+                /* concat strings until buff is full - then throw the data away */
+                if (len > ((bufflen-1)-(pos-buff))) {
+                    len = (bufflen-1)-(pos-buff);
+                }
+                if (len > 0) {
+                    memcpy(pos, response, len);
+                    pos += len;
+                }
+            }
+            APR_BUCKET_REMOVE(e);
+            apr_bucket_destroy(e);
+        }
+        *pos = '\0';
+    }
+
+    return APR_SUCCESS;
+}
+
+/*
  * Canonicalise ftp URLs.
  */
 static int proxy_ftp_canon(request_rec *r, char *url)
@@ -313,7 +387,7 @@ static int ftp_getrc_msg(conn_rec *ftp_c
     apr_status_t rv;
     int eos;
 
-    if (APR_SUCCESS != (rv = ap_proxy_string_read(ftp_ctrl, bb, response, sizeof(response), &eos))) {
+    if (APR_SUCCESS != (rv = ftp_string_read(ftp_ctrl, bb, response, sizeof(response), &eos))) {
         return -1;
     }
 /*
@@ -332,7 +406,7 @@ static int ftp_getrc_msg(conn_rec *ftp_c
         memcpy(buff, response, 3);
         buff[3] = ' ';
         do {
-            if (APR_SUCCESS != (rv = ap_proxy_string_read(ftp_ctrl, bb, response, sizeof(response), &eos))) {
+            if (APR_SUCCESS != (rv = ftp_string_read(ftp_ctrl, bb, response, sizeof(response), &eos))) {
                 return -1;
             }
             mb = apr_cpystrn(mb, response + (' ' == response[0] ? 1 : 4), me - mb);

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_http.c?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_http.c Sat Dec  3 18:02:24 2011
@@ -688,6 +688,56 @@ static int spool_reqbody_cl(apr_pool_t *
     return(pass_brigade(bucket_alloc, r, p_conn, origin, header_brigade, 1));
 }
 
+/*
+ * Transform buckets from one bucket allocator to another one by creating a
+ * transient bucket for each data bucket and let it use the data read from
+ * the old bucket. Metabuckets are transformed by just recreating them.
+ * Attention: Currently only the following bucket types are handled:
+ *
+ * All data buckets
+ * FLUSH
+ * EOS
+ *
+ * If an other bucket type is found its type is logged as a debug message
+ * and APR_EGENERAL is returned.
+ */
+static apr_status_t proxy_buckets_lifetime_transform(request_rec *r,
+        apr_bucket_brigade *from, apr_bucket_brigade *to)
+{
+    apr_bucket *e;
+    apr_bucket *new;
+    const char *data;
+    apr_size_t bytes;
+    apr_status_t rv = APR_SUCCESS;
+
+    apr_brigade_cleanup(to);
+    for (e = APR_BRIGADE_FIRST(from);
+         e != APR_BRIGADE_SENTINEL(from);
+         e = APR_BUCKET_NEXT(e)) {
+        if (!APR_BUCKET_IS_METADATA(e)) {
+            apr_bucket_read(e, &data, &bytes, APR_BLOCK_READ);
+            new = apr_bucket_transient_create(data, bytes, r->connection->bucket_alloc);
+            APR_BRIGADE_INSERT_TAIL(to, new);
+        }
+        else if (APR_BUCKET_IS_FLUSH(e)) {
+            new = apr_bucket_flush_create(r->connection->bucket_alloc);
+            APR_BRIGADE_INSERT_TAIL(to, new);
+        }
+        else if (APR_BUCKET_IS_EOS(e)) {
+            new = apr_bucket_eos_create(r->connection->bucket_alloc);
+            APR_BRIGADE_INSERT_TAIL(to, new);
+        }
+        else {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00964)
+                          "Unhandled bucket type of type %s in"
+                          " proxy_buckets_lifetime_transform", e->type->name);
+            apr_bucket_delete(e);
+            rv = APR_EGENERAL;
+        }
+    }
+    return rv;
+}
+
 static
 int ap_proxy_http_request(apr_pool_t *p, request_rec *r,
                                    proxy_conn_rec *p_conn, proxy_worker *worker,
@@ -1195,6 +1245,65 @@ skip_body:
     return OK;
 }
 
+/*
+ * If the date is a valid RFC 850 date or asctime() date, then it
+ * is converted to the RFC 1123 format.
+ */
+static const char *date_canon(apr_pool_t *p, const char *date)
+{
+    apr_status_t rv;
+    char* ndate;
+
+    apr_time_t time = apr_date_parse_http(date);
+    if (!time) {
+        return date;
+    }
+
+    ndate = apr_palloc(p, APR_RFC822_DATE_LEN);
+    rv = apr_rfc822_date(ndate, time);
+    if (rv != APR_SUCCESS) {
+        return date;
+    }
+
+    return ndate;
+}
+
+static request_rec *make_fake_req(conn_rec *c, request_rec *r)
+{
+    apr_pool_t *pool;
+    request_rec *rp;
+
+    apr_pool_create(&pool, c->pool);
+
+    rp = apr_pcalloc(pool, sizeof(*r));
+
+    rp->pool            = pool;
+    rp->status          = HTTP_OK;
+
+    rp->headers_in      = apr_table_make(pool, 50);
+    rp->subprocess_env  = apr_table_make(pool, 50);
+    rp->headers_out     = apr_table_make(pool, 12);
+    rp->err_headers_out = apr_table_make(pool, 5);
+    rp->notes           = apr_table_make(pool, 5);
+
+    rp->server = r->server;
+    rp->log = r->log;
+    rp->proxyreq = r->proxyreq;
+    rp->request_time = r->request_time;
+    rp->connection      = c;
+    rp->output_filters  = c->output_filters;
+    rp->input_filters   = c->input_filters;
+    rp->proto_output_filters  = c->output_filters;
+    rp->proto_input_filters   = c->input_filters;
+    rp->client_ip = c->peer_ip;
+    rp->client_addr = c->peer_addr;
+
+    rp->request_config  = ap_create_request_config(pool);
+    proxy_run_create_req(r, rp);
+
+    return rp;
+}
+
 static void process_proxy_header(request_rec *r, proxy_dir_conf *c,
                                  const char *key, const char *value)
 {
@@ -1215,7 +1324,7 @@ static void process_proxy_header(request
     for (i = 0; date_hdrs[i]; ++i) {
         if (!strcasecmp(date_hdrs[i], key)) {
             apr_table_add(r->headers_out, key,
-                          ap_proxy_date_canon(r->pool, value));
+                          date_canon(r->pool, value));
             return;
         }
     }
@@ -1444,7 +1553,7 @@ apr_status_t ap_proxy_http_process_respo
      * filter chain
      */
 
-    backend->r = ap_proxy_make_fake_req(origin, r);
+    backend->r = make_fake_req(origin, r);
     /* In case anyone needs to know, this is a fake request that is really a
      * response.
      */
@@ -1646,9 +1755,8 @@ apr_status_t ap_proxy_http_process_respo
              */
             te = apr_table_get(r->headers_out, "Transfer-Encoding");
             /* strip connection listed hop-by-hop headers from response */
-            backend->close += ap_proxy_liststr(apr_table_get(r->headers_out,
-                                                             "Connection"),
-                                              "close");
+            backend->close += ap_find_token(p,
+                    apr_table_get(r->headers_out, "Connection"), "close");
             ap_proxy_clear_connection(p, r->headers_out);
             if ((buf = apr_table_get(r->headers_out, "Content-Type"))) {
                 ap_set_content_type(r, apr_pstrdup(p, buf));
@@ -1904,7 +2012,7 @@ apr_status_t ap_proxy_http_process_respo
                     }
 
                     /* Switch the allocator lifetime of the buckets */
-                    ap_proxy_buckets_lifetime_transform(r, bb, pass_bb);
+                    proxy_buckets_lifetime_transform(r, bb, pass_bb);
 
                     /* found the last brigade? */
                     if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pass_bb))) {

Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c Sat Dec  3 18:02:24 2011
@@ -355,151 +355,6 @@ PROXY_DECLARE(char *)
     return NULL;
 }
 
-/*
- * If the date is a valid RFC 850 date or asctime() date, then it
- * is converted to the RFC 1123 format.
- */
-PROXY_DECLARE(const char *)
-     ap_proxy_date_canon(apr_pool_t *p, const char *date)
-{
-    apr_status_t rv;
-    char* ndate;
-
-    apr_time_t time = apr_date_parse_http(date);
-    if (!time) {
-        return date;
-    }
-
-    ndate = apr_palloc(p, APR_RFC822_DATE_LEN);
-    rv = apr_rfc822_date(ndate, time);
-    if (rv != APR_SUCCESS) {
-        return date;
-    }
-
-    return ndate;
-}
-
-PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r)
-{
-    apr_pool_t *pool;
-    request_rec *rp;
-
-    apr_pool_create(&pool, c->pool);
-
-    rp = apr_pcalloc(pool, sizeof(*r));
-
-    rp->pool            = pool;
-    rp->status          = HTTP_OK;
-
-    rp->headers_in      = apr_table_make(pool, 50);
-    rp->subprocess_env  = apr_table_make(pool, 50);
-    rp->headers_out     = apr_table_make(pool, 12);
-    rp->err_headers_out = apr_table_make(pool, 5);
-    rp->notes           = apr_table_make(pool, 5);
-
-    rp->server = r->server;
-    rp->log = r->log;
-    rp->proxyreq = r->proxyreq;
-    rp->request_time = r->request_time;
-    rp->connection      = c;
-    rp->output_filters  = c->output_filters;
-    rp->input_filters   = c->input_filters;
-    rp->proto_output_filters  = c->output_filters;
-    rp->proto_input_filters   = c->input_filters;
-
-    rp->request_config  = ap_create_request_config(pool);
-    proxy_run_create_req(r, rp);
-
-    return rp;
-}
-
-
-/*
- * list is a comma-separated list of case-insensitive tokens, with
- * optional whitespace around the tokens.
- * The return returns 1 if the token val is found in the list, or 0
- * otherwise.
- */
-PROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val)
-{
-    int len, i;
-    const char *p;
-
-    len = strlen(val);
-
-    while (list != NULL) {
-        p = ap_strchr_c(list, ',');
-        if (p != NULL) {
-            i = p - list;
-            do {
-                p++;
-            } while (apr_isspace(*p));
-        }
-        else {
-            i = strlen(list);
-        }
-
-        while (i > 0 && apr_isspace(list[i - 1])) {
-            i--;
-        }
-        if (i == len && strncasecmp(list, val, len) == 0) {
-            return 1;
-        }
-        list = p;
-    }
-    return 0;
-}
-
-/*
- * Converts 8 hex digits to a time integer
- */
-PROXY_DECLARE(int) ap_proxy_hex2sec(const char *x)
-{
-    int i, ch;
-    unsigned int j;
-
-    for (i = 0, j = 0; i < 8; i++) {
-        ch = x[i];
-        j <<= 4;
-        if (apr_isdigit(ch)) {
-            j |= ch - '0';
-        }
-        else if (apr_isupper(ch)) {
-            j |= ch - ('A' - 10);
-        }
-        else {
-            j |= ch - ('a' - 10);
-        }
-    }
-    if (j == 0xffffffff) {
-        return -1;      /* so that it works with 8-byte ints */
-    }
-    else {
-        return j;
-    }
-}
-
-/*
- * Converts a time integer to 8 hex digits
- */
-PROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y)
-{
-    int i, ch;
-    unsigned int j = t;
-
-    for (i = 7; i >= 0; i--) {
-        ch = j & 0xF;
-        j >>= 4;
-        if (ch >= 10) {
-            y[i] = ch + ('A' - 10);
-        }
-        else {
-            y[i] = ch + '0';
-        }
-    }
-    y[8] = '\0';
-}
-
 PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message)
 {
     const char *uri = ap_escape_html(r->pool, r->uri);
@@ -951,109 +806,6 @@ PROXY_DECLARE(int) ap_proxy_pre_http_req
     return OK;
 }
 
-/*
- * converts a series of buckets into a string
- * XXX: BillS says this function performs essentially the same function as
- * ap_rgetline() in protocol.c. Deprecate this function and use ap_rgetline()
- * instead? I think ap_proxy_string_read() will not work properly on non ASCII
- * (EBCDIC) machines either.
- */
-PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb,
-                                                 char *buff, apr_size_t bufflen, int *eos)
-{
-    apr_bucket *e;
-    apr_status_t rv;
-    char *pos = buff;
-    char *response;
-    int found = 0;
-    apr_size_t len;
-
-    /* start with an empty string */
-    buff[0] = 0;
-    *eos = 0;
-
-    /* loop through each brigade */
-    while (!found) {
-        /* get brigade from network one line at a time */
-        if (APR_SUCCESS != (rv = ap_get_brigade(c->input_filters, bb,
-                                                AP_MODE_GETLINE,
-                                                APR_BLOCK_READ,
-                                                0))) {
-            return rv;
-        }
-        /* loop through each bucket */
-        while (!found) {
-            if (*eos || APR_BRIGADE_EMPTY(bb)) {
-                /* The connection aborted or timed out */
-                return APR_ECONNABORTED;
-            }
-            e = APR_BRIGADE_FIRST(bb);
-            if (APR_BUCKET_IS_EOS(e)) {
-                *eos = 1;
-            }
-            else {
-                if (APR_SUCCESS != (rv = apr_bucket_read(e,
-                                                         (const char **)&response,
-                                                         &len,
-                                                         APR_BLOCK_READ))) {
-                    return rv;
-                }
-                /*
-                 * is string LF terminated?
-                 * XXX: This check can be made more efficient by simply checking
-                 * if the last character in the 'response' buffer is an ASCII_LF.
-                 * See ap_rgetline() for an example.
-                 */
-                if (memchr(response, APR_ASCII_LF, len)) {
-                    found = 1;
-                }
-                /* concat strings until buff is full - then throw the data away */
-                if (len > ((bufflen-1)-(pos-buff))) {
-                    len = (bufflen-1)-(pos-buff);
-                }
-                if (len > 0) {
-                    memcpy(pos, response, len);
-                    pos += len;
-                }
-            }
-            APR_BUCKET_REMOVE(e);
-            apr_bucket_destroy(e);
-        }
-        *pos = '\0';
-    }
-
-    return APR_SUCCESS;
-}
-
-/* unmerge an element in the table */
-PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key)
-{
-    apr_off_t offset = 0;
-    apr_off_t count = 0;
-    char *value = NULL;
-
-    /* get the value to unmerge */
-    const char *initial = apr_table_get(t, key);
-    if (!initial) {
-        return;
-    }
-    value = apr_pstrdup(p, initial);
-
-    /* remove the value from the headers */
-    apr_table_unset(t, key);
-
-    /* find each comma */
-    while (value[count]) {
-        if (value[count] == ',') {
-            value[count] = 0;
-            apr_table_add(t, key, value + offset);
-            offset = count + 1;
-        }
-        count++;
-    }
-    apr_table_add(t, key, value + offset);
-}
-
 PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
                               proxy_dir_conf *conf, const char *url)
 {
@@ -2835,57 +2587,6 @@ PROXY_DECLARE(void) ap_proxy_backend_bro
 }
 
 /*
- * Transform buckets from one bucket allocator to another one by creating a
- * transient bucket for each data bucket and let it use the data read from
- * the old bucket. Metabuckets are transformed by just recreating them.
- * Attention: Currently only the following bucket types are handled:
- *
- * All data buckets
- * FLUSH
- * EOS
- *
- * If an other bucket type is found its type is logged as a debug message
- * and APR_EGENERAL is returned.
- */
-PROXY_DECLARE(apr_status_t)
-ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from,
-                                    apr_bucket_brigade *to)
-{
-    apr_bucket *e;
-    apr_bucket *new;
-    const char *data;
-    apr_size_t bytes;
-    apr_status_t rv = APR_SUCCESS;
-
-    apr_brigade_cleanup(to);
-    for (e = APR_BRIGADE_FIRST(from);
-         e != APR_BRIGADE_SENTINEL(from);
-         e = APR_BUCKET_NEXT(e)) {
-        if (!APR_BUCKET_IS_METADATA(e)) {
-            apr_bucket_read(e, &data, &bytes, APR_BLOCK_READ);
-            new = apr_bucket_transient_create(data, bytes, r->connection->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(to, new);
-        }
-        else if (APR_BUCKET_IS_FLUSH(e)) {
-            new = apr_bucket_flush_create(r->connection->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(to, new);
-        }
-        else if (APR_BUCKET_IS_EOS(e)) {
-            new = apr_bucket_eos_create(r->connection->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(to, new);
-        }
-        else {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                          "Unhandled bucket type of type %s in"
-                          " ap_proxy_buckets_lifetime_transform", e->type->name);
-            apr_bucket_delete(e);
-            rv = APR_EGENERAL;
-        }
-    }
-    return rv;
-}
-
-/*
  * Provide a string hashing function for the proxy.
  * We offer 2 methods: one is the APR model but we
  * also provide our own, based on either FNV or SDBM.

Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h?rev=1209960&r1=1209959&r2=1209960&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h Sat Dec  3 18:02:24 2011
@@ -26,6 +26,15 @@
  * @{
  */
 
+PROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
+PROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
+PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
+PROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
+
+extern int PROXY_DECLARE_DATA proxy_lb_workers;
+extern const apr_strmatch_pattern PROXY_DECLARE_DATA *ap_proxy_strmatch_path;
+extern const apr_strmatch_pattern PROXY_DECLARE_DATA *ap_proxy_strmatch_domain;
+
 /**
  * Register optional functions declared within proxy_util.c.
  */