httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_negotiation.c
Date Mon, 06 Aug 2001 19:03:37 GMT
wrowe       01/08/06 12:03:37

  Modified:    modules/http http_request.c
               include  http_request.h
               modules/mappers mod_negotiation.c
  Log:
    The real slim shady finally stood up.  This patch segregates the fast
    internal redirect logic back into http_request, the next patch will
    actually fix it.
  
  Revision  Changes    Path
  1.103     +27 -0     httpd-2.0/modules/http/http_request.c
  
  Index: http_request.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_request.c,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- http_request.c	2001/06/01 17:35:07	1.102
  +++ http_request.c	2001/08/06 19:03:37	1.103
  @@ -556,6 +556,33 @@
       return new;
   }
   
  +AP_DECLARE(void) ap_internal_fast_redirect(request_rec *rr, request_rec *r))
  +{
  +    /* We need to tell POOL_DEBUG that we're guaranteeing that rr->pool
  +     * will exist as long as r->pool.  Otherwise we run into troubles because
  +     * some values in this request will be allocated in r->pool, and others in
  +     * rr->pool.
  +     */
  +    apr_pool_join(r->pool, rr->pool);
  +    r->mtime = 0; /* reset etag info for subrequest */
  +    r->filename = rr->filename;
  +    r->handler = rr->handler;
  +    r->content_type = rr->content_type;
  +    r->content_encoding = rr->content_encoding;
  +    r->content_languages = rr->content_languages;
  +    r->content_language = rr->content_language;
  +    r->finfo = rr->finfo;
  +    r->per_dir_config = rr->per_dir_config;
  +    /* copy output headers from subrequest, but leave negotiation headers */
  +    r->notes = apr_table_overlay(r->pool, rr->notes, r->notes);
  +    r->headers_out = apr_table_overlay(r->pool, rr->headers_out,
  +                                    r->headers_out);
  +    r->err_headers_out = apr_table_overlay(r->pool, rr->err_headers_out,
  +                                        r->err_headers_out);
  +    r->subprocess_env = apr_table_overlay(r->pool, rr->subprocess_env,
  +                                       r->subprocess_env);
  +}
  +
   AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r)
   {
       request_rec *new = internal_internal_redirect(new_uri, r);
  
  
  
  1.32      +10 -0     httpd-2.0/include/http_request.h
  
  Index: http_request.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_request.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- http_request.h	2001/07/23 19:02:03	1.31
  +++ http_request.h	2001/08/06 19:03:37	1.32
  @@ -200,6 +200,16 @@
   AP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r);
   
   /**
  + * Redirect the current request to a sub_req, merging the pools
  + * @param sub_req A subrequest created from this request
  + * @param r The current request
  + * @deffunc void ap_internal_fast_redirect(request_rec *sub_req, request_rec *r)
  + * @tip the sub_req's pool will be merged into r's pool, be very careful
  + * not to destroy this subrequest, it will be destroyed with the main request!
  + */
  +AP_DECLARE(void) ap_internal_fast_redirect(request_rec *sub_req, request_rec *r))
  +
  +/**
    * Can be used within any handler to determine if any authentication
    * is required for the current request
    * @param r The current request
  
  
  
  1.66      +17 -33    httpd-2.0/modules/mappers/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_negotiation.c,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- mod_negotiation.c	2001/08/04 11:37:12	1.65
  +++ mod_negotiation.c	2001/08/06 19:03:37	1.66
  @@ -911,6 +911,7 @@
       struct var_rec mime_info;
       struct accept_rec accept_info;
       void *new_var;
  +    int anymatch = 0;
   
       clean_var_rec(&mime_info);
   
  @@ -947,6 +948,11 @@
               continue;
           }
   
  +        /* Ok, something's here.  Maybe nothing useful.  Remember that
  +         * we tried, if we completely fail, so we can reject the request!
  +         */
  +        anymatch = 1;
  +
           /* Yep.  See if it's something which we have access to, and 
            * which has a known type and encoding (as opposed to something
            * which we'll be slapping default_type on later).
  @@ -954,6 +960,11 @@
   
           sub_req = ap_sub_req_lookup_dirent(&dirent, r, NULL);
   
  +        /* BLECH --- don't multi-resolve non-ordinary files */
  +
  +        if (sub_req->finfo.filetype != APR_REG)
  +            continue;
  +
           /* If it has a handler, we'll pretend it's a CGI script,
            * since that's a good indication of the sort of thing it
            * might be doing.
  @@ -2689,43 +2700,16 @@
           }
       }
   
  -    /* BLECH --- don't multi-resolve non-ordinary files */
  +    /* now do a "fast redirect" ... promotes the sub_req into the main req */
  +    ap_internal_fast_redirect(sub_req, r);
   
  -    if (sub_req->finfo.filetype != APR_REG) {
  -        res = HTTP_NOT_FOUND;
  -        goto return_from_multi;
  -    }
  -
  -    /* Otherwise, use it. */
  -
  -    /* now do a "fast redirect" ... promote the sub_req into the main req */
  -    /* We need to tell POOL_DEBUG that we're guaranteeing that sub_req->pool
  -     * will exist as long as r->pool.  Otherwise we run into troubles because
  -     * some values in this request will be allocated in r->pool, and others in
  -     * sub_req->pool.
  -     */
  -    apr_pool_join(r->pool, sub_req->pool);
  -    r->mtime = 0; /* reset etag info for subrequest */
  -    r->filename = sub_req->filename;
  -    r->handler = sub_req->handler;
  -    r->content_type = sub_req->content_type;
  -    r->content_encoding = sub_req->content_encoding;
  -    r->content_languages = sub_req->content_languages;
  -    r->content_language = sub_req->content_language;
  -    r->finfo = sub_req->finfo;
  -    r->per_dir_config = sub_req->per_dir_config;
  -    /* copy output headers from subrequest, but leave negotiation headers */
  -    r->notes = apr_table_overlay(r->pool, sub_req->notes, r->notes);
  -    r->headers_out = apr_table_overlay(r->pool, sub_req->headers_out,
  -                                    r->headers_out);
  -    r->err_headers_out = apr_table_overlay(r->pool, sub_req->err_headers_out,
  -                                        r->err_headers_out);
  -    r->subprocess_env = apr_table_overlay(r->pool, sub_req->subprocess_env,
  -                                       r->subprocess_env);
  +    /* clean up all but our favorite variant, since that sub_req
  +     * is now merged into the main request!
  +     */
       avail_recs = (var_rec *) neg->avail_vars->elts;
       for (j = 0; j < neg->avail_vars->nelts; ++j) {
           var_rec *variant = &avail_recs[j];
  -        if (variant != best && variant->sub_req) {
  +        if (variant != best && variant->rr) {
               ap_destroy_sub_req(variant->sub_req);
           }
       }
  
  
  

Mime
View raw message