httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Wed, 28 Mar 2001 10:40:45 GMT
gstein      01/03/28 02:40:45

  Modified:    modules/http http_protocol.c
  Log:
  Fix the OPTIONS response. It was attempting to send an HTTP response
  (header) through the filter stack, which just wrapped that response in
  another set of headers.
  
  Instead, just set the Allow header and return. The EOS will then flush that
  header with the rest of the data through the header filter, and generate the
  proper response.
  
  Also, cleaned out the unused header_filter_ctx and the "len" variable from
  the header filter, and added some comments here and there.
  
  Revision  Changes    Path
  1.311     +24 -40    httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.310
  retrieving revision 1.311
  diff -u -u -r1.310 -r1.311
  --- http_protocol.c	2001/03/25 20:42:46	1.310
  +++ http_protocol.c	2001/03/28 10:40:44	1.311
  @@ -748,11 +748,19 @@
       return 1;
   }
   
  +/*
  + * Determine the protocol to use for the response. Potentially downgrade
  + * to HTTP/1.0 in some situations and/or turn off keepalives.
  + *
  + * also prepare r->status_line.
  + */
   static void basic_http_header_check(request_rec *r, 
                                       const char **protocol)
   {
  -    if (r->assbackwards)
  +    if (r->assbackwards) {
  +        /* no such thing as a response protocol */
           return;
  +    }
   
       if (!r->status_line)
           r->status_line = status_lines[ap_index_of_response(r->status)];
  @@ -770,14 +778,18 @@
       }
   }
   
  -static void basic_http_header(request_rec *r, apr_bucket_brigade *bb, const char *protocol)
  +/* fill "bb" with a barebones/initial HTTP response header */
  +static void basic_http_header(request_rec *r, apr_bucket_brigade *bb,
  +                              const char *protocol)
   {
       char *date = NULL;
       char *tmp;
       header_struct h;
   
  -    if (r->assbackwards)
  +    if (r->assbackwards) {
  +        /* there are no headers to send */
           return;
  +    }
   
       /* Output the HTTP/1.x Status-Line and the Date and Server fields */
   
  @@ -910,29 +922,13 @@
   
   int ap_send_http_options(request_rec *r)
   {
  -    apr_bucket_brigade *bb = apr_brigade_create(r->pool);
  -    header_struct h;
  -
       if (r->assbackwards)
           return DECLINED;
       
  -    ap_basic_http_header(r, bb);
  -
  -    apr_table_setn(r->headers_out, "Content-Length", "0");
       apr_table_setn(r->headers_out, "Allow", make_allow(r));
  -    ap_set_keepalive(r);
   
  -    h.pool = r->pool;
  -    h.bb = bb;
  -
  -    apr_table_do((int (*) (void *, const char *, const char *)) form_header_field,
  -             (void *) &h, r->headers_out, NULL);
  -
  -    terminate_header(bb);
  -
  -    r->bytes_sent = 0;
  -
  -    ap_pass_brigade(r->output_filters, bb);
  +    /* the request finalization will send an EOS, which will flush all
  +       the headers out (including the Allow header) */
   
       return OK;
   }
  @@ -1015,10 +1011,9 @@
       }
   }
   
  -typedef struct header_filter_cts {
  -    int headers_sent;
  -} header_filter_ctx;
  -AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade
*b)
  +AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(
  +    ap_filter_t *f,
  +    apr_bucket_brigade *b)
   {
       int i;
       char *date = NULL;
  @@ -1027,21 +1022,10 @@
       const char *protocol;
       apr_bucket *e;
       apr_bucket_brigade *b2;
  -    apr_size_t len = 0;
       header_struct h;
  -    header_filter_ctx *ctx = f->ctx;
   
       AP_DEBUG_ASSERT(!r->main);
   
  -    if (!ctx) {
  -        ctx = apr_pcalloc(r->pool, sizeof(*ctx));
  -    }
  -
  -    if (ctx->headers_sent) {
  -        apr_brigade_destroy(b);
  -        return OK;
  -    }
  -
       APR_BRIGADE_FOREACH(e, b) {
           if (e->type == &ap_bucket_type_error) {
               ap_bucket_error *eb = e->data;
  @@ -1071,6 +1055,9 @@
        * Remove the 'Vary' header field if the client can't handle it.
        * Since this will have nasty effects on HTTP/1.1 caches, force
        * the response into HTTP/1.0 mode.
  +     *
  +     * Note: the force-response-1.0 should come before the call to
  +     *       basic_http_header_check()
        */
       if (apr_table_get(r->subprocess_env, "force-no-vary") != NULL) {
   	apr_table_unset(r->headers_out, "Vary");
  @@ -1081,10 +1068,7 @@
   	fixup_vary(r);
       }
   
  -    /* Need to add a fudge factor so that the CRLF at the end of the headers
  -     * and the basic http headers don't overflow this buffer.
  -     */
  -    len += strlen(ap_get_server_version()) + 100;
  +    /* determine the protocol and whether we should use keepalives. */
       basic_http_header_check(r, &protocol);
       ap_set_keepalive(r);
   
  
  
  

Mime
View raw message