stas        2003/03/08 01:15:16

  Modified:    lib/Apache compat.pm
               lib/ModPerl Code.pm
               src/modules/perl mod_perl.c modperl_filter.c
               xs/Apache/RequestRec Apache__RequestRec.h
               .        Changes
  Log:
  When PerlOptions +ParseHeaders is an effect, the CGI headers parsing
  won't be done if any *mod_perl* handler, from the header_parser phase
  and upto and including the response phase, sets $r->content_type.
  (similar behavior to mp1's send_http_header()
  
  Revision  Changes    Path
  1.83      +7 -1      modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- compat.pm 4 Mar 2003 00:56:26 -0000       1.82
  +++ compat.pm 8 Mar 2003 09:15:16 -0000       1.83
  @@ -171,7 +171,13 @@
   
   sub send_http_header {
       my ($r, $type) = @_;
  -    $r->content_type($type) if defined $type;
  +
  +    # since send_http_header() in mp1 was telling mod_perl not to
  +    # parse headers and in mp2 one must call $r->content_type($type) to
  +    # perform the same, we make sure that this happens
  +    $type = $r->content_type || 'text/html' unless defined $type;
  +
  +    $r->content_type($type);
   }
   
   #to support $r->server_root_relative
  
  
  
  1.94      +2 -1      modperl-2.0/lib/ModPerl/Code.pm
  
  Index: Code.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Code.pm   1 Mar 2003 00:53:20 -0000       1.93
  +++ Code.pm   8 Mar 2003 09:15:16 -0000       1.94
  @@ -105,7 +105,8 @@
       Srv => ['NONE', @ithread_opts, qw(ENABLE AUTOLOAD MERGE_HANDLERS),
               @hook_flags, 'UNSET'],
       Dir => [qw(NONE PARSE_HEADERS SETUP_ENV MERGE_HANDLERS GLOBAL_REQUEST UNSET)],
  -    Req => [qw(NONE SET_GLOBAL_REQUEST SETUP_ENV CLEANUP_REGISTERED)],
  +    Req => [qw(NONE SET_GLOBAL_REQUEST PARSE_HEADERS SETUP_ENV 
  +               CLEANUP_REGISTERED)],
       Interp => [qw(NONE IN_USE PUTBACK CLONED BASE)],
       Handler => [qw(NONE PARSED METHOD OBJECT ANON AUTOLOAD DYNAMIC)],
   );
  
  
  
  1.155     +11 -2     modperl-2.0/src/modules/perl/mod_perl.c
  
  Index: mod_perl.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
  retrieving revision 1.154
  retrieving revision 1.155
  diff -u -r1.154 -r1.155
  --- mod_perl.c        3 Mar 2003 03:39:06 -0000       1.154
  +++ mod_perl.c        8 Mar 2003 09:15:16 -0000       1.155
  @@ -550,6 +550,16 @@
   
   static int modperl_hook_header_parser(request_rec *r)
   {
  +    MP_dDCFG;
  +
  +    /* set the default for cgi header parsing On (if applicable) as
  +     * early as possible so $r->content_type in any phase after
  +     * header_parser could turn it off */
  +    if (MpDirPARSE_HEADERS(dcfg)) {
  +        MP_dRCFG;
  +        MpReqPARSE_HEADERS_On(rcfg);
  +    }
  +    
       /* if 'PerlOptions +GlobalRequest' is inside a container */
       modperl_global_request_cfg_set(r);
   
  @@ -718,7 +728,6 @@
   void modperl_response_init(request_rec *r)
   {
       MP_dRCFG;
  -    MP_dDCFG;
       modperl_wbucket_t *wb;
   
       if (!rcfg->wbucket) {
  @@ -733,7 +742,7 @@
       wb->pool = r->pool;
       wb->filters = &r->output_filters;
       wb->outcnt = 0;
  -    wb->header_parse = MpDirPARSE_HEADERS(dcfg) ? 1 : 0;
  +    wb->header_parse = MpReqPARSE_HEADERS(rcfg) ? 1 : 0;
       wb->r = r;
   }
   
  
  
  
  1.55      +2 -2      modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- modperl_filter.c  3 Mar 2003 03:39:06 -0000       1.54
  +++ modperl_filter.c  8 Mar 2003 09:15:16 -0000       1.55
  @@ -54,8 +54,8 @@
       apr_bucket_brigade *bb;
       apr_bucket *bucket;
       const char *work_buf = buf;
  -    
  -    if (wb->header_parse && !wb->r->content_type) {
  +
  +    if (wb->header_parse) {
           request_rec *r = wb->r;
           const char *bodytext = NULL;
           int status;
  
  
  
  1.5       +14 -0     modperl-2.0/xs/Apache/RequestRec/Apache__RequestRec.h
  
  Index: Apache__RequestRec.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestRec/Apache__RequestRec.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Apache__RequestRec.h      21 May 2002 02:50:16 -0000      1.4
  +++ Apache__RequestRec.h      8 Mar 2003 09:15:16 -0000       1.5
  @@ -5,9 +5,23 @@
       const char *retval = r->content_type;
   
       if (type) {
  +        MP_dRCFG;
           STRLEN len;
           const char *val = SvPV(type, len);
           ap_set_content_type(r, apr_pmemdup(r->pool, val, len+1));
  +
  +        /* turn off cgi header parsing, similar to what
  +         * send_http_header did in mp1 */
  +        MpReqPARSE_HEADERS_Off(rcfg);
  +        if (rcfg->wbucket) {
  +            /* in case we are already inside
  +             *     modperl_callback_per_dir(MP_RESPONSE_HANDLER, r); 
  +             * but haven't sent any data yet, it's too late to change
  +             * MpReqPARSE_HEADERS, so change the wbucket's private
  +             * flag directly
  +             */
  +            rcfg->wbucket->header_parse = 0;
  +        }
       }
   
       return retval;
  
  
  
  1.145     +5 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.144
  retrieving revision 1.145
  diff -u -r1.144 -r1.145
  --- Changes   8 Mar 2003 03:58:59 -0000       1.144
  +++ Changes   8 Mar 2003 09:15:16 -0000       1.145
  @@ -10,6 +10,11 @@
   
   =item 1.99_09-dev
   
  +When PerlOptions +ParseHeaders is an effect, the CGI headers parsing
  +won't be done if any *mod_perl* handler, from the header_parser phase
  +and upto and including the response phase, sets $r->content_type.
  +(similar behavior to mp1's send_http_header() [Stas]
  +
   Registry: make sure that $r is not in the scope when the script is
   compiled [Stas]
   
  
  
  

Reply via email to