httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1209776 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h mod_proxy_ftp.c proxy_util.c
Date Fri, 02 Dec 2011 23:18:40 GMT
Author: minfrin
Date: Fri Dec  2 23:18:39 2011
New Revision: 1209776

URL: http://svn.apache.org/viewvc?rev=1209776&view=rev
Log:
mod_proxy: Move ap_proxy_string_read() out of the public API into
mod_proxy_ftp.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1209776&r1=1209775&r2=1209776&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Fri Dec  2 23:18:39 2011
@@ -548,7 +548,6 @@ PROXY_DECLARE(int) ap_proxy_is_hostname(
 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 *);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c?rev=1209776&r1=1209775&r2=1209776&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c Fri Dec  2 23:18:39 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/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1209776&r1=1209775&r2=1209776&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Fri Dec  2 23:18:39 2011
@@ -951,80 +951,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)
 {



Mime
View raw message