]> granicus.if.org Git - apache/commitdiff
Clean up the input filtering a lot. This makes the code a bit easier
authorRyan Bloom <rbb@apache.org>
Wed, 11 Oct 2000 23:27:03 +0000 (23:27 +0000)
committerRyan Bloom <rbb@apache.org>
Wed, 11 Oct 2000 23:27:03 +0000 (23:27 +0000)
to follow.  This code works for browser based requests and line-based
telnet requests.  It is untested with character-based telnet requests.
I will be testing that very soon.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86549 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index 34117a2d8964452a3ab3c135c64e1a2bb8786aa2..c2a8e4c7801e8a28969a4d78fc24cfa891990d29 100644 (file)
@@ -915,7 +915,6 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b)
     }
 
     AP_BRIGADE_FOREACH(e, b) {
-
         if ((rv = e->read(e, (const char **)&buff, &length, 0)) != APR_SUCCESS) {
             return rv;
         }
@@ -953,7 +952,7 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b)
  */
 static int getline(char *s, int n, conn_rec *c, int fold)
 {
-    char *pos;
+    char *pos = s;
     const char *toss;
     const char *temp;
     int retval;
@@ -961,21 +960,6 @@ static int getline(char *s, int n, conn_rec *c, int fold)
     apr_ssize_t length;
     ap_bucket_brigade *b;
     ap_bucket *e;
-    
-    
-#ifdef APACHE_XLATE_XXX
-    /* When getline() is called, the HTTP protocol is in a state
-     * where we MUST be reading "plain text" protocol stuff,
-     * (Request line, MIME headers, Chunk sizes) regardless of
-     * the MIME type and conversion setting of the document itself.
-     * Save the current setting of the translation handle for
-     * uploads, then temporarily set it to the one used for headers
-     * (and restore it before returning).
-     */
-    AP_PUSH_INPUTCONVERSION_STATE(in, ap_hdrs_from_ascii);
-#endif /*APACHE_XLATE*/
-
-    pos = s;
 
     if (!c->input_data) {
         b = ap_brigade_create(c->pool);
@@ -984,31 +968,22 @@ static int getline(char *s, int n, conn_rec *c, int fold)
         b = c->input_data;
     }
 
-    if (AP_BRIGADE_EMPTY(b)) {
-        ap_get_brigade(c->input_filters, b);
-    }
-
-    if (AP_BRIGADE_EMPTY(b)) {
-        return -1;
-    }
     while (1) {
+        if (AP_BRIGADE_EMPTY(b)) {
+            if (ap_get_brigade(c->input_filters, b) != APR_SUCCESS) {
+                return -1;
+            }
+        }
         e = AP_BRIGADE_FIRST(b); 
-        while (e->length == 0) {
+        if (e->length == 0) {
             AP_BUCKET_REMOVE(e);
             ap_bucket_destroy(e);
-
-            ap_get_brigade(c->input_filters, b);
-            if (!AP_BRIGADE_EMPTY(b)) {
-                e = AP_BRIGADE_FIRST(b); 
-            }
-            else {
-                return -1;
-            }
+            continue;
         }
         retval = e->read(e, &temp, &length, 0);
-        /* retval == 0 on SUCCESS */
 
-        if (retval != 0) {
+        /* retval == APR_SUCCESS on SUCCESS */
+        if (retval != APR_SUCCESS) {
             total = ((length < 0) && (total == 0)) ? -1 : total;
             break;
         }
@@ -1016,12 +991,6 @@ static int getline(char *s, int n, conn_rec *c, int fold)
        /* check for line end using ascii encoding, even on an ebcdic box
         * since this is raw protocol data fresh from the network
         */
-/*XXX This needs to be scrubbed, but Greg Ames is going to do a lot to this
-  *   code in a little while.  When he is done, it shouldn't need scrubbing
-  *   any more.
-  *
-  *   GREG, this is where the breakage is!!!!
-  */
         if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) { 
             length = (toss - temp) + (pos - s) + 1;
             e->split(e, length + (temp[length] == '\0')); 
@@ -1075,11 +1044,6 @@ static int getline(char *s, int n, conn_rec *c, int fold)
            break;       /* if not, input line exceeded buffer size */
        }
     }
-#ifdef APACHE_XLATE_XXX
-    /* restore translation handle */
-    AP_POP_INPUTCONVERSION_STATE(in);
-#endif /*APACHE_XLATE*/
-
     return total;
 }