#include "ap_hooks.h"
#include "apr_portable.h"
#include "apr_mmap.h"
+#include "util_filter.h"
+#include "ap_buckets.h"
#ifdef __cplusplus
extern "C" {
*/
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,
* 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);
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.
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
*/
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);
}
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;