You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/10/06 08:07:17 UTC
cvs commit: apache-2.0/src/main http_connection.c http_core.c http_protocol.c
rbb 00/10/05 23:07:16
Modified: src CHANGES
src/include http_protocol.h
src/main http_connection.c http_core.c http_protocol.c
Log:
Add the first draft of the http_filter. In time this filter will split
the bucket brigade between the headers and the body. Right now it just
converts \r\n to \n\0.
Revision Changes Path
1.254 +6 -0 apache-2.0/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-2.0/src/CHANGES,v
retrieving revision 1.253
retrieving revision 1.254
diff -u -r1.253 -r1.254
--- CHANGES 2000/10/05 22:34:46 1.253
+++ CHANGES 2000/10/06 06:06:58 1.254
@@ -1,4 +1,10 @@
Changes with Apache 2.0a7
+ *) Begin the http_filter. This is an input filter that understands
+ the absolute basic amount required to parse an HTTP Request. The
+ goal is to be able to split headers from request body before passing
+ the data back to the other filters.
+ [Ryan Bloom]
+
*) Bring forward from 1.3.13 the config directory implementation
[Jim Jagielski]
1.26 +4 -0 apache-2.0/src/include/http_protocol.h
Index: http_protocol.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/http_protocol.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- http_protocol.h 2000/09/18 19:30:22 1.25
+++ http_protocol.h 2000/10/06 06:07:01 1.26
@@ -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" {
@@ -543,6 +545,8 @@
* @deffunc const char *ap_method_name_of(int methnum)
*/
API_EXPORT(const char *) ap_method_name_of(int methnum);
+
+int http_filter(ap_filter_t *f, ap_bucket_brigade *b);
/* Hooks */
/*
1.51 +1 -0 apache-2.0/src/main/http_connection.c
Index: http_connection.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_connection.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- http_connection.c 2000/10/05 16:55:03 1.50
+++ http_connection.c 2000/10/06 06:07:07 1.51
@@ -216,6 +216,7 @@
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;
1.146 +1 -0 apache-2.0/src/main/http_core.c
Index: http_core.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -r1.145 -r1.146
--- http_core.c 2000/10/05 16:55:04 1.145
+++ http_core.c 2000/10/06 06:07:07 1.146
@@ -3478,6 +3478,7 @@
* 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);
1.146 +28 -12 apache-2.0/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -r1.145 -r1.146
--- http_protocol.c 2000/10/05 22:40:28 1.145
+++ http_protocol.c 2000/10/06 06:07:07 1.146
@@ -856,6 +856,33 @@
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 @@
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 @@
*/
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);
}
Re: cvs commit: apache-2.0/src/main http_connection.c http_core.c
http_protocol.c
Posted by rb...@covalent.net.
> > +
> > + 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';
>
> euh... this doesn't look right. We shouldn't be modifying a bucket's
> internal contents like this. I understand this is your first draft, but how
> will you be fixing this part?
This fine to do, because this filter will always be just above the core
input filter, and we know that the core used a pool to allocate the
data. This does work, the only way this won't work, is if we add another
filter between the two, and the solution is to just check the bucket type,
and call setaside if necessary.
> Separate question: I don't understand why we aren't we doing this conversion
> as we read the headers into the headers_in table (??)
We do this, because this is how the core expects the data. If there is a
\r\n, the core gets very confused, and it stops working. The problem is
that not all headers are put into the headers_in table, and Unix and
Windows differ in the data they send.
Ryan
Re: cvs commit: apache-2.0/src/main http_connection.c http_core.c http_protocol.c
Posted by Greg Stein <gs...@lyra.org>.
On Fri, Oct 06, 2000 at 06:07:17AM -0000, rbb@locus.apache.org wrote:
> rbb 00/10/05 23:07:16
>
> Modified: src CHANGES
> src/include http_protocol.h
> src/main http_connection.c http_core.c http_protocol.c
> Log:
> Add the first draft of the http_filter. In time this filter will split
> the bucket brigade between the headers and the body. Right now it just
> converts \r\n to \n\0.
>...
> --- http_protocol.c 2000/10/05 22:40:28 1.145
> +++ http_protocol.c 2000/10/06 06:07:07 1.146
> @@ -856,6 +856,33 @@
> 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';
euh... this doesn't look right. We shouldn't be modifying a bucket's
internal contents like this. I understand this is your first draft, but how
will you be fixing this part?
Separate question: I don't understand why we aren't we doing this conversion
as we read the headers into the headers_in table (??)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/