]> granicus.if.org Git - apache/commitdiff
Add the first draft of the http_filter. In time this filter will split
authorRyan Bloom <rbb@apache.org>
Fri, 6 Oct 2000 06:07:07 +0000 (06:07 +0000)
committerRyan Bloom <rbb@apache.org>
Fri, 6 Oct 2000 06:07:07 +0000 (06:07 +0000)
the bucket brigade between the headers and the body.  Right now it just
converts \r\n to \n\0.

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

include/http_protocol.h
modules/http/http_core.c
modules/http/http_protocol.c
server/connection.c

index 1e4f2ef2993fdc76bd1067279c1ef25fe584760a..a368646ba49ad9f5cdec6218178353581a7b14c9 100644 (file)
@@ -62,6 +62,8 @@
 #include "ap_hooks.h"
 #include "apr_portable.h"
 #include "apr_mmap.h"
+#include "util_filter.h"
+#include "ap_buckets.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -544,6 +546,8 @@ API_EXPORT(int) ap_method_number_of(const char *method);
  */
 API_EXPORT(const char *) ap_method_name_of(int methnum);
 
+int http_filter(ap_filter_t *f, ap_bucket_brigade *b);
+
   /* Hooks */
   /*
    * post_read_request --- run right after read_request or internal_redirect,
index dc1bf2ddd1b3b47fd6ddf5814dcc70e69c8861ac..6c8f8fdbc4a27f1d4725959f4bc7551e317d9c7e 100644 (file)
@@ -3478,6 +3478,7 @@ static void register_hooks(void)
      * request-processing time.
      */
     ap_hook_insert_filter(core_register_filter, NULL, NULL, AP_HOOK_MIDDLE);
+    ap_register_input_filter("HTTP_IN", http_filter, AP_FTYPE_CONNECTION);
     ap_register_input_filter("CORE_IN", core_input_filter, AP_FTYPE_CONNECTION);
     ap_register_output_filter("CORE", core_output_filter, AP_FTYPE_CONNECTION + 1);
     ap_register_output_filter("CHUNK", chunk_filter, AP_FTYPE_CONNECTION);
index 3ae2198bcdf50d7143938fb66d77b09d4afb3446..a3ebf727e0714e60518957547352aba91f2eb737 100644 (file)
@@ -856,6 +856,33 @@ API_EXPORT(const char *) ap_method_name_of(int methnum)
     return AP_HTTP_METHODS[methnum];
 }
 
+int http_filter(ap_filter_t *f, ap_bucket_brigade *b)
+{
+#define ASCII_CR '\015'
+#define ASCII_LF '\012'
+    ap_bucket *e;
+    char *buff;
+    int length;
+    char *pos;
+
+    ap_get_brigade(f->next, b);
+
+    AP_BRIGADE_FOREACH(e, b) {
+
+        e->read(e, (const char **)&buff, &length, 0);
+
+        pos = buff + 1;
+        while (pos < buff + length) {
+            if ((*pos == ASCII_LF) && (*(pos - 1) == ASCII_CR)) {
+                *(pos - 1) = ASCII_LF;
+                *pos = '\0';
+            }
+            pos++;
+        }
+    }
+    return APR_SUCCESS;
+}
+
 /* Get a line of protocol input, including any continuation lines
  * caused by MIME folding (or broken clients) if fold != 0, and place it
  * in the buffer s, of size n bytes, without the ending newline.
@@ -880,8 +907,6 @@ static int getline(char *s, int n, conn_rec *c, int fold)
     ap_bucket_brigade *b;
     ap_bucket *e;
     
-#define ASCII_CR '\015'
-#define ASCII_LF '\012'
     
 #ifdef APACHE_XLATE_XXX
     /* When getline() is called, the HTTP protocol is in a state
@@ -938,18 +963,9 @@ static int getline(char *s, int n, conn_rec *c, int fold)
         */
         if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) { 
             length = toss - temp + 1;
-            e->split(e, length);
+            e->split(e, length + 1);
             apr_cpystrn(pos, temp, length + 1);
            
-           /* get rid of optional \r, again using ascii encoding */
-           
-           /*** XXX need 2 sentinels in front of pos 
-            ***     which are never ASCII_CR, in case length < 2
-            */
-           if (pos[length - 2] == ASCII_CR) {
-                pos[length - 2] = ASCII_LF;
-                pos[--length] = '\0';
-           }
             AP_BUCKET_REMOVE(e);
             e->destroy(e);
         }
index e1b56fed52b961e069a5df79bdebab264a01d515..92a4d22cf3587635e0af0bf977a233bf776a985a 100644 (file)
@@ -216,6 +216,7 @@ CORE_EXPORT(void) ap_process_connection(conn_rec *c)
 
 int ap_pre_http_connection(conn_rec *c)
 {
+    ap_add_input_filter("HTTP_IN", NULL, NULL, c);
     ap_add_input_filter("CORE_IN", NULL, NULL, c);
     ap_add_output_filter("CORE", NULL, NULL, c);
     return OK;