Commit 0e2376aa authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

Remove the lameo create_req hack and delay the addition of the HTTP_IN

filter until after we have read the headers.  This eliminates the status
hack that was in http_protocol.c and makes it all around better.

server/protocol.c now directly adds HTTP_IN filter - should we create a
specific hook for this?  (Could we do this as a post_read_request hook?)
I'm not terribly sure, but let's move it down to the lowest possible
place in ap_read_request.  We can change this detail later as we see fit.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91192 13f79535-47bb-0310-9956-ffa450edef68
parent 0ded2ad1
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -301,15 +301,6 @@ static int ap_process_http_connection(conn_rec *c)
    return OK;
}

static int ap_http_create_req(request_rec *r)
{
    if (!r->main)
    {
        ap_add_input_filter("HTTP_IN", NULL, r, r->connection);
    }
    return OK;
}

static void ap_http_insert_filter(request_rec *r)
{
    if (!r->main) {
@@ -328,8 +319,6 @@ static void register_hooks(apr_pool_t *p)
    ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);
    ap_hook_http_method(http_method,NULL,NULL,APR_HOOK_REALLY_LAST);
    ap_hook_default_port(http_port,NULL,NULL,APR_HOOK_REALLY_LAST);
    ap_hook_create_request(ap_http_create_req, NULL, NULL, APR_HOOK_MIDDLE);

    ap_hook_insert_filter(ap_http_insert_filter, NULL, NULL, APR_HOOK_REALLY_LAST);
    ap_register_input_filter("HTTP_IN", ap_http_filter, AP_FTYPE_CONNECTION);
    ap_register_output_filter("HTTP_HEADER", ap_http_header_filter, 
+25 −37
Original line number Diff line number Diff line
@@ -484,7 +484,6 @@ AP_DECLARE(const char *) ap_method_name_of(int methnum)
static long get_chunk_size(char *);

typedef struct http_filter_ctx {
    int status;
    apr_size_t remaining;
    enum {
        BODY_NONE,
@@ -493,8 +492,9 @@ typedef struct http_filter_ctx {
    } state;
} http_ctx_t;

/* Hi, I'm the main input filter for HTTP requests. 
 * I handle chunked and content-length bodies. */
/* This is the input filter for HTTP requests.  It handles chunked and 
 * content-length bodies.  This can only be inserted/used after the headers
 * are successfully parsed. */
apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_off_t *readbytes)
{
    apr_bucket *e;
@@ -502,22 +502,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode
    apr_status_t rv;

    if (!ctx) {
        f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
        ctx->status = f->r->status;
    }

    /* Basically, we have to stay out of the way until server/protocol.c
     * says it is okay - which it does by setting r->status to OK. */
    if (f->r->status != ctx->status)
    {
        int old_status;
        /* Allow us to be reentrant! */
        old_status = ctx->status;
        ctx->status = f->r->status;

        if (old_status == HTTP_REQUEST_TIME_OUT && f->r->status == HTTP_OK)
        {
        const char *tenc, *lenp;
        f->ctx = ctx = apr_palloc(f->r->pool, sizeof(*ctx));
        ctx->state = BODY_NONE;

        tenc = apr_table_get(f->r->headers_in, "Transfer-Encoding");
        lenp = apr_table_get(f->r->headers_in, "Content-Length");

@@ -543,7 +531,6 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode
            }
        }
    }
    }

    if (!ctx->remaining)
    {
@@ -575,6 +562,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode

                if (!ctx->remaining)
                {
                    /* Handle trailers by calling get_mime_headers again! */
                    e = apr_bucket_eos_create();
                    APR_BRIGADE_INSERT_TAIL(b, e);
                    return APR_SUCCESS;
+2 −0
Original line number Diff line number Diff line
@@ -676,6 +676,8 @@ request_rec *ap_read_request(conn_rec *conn)
        }
    }

    ap_add_input_filter("HTTP_IN", NULL, r, r->connection);

    if ((access_status = ap_run_post_read_request(r))) {
        ap_die(access_status, r);
        ap_run_log_transaction(r);