richter     02/01/25 12:19:27

  Modified:    .        Tag: Embperl2c Embperl.pm epinit.c epmain.c
  Log:
  includes
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.118.4.82 +17 -3     embperl/Embperl.pm
  
  Index: Embperl.pm
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl.pm,v
  retrieving revision 1.118.4.81
  retrieving revision 1.118.4.82
  diff -u -r1.118.4.81 -r1.118.4.82
  --- Embperl.pm        25 Jan 2002 07:04:30 -0000      1.118.4.81
  +++ Embperl.pm        25 Jan 2002 20:19:26 -0000      1.118.4.82
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: Embperl.pm,v 1.118.4.81 2002/01/25 07:04:30 richter Exp $
  +#   $Id: Embperl.pm,v 1.118.4.82 2002/01/25 20:19:26 richter Exp $
   #
   ###################################################################################
   
  @@ -68,7 +68,14 @@
   
       local $SIG{__WARN__} = \&Warn ;
   
  -    Embperl::Req::RunRequest (undef, $param) ;
  +    if (!ref $param)
  +        {
  +        Embperl::Req::RunRequest (undef, { inputfile => $param, param => [@_]}) ;
  +        }
  +    else
  +        {
  +        Embperl::Req::RunRequest (undef, $param) ;
  +        }
       }
   
   
#######################################################################################
  @@ -110,7 +117,14 @@
       my $rc ;
       my $param = shift ;
   
  -    Embperl::Req::RunComponent ($Embperl::req, $param) ;
  +    if (!ref $param)
  +        {
  +        Embperl::Req::RunComponent ($Embperl::req, { inputfile => $param, param => 
[@_]}) ;
  +        }
  +    else
  +        {
  +        Embperl::Req::RunComponent ($Embperl::req, $param) ;
  +        }
       }
   
   
#######################################################################################
  
  
  
  1.1.2.19  +4 -4      embperl/Attic/epinit.c
  
  Index: epinit.c
  ===================================================================
  RCS file: /home/cvs/embperl/Attic/epinit.c,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- epinit.c  25 Jan 2002 15:51:31 -0000      1.1.2.18
  +++ epinit.c  25 Jan 2002 20:19:26 -0000      1.1.2.19
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epinit.c,v 1.1.2.18 2002/01/25 15:51:31 richter Exp $
  +#   $Id: epinit.c,v 1.1.2.19 2002/01/25 20:19:26 richter Exp $
   #
   
###################################################################################*/
   
  @@ -1262,11 +1262,11 @@
       tComponentParam * pParam ;
       tComponentConfig * pConfig ;
       epTHX ;
  +    tComponent * pPrev = NULL ;
   
   
       if (r -> Component._perlsv)
           { /* we have already a component, so let safe it first */
  -        tComponent * pPrev ;
           SV * pHV ;
           MAGIC * mg ;
   
  @@ -1274,8 +1274,6 @@
   
           memcpy (pPrev, &r -> Component, sizeof (*pPrev)) ;
           
  -        r -> Component.pPrev = pPrev ;
  -
        /* adjust pointer in perl magic */
           pHV = SvRV (pPrev -> _perlsv) ;
           if (mg = mg_find (pHV, '~'))
  @@ -1293,6 +1291,8 @@
       epxs_Embperl__Component__Param_create_obj(pParam,pSV, pRV,&r->Component.Param) ;
       epxs_Embperl__Component__Config_create_obj(pConfig,pSV, 
pRV,&r->Component.Config) ;
       
  +    r -> Component.pPrev = pPrev ;
  +
       c -> Param.nImport = -1 ;
       c -> Param.nFirstLine = 1 ;
   
  
  
  
  1.75.4.91 +369 -434  embperl/epmain.c
  
  Index: epmain.c
  ===================================================================
  RCS file: /home/cvs/embperl/epmain.c,v
  retrieving revision 1.75.4.90
  retrieving revision 1.75.4.91
  diff -u -r1.75.4.90 -r1.75.4.91
  --- epmain.c  25 Jan 2002 07:04:31 -0000      1.75.4.90
  +++ epmain.c  25 Jan 2002 20:19:26 -0000      1.75.4.91
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epmain.c,v 1.75.4.90 2002/01/25 07:04:31 richter Exp $
  +#   $Id: epmain.c,v 1.75.4.91 2002/01/25 20:19:26 richter Exp $
   #
   
###################################################################################*/
   
  @@ -663,7 +663,7 @@
           if (r -> pApacheReq == NULL)
               {
   #endif
  -            if (r -> nIOType != epIOPerl && (r -> Component.Config.bOptions & 
optSendHttpHeader))
  +            if (r -> Component.Config.bOptions & optSendHttpHeader)
                   oputs (r, "Content-type: text/html\n\n") ;
   
   #ifdef APACHE
  @@ -677,11 +677,7 @@
            /* mod_perl_sent_header(r -> pApacheReq, 1) ; */
   #endif
               if (r -> pApacheReq -> header_only)
  -             {
  -             if (!r -> Component.bAppendToMainReq)
  -                    CloseOutput (r) ;
                return ok ;
  -             }
               }
   #endif
           }
  @@ -725,495 +721,417 @@
       return ok ;
       }
   
  +
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  -/* End the output stream                                                        */
  +/* GenerateErrorPage                                                            */
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
   
   
  -static int EndOutput (/*i/o*/ register req * r,
  -                   /*in*/ int    rc,
  -                      /*in*/ SV *   pOutData) 
  -                      
   
  -    {
  -    SV * pOut = NULL ;
  -    int  bOutToMem = pOutData && SvROK (pOutData) ;
  -    SV * pCookie = NULL ;
  -    SV * pCookie2 = NULL ;
  -    int  bError = 0 ;
  -    STRLEN ldummy ;
  -    epTHX ;    
  +static int GenerateErrorPage (/*i/o*/ register req * r)
  +                     
   
  -#ifdef EP2OLDXSLT
  -    /* ### tmp ### */
  -    int bXSLT = 0 ;
  +    {
  +    epTHX_    
   
  -    if (strcmp (r -> Component.Config.sRecipe + strlen (r -> 
Component.Config.sRecipe) - 4 , "XSLT") == 0)
  +    dSP;                            /* initialize stack pointer      */
  +    
  +    if (r -> pApp -> Config.sMailErrorsTo)
           {
  -        bXSLT = 1 ;
  +        /* --- check if error should be mailed --- */
  +     PUSHMARK(sp);                   /* remember the stack pointer    */
  +        XPUSHs(r -> _perlsv) ;            /* push pointer to obeject */
  +        PUTBACK;
  +        perl_call_method ("MailErrorsTo", G_DISCARD) ; /* call the function         
    */
           }
  -#endif
       
  -    r -> Component.bEscModeSet = 0 ;
  -
  -    if (rc != ok ||  r -> bError)
  -        { /* --- generate error page if necessary --- */
  -     dSP;                            /* initialize stack pointer      */
  -        
  -        if (r -> pApp -> Config.sMailErrorsTo)
  -            {
  -            /* --- check if error should be mailed --- */
  -         PUSHMARK(sp);                   /* remember the stack pointer    */
  -            XPUSHs(r -> _perlsv) ;            /* push pointer to obeject */
  -            PUTBACK;
  -            perl_call_method ("MailErrorsTo", G_DISCARD) ; /* call the function     
        */
  -            }
  -        
  -     if (r -> Component.Config.bOptions & optReturnError)
  -         {
  -         r -> bError = 1 ;
  -         oRollbackOutput (r, NULL) ;
  -         if (bOutToMem)
  -             {
  -             pOut = SvRV (pOutData) ;
  -             sv_setsv (pOut, &sv_undef) ;
  -             }
  -         return ok ; /* No further output or header, this should be handle by the 
server */
  -         }    
  -        else if (!(r -> Component.Config.bOptions & optDisableEmbperlErrorPage))
  +    if (r -> Component.Config.bOptions & optReturnError)
  +     {
  +     oRollbackOutput (r, NULL) ;
  +     if (r -> Component.Param.pOutput && SvROK (r -> Component.Param.pOutput))
            {
  -         if (!r -> Component.bAppendToMainReq)
  -             {
  -
  -             oRollbackOutput (r, NULL) ; /* forget everything outputed so far */
  -             oBegin (r) ;
  +         sv_setsv (SvRV (r -> Component.Param.pOutput), &sv_undef) ;
  +         }
  +     r -> bExit = 1 ;
  +     return ok ; /* No further output or header, this should be handle by the 
server */
  +     }    
  +    else if (!(r -> Component.Config.bOptions & optDisableEmbperlErrorPage))
  +     {
  +     oRollbackOutput (r, NULL) ; /* forget everything outputed so far */
  +     oBegin (r) ;
   
  -             PUSHMARK(sp);                   /* remember the stack pointer    */
  -             XPUSHs(r -> _perlsv) ;            /* push pointer to obeject */
  -             PUTBACK;
  -             perl_call_method ("SendErrorDoc", G_DISCARD) ; /* call the function    
         */
  +     PUSHMARK(sp);                   /* remember the stack pointer    */
  +     XPUSHs(r -> _perlsv) ;            /* push pointer to obeject */
  +     PUTBACK;
  +     perl_call_method ("SendErrorDoc", G_DISCARD) ; /* call the function            
 */
   #ifdef APACHE
  -             if (r -> pApacheReq)
  -                 r -> pApacheReq -> status = 500 ;
  +     if (r -> pApacheReq)
  +         r -> pApacheReq -> status = 500 ;
   #endif
  -             }
  -         bError = 1 ;
  -         }
  -     if (!r -> Component.bAppendToMainReq)
  -         r -> bError = 0 ; /* error already handled */
        }
  -    
  +    r -> bError = 1 ;
  +
  +    return ok ;
  +    }
  +
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* SendHttpHeader                                                               */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
  +
  +
   
  -    if (!(r -> Component.Config.bOptions & optEarlyHttpHeader) && (r -> 
Component.Config.bOptions & optSendHttpHeader) && !bOutToMem)
  -        {  /* --- send http headers if not alreay done --- */
  -        if (!r -> Component.bAppendToMainReq)
  -            {                    
  -            if (!(r -> Component.Config.bOptions & optNoSessionCookies))
  -                pCookie = CreateSessionCookie (r, r -> pApp -> pUserHash, 'u', 1) ;
  -         /* pCookie2 = CreateSessionCookie (r, r -> pApp -> pStateHash, 's') ; */
  -             
  +static int SendHttpHeader (/*i/o*/ register req * r)
  +                     
  +
  +    {                    
  +    epTHX_
  +    SV * pCookie = NULL ;
  +    SV * pCookie2 = NULL ;
  +
  +    if (!(r -> Component.Config.bOptions & optNoSessionCookies))
  +        pCookie = CreateSessionCookie (r, r -> pApp -> pUserHash, 'u', 1) ;
  +    /* pCookie2 = CreateSessionCookie (r, r -> pApp -> pStateHash, 's') ; */
  +     
   #ifdef APACHE
  -         if (r -> pApacheReq)
  -             {
  -             SV *   pHeader ;
  -             char * p ;
  -             HE *   pEntry ;
  -             char * pKey ;
  -             I32    l ;
  -
  - 
  -             I32     i;
  -             I32     len;
  -             AV      *arr;
  -             SV      **svp;
  -
  -             /* loc = 0  =>  no location header found
  -              * loc = 1  =>  location header found
  -              * loc = 2  =>  location header + value found
  -              */
  -             I32     loc;
  -        
  -             hv_iterinit (r -> pThread -> pHeaderHash) ;
  -             while ((pEntry = hv_iternext (r -> pThread -> pHeaderHash)))
  -                 {
  -                 pKey     = hv_iterkey (pEntry, &l) ;
  -                 pHeader  = hv_iterval (r -> pThread -> pHeaderHash, pEntry) ;
  -                 loc = 0;
  -                 if (pHeader && pKey)
  -                     {                           
  -
  -                     if (stricmp (pKey, "location") == 0)
  -                         loc = 1;
  -                     if (stricmp (pKey, "content-type") == 0)  
  -                         {
  -                         p = NULL;
  -                         if ( SvROK(pHeader) && SvTYPE(SvRV(pHeader)) == SVt_PVAV ) 
  -                             {
  -                             arr = (AV *)SvRV(pHeader);
  -                             if (av_len(arr) >= 0) 
  -                                 {
  -                                 svp = av_fetch(arr, 0, 0);
  -                                 p = SvPV(*svp, ldummy);
  -                                 }
  -                             } 
  -                         else 
  -                             {
  -                             p = SvPV(pHeader, ldummy);
  -                             }
  -                         if (p) 
  -                             r->pApacheReq->content_type = 
pstrdup(r->pApacheReq->pool, p);
  -                         } 
  -                     else if (SvROK(pHeader)  && SvTYPE(SvRV(pHeader)) == SVt_PVAV 
) 
  -                         {
  -                         arr = (AV *)SvRV(pHeader);
  -                         len = av_len(arr);
  -                         for (i = 0; i <= len; i++) 
  -                             {
  -                             svp = av_fetch(arr, i, 0);
  -                             p = SvPV(*svp, ldummy);
  -                             table_add( r->pApacheReq->headers_out, 
pstrdup(r->pApacheReq->pool, pKey),
  -                                        pstrdup(r->pApacheReq->pool, p ) );
  -                             if (loc == 1) 
  -                                 {
  -                                 loc = 2;
  -                                 break;
  -                                 }
  -                             }
  -                         } 
  -                     else 
  +    if (r -> pApacheReq)
  +     {
  +     SV *   pHeader ;
  +     char * p ;
  +     HE *   pEntry ;
  +     char * pKey ;
  +     I32    l ;
  +
  +
  +     I32     i;
  +     I32     len;
  +     AV      *arr;
  +     SV      **svp;
  +
  +     /* loc = 0  =>  no location header found
  +      * loc = 1  =>  location header found
  +      * loc = 2  =>  location header + value found
  +      */
  +     I32     loc;
  +
  +     hv_iterinit (r -> pThread -> pHeaderHash) ;
  +     while ((pEntry = hv_iternext (r -> pThread -> pHeaderHash)))
  +         {
  +         pKey     = hv_iterkey (pEntry, &l) ;
  +         pHeader  = hv_iterval (r -> pThread -> pHeaderHash, pEntry) ;
  +         loc = 0;
  +         if (pHeader && pKey)
  +             {                           
  +
  +             if (stricmp (pKey, "location") == 0)
  +                 loc = 1;
  +             if (stricmp (pKey, "content-type") == 0)  
  +                 {
  +                 p = NULL;
  +                 if ( SvROK(pHeader) && SvTYPE(SvRV(pHeader)) == SVt_PVAV ) 
  +                     {
  +                     arr = (AV *)SvRV(pHeader);
  +                     if (av_len(arr) >= 0) 
                            {
  -                         p = SvPV(pHeader, ldummy);
  -                         table_set(r -> pApacheReq->headers_out, pstrdup(r -> 
pApacheReq->pool, pKey), pstrdup(r -> pApacheReq->pool, p)) ;
  -                         if (loc == 1) loc = 2;
  +                         svp = av_fetch(arr, 0, 0);
  +                         p = SvPV(*svp, ldummy);
                            }
  -
  -                     if (loc == 2) r->pApacheReq->status = 301;
  +                     } 
  +                 else 
  +                     {
  +                     p = SvPV(pHeader, ldummy);
  +                     }
  +                 if (p) 
  +                     r->pApacheReq->content_type = pstrdup(r->pApacheReq->pool, p);
  +                 } 
  +             else if (SvROK(pHeader)  && SvTYPE(SvRV(pHeader)) == SVt_PVAV ) 
  +                 {
  +                 arr = (AV *)SvRV(pHeader);
  +                 len = av_len(arr);
  +                 for (i = 0; i <= len; i++) 
  +                     {
  +                     svp = av_fetch(arr, i, 0);
  +                     p = SvPV(*svp, ldummy);
  +                     table_add( r->pApacheReq->headers_out, 
pstrdup(r->pApacheReq->pool, pKey),
  +                                pstrdup(r->pApacheReq->pool, p ) );
  +                     if (loc == 1) 
  +                         {
  +                         loc = 2;
  +                         break;
  +                         }
                        }
  +                 } 
  +             else 
  +                 {
  +                 p = SvPV(pHeader, ldummy);
  +                 table_set(r -> pApacheReq->headers_out, pstrdup(r -> 
pApacheReq->pool, pKey), pstrdup(r -> pApacheReq->pool, p)) ;
  +                 if (loc == 1) loc = 2;
                    }
   
  +             if (loc == 2) r->pApacheReq->status = 301;
  +             }
  +         }
   
  -             if (pCookie)
  -                 {
  -                 table_add(r -> pApacheReq->headers_out, sSetCookie, pstrdup(r -> 
pApacheReq->pool, SvPV(pCookie, ldummy))) ;
  -                 SvREFCNT_dec (pCookie) ;
  -                 }
  -             if (pCookie2)
  -                 {
  -                 table_add(r -> pApacheReq->headers_out, sSetCookie, pstrdup(r -> 
pApacheReq->pool, SvPV(pCookie2, ldummy))) ;
  -                 SvREFCNT_dec (pCookie2) ;
  -                 }
  -#ifdef EP2
  -             if (r -> Component.Config.bEP1Compat)  /*  Embperl 2 currently cannot 
calc Content Length */
  -#endif
  -             set_content_length (r -> pApacheReq, GetContentLength (r) + (r -> 
Component.pCurrEscape?2:0)) ;
  -             send_http_header (r -> pApacheReq) ;
  -#ifndef WIN32
  -             /* shouldn't be neccessary for newer mod_perl versions !? */
  -                /* mod_perl_sent_header(r -> pApacheReq, 1) ; */
  +
  +     if (pCookie)
  +         {
  +         table_add(r -> pApacheReq->headers_out, sSetCookie, pstrdup(r -> 
pApacheReq->pool, SvPV(pCookie, ldummy))) ;
  +         SvREFCNT_dec (pCookie) ;
  +         }
  +     if (pCookie2)
  +         {
  +         table_add(r -> pApacheReq->headers_out, sSetCookie, pstrdup(r -> 
pApacheReq->pool, SvPV(pCookie2, ldummy))) ;
  +         SvREFCNT_dec (pCookie2) ;
  +         }
  +#if 0
  +     if (r -> Component.Config.bEP1Compat)  /*  Embperl 2 currently cannot calc 
Content Length */
  +         set_content_length (r -> pApacheReq, GetContentLength (r) + (r -> 
Component.pCurrEscape?2:0)) ;
   #endif
  -                if (r -> Component.Config.bDebug & dbgHeadersIn)
  -                 {
  -                 int i;
  -                 array_header *hdrs_arr;
  -                 table_entry  *hdrs;
  -
  -                 hdrs_arr = table_elts (r -> pApacheReq->headers_out);
  -                 hdrs = (table_entry *)hdrs_arr->elts;
  -
  -                 lprintf (r -> pApp,   "[%d]HDR:  %d\n", r -> pThread -> nPid, 
hdrs_arr->nelts) ; 
  -                 for (i = 0; i < hdrs_arr->nelts; ++i)
  -                     if (hdrs[i].key)
  -                         lprintf (r -> pApp,   "[%d]HDR:  %s=%s\n", r -> pThread -> 
nPid, hdrs[i].key, hdrs[i].val) ; 
  -                 }
  -                }
  -         else
  +         send_http_header (r -> pApacheReq) ;
  +
  +        if (r -> Component.Config.bDebug & dbgHeadersIn)
  +            {
  +            int i;
  +            array_header *hdrs_arr;
  +            table_entry  *hdrs;
  +
  +            hdrs_arr = table_elts (r -> pApacheReq->headers_out);
  +         hdrs = (table_entry *)hdrs_arr->elts;
  +
  +            lprintf (r -> pApp,   "[%d]HDR:  %d\n", r -> pThread -> nPid, 
hdrs_arr->nelts) ; 
  +         for (i = 0; i < hdrs_arr->nelts; ++i)
  +             if (hdrs[i].key)
  +                    lprintf (r -> pApp,   "[%d]HDR:  %s=%s\n", r -> pThread -> 
nPid, hdrs[i].key, hdrs[i].val) ; 
  +            }
  +        }
  +    else
   #endif
  -             { 
  -             if (r -> nIOType == epIOCGI)
  -                 {            
  -                 char txt[100] ;
  -                 int  save = r -> Component.pOutput -> nMarker ;
  -                 SV *   pHeader ;
  -                 char * p ;
  -                 HE *   pEntry ;
  -                 char * pKey ;
  -                 I32    l ;
  -                 char * pContentType = "text/html";
  +     { 
  +     char txt[100] ;
  +     int  save = r -> Component.pOutput -> nMarker ;
  +     SV *   pHeader ;
  +     char * p ;
  +     HE *   pEntry ;
  +     char * pKey ;
  +     I32    l ;
  +     char * pContentType = "text/html";
  +        STRLEN ldummy ;
   
  -                 r -> Component.pOutput -> nMarker = 0 ; /* output directly */
  -        
  -                 hv_iterinit (r -> pThread -> pHeaderHash) ;
  -                 while ((pEntry = hv_iternext (r -> pThread -> pHeaderHash)))
  -                     {
  -                     pKey     = hv_iterkey (pEntry, &l) ;
  -                     pHeader  = hv_iterval (r -> pThread -> pHeaderHash, pEntry) ;
  +     r -> Component.pOutput -> nMarker = 0 ; /* output directly */
   
  -                     if (pHeader && pKey)
  -                         {                       
  -                         if (SvROK(pHeader)  && SvTYPE(SvRV(pHeader)) == SVt_PVAV ) 
  -                             {
  -                             AV * arr = (AV *)SvRV(pHeader);
  -                             I32 len = av_len(arr);
  -                             int i ;
  -
  -                             for (i = 0; i <= len; i++) 
  -                                 {
  -                                 SV ** svp = av_fetch(arr, i, 0);
  -                                 p = SvPV(*svp, ldummy);
  -                                 oputs (r, pKey) ;
  -                                 oputs (r, ": ") ;
  -                                 oputs (r, p) ;
  -                                 oputs (r, "\n") ;
  -                                 if (r -> Component.Config.bDebug & dbgHeadersIn)
  -                                     lprintf (r -> pApp,   "[%d]HDR:  %s: %s\n", r 
-> pThread -> nPid, pKey, p) ; 
  -                                 }
  -                             } 
  -                         else
  -                             {                                   
  -                             p = SvPV (pHeader, na) ;
  -                             if (stricmp (pKey, "content-type") == 0)
  -                                 pContentType = p ;
  -                             else
  -                                 {
  -                                 oputs (r, pKey) ;
  -                                 oputs (r, ": ") ;
  -                                 oputs (r, p) ;
  -                                 oputs (r, "\n") ;
  -                                 }
  -                             if (r -> Component.Config.bDebug & dbgHeadersIn)
  -                                 lprintf (r -> pApp,   "[%d]HDR:  %s: %s\n", r -> 
pThread -> nPid, pKey, p) ; 
  -                             }
  -                         }
  -                     }
  -                 
  -                 oputs (r, "Content-Type: ") ;
  -                 oputs (r, pContentType) ;
  -                 oputs (r, "\n") ;
  -                 sprintf (txt, "Content-Length: %d\n", GetContentLength (r) + (r -> 
Component.pCurrEscape?2:0)) ;
  -                 oputs (r, txt) ;
  -                 if (pCookie)
  -                     {
  -                     oputs (r, sSetCookie) ;
  +     hv_iterinit (r -> pThread -> pHeaderHash) ;
  +     while ((pEntry = hv_iternext (r -> pThread -> pHeaderHash)))
  +         {
  +         pKey     = hv_iterkey (pEntry, &l) ;
  +         pHeader  = hv_iterval (r -> pThread -> pHeaderHash, pEntry) ;
  +
  +         if (pHeader && pKey)
  +             {                           
  +             if (SvROK(pHeader)  && SvTYPE(SvRV(pHeader)) == SVt_PVAV ) 
  +                 {
  +                 AV * arr = (AV *)SvRV(pHeader);
  +                 I32 len = av_len(arr);
  +                 int i ;
  +
  +                 for (i = 0; i <= len; i++) 
  +                     {
  +                     SV ** svp = av_fetch(arr, i, 0);
  +                     p = SvPV(*svp, ldummy);
  +                     oputs (r, pKey) ;
                        oputs (r, ": ") ;
  -                     oputs (r, SvPV(pCookie, na)) ;
  +                     oputs (r, p) ;
                        oputs (r, "\n") ;
  -                     SvREFCNT_dec (pCookie) ;
  +                     if (r -> Component.Config.bDebug & dbgHeadersIn)
  +                         lprintf (r -> pApp,   "[%d]HDR:  %s: %s\n", r -> pThread 
-> nPid, pKey, p) ; 
                        }
  -                 if (pCookie2)
  +                 } 
  +             else
  +                 {                               
  +                 p = SvPV (pHeader, na) ;
  +                 if (stricmp (pKey, "content-type") == 0)
  +                     pContentType = p ;
  +                 else
                        {
  -                     oputs (r, sSetCookie) ;
  +                     oputs (r, pKey) ;
                        oputs (r, ": ") ;
  -                     oputs (r, SvPV(pCookie2, na)) ;
  +                     oputs (r, p) ;
                        oputs (r, "\n") ;
  -                     SvREFCNT_dec (pCookie2) ;
                        }
  -
  -                 oputs (r, "\n") ;
  -
  -                 r -> Component.pOutput -> nMarker = save ;
  +                 if (r -> Component.Config.bDebug & dbgHeadersIn)
  +                     lprintf (r -> pApp,   "[%d]HDR:  %s: %s\n", r -> pThread -> 
nPid, pKey, p) ; 
                    }
                }
            }
  -     }
  +     
  +     oputs (r, "Content-Type: ") ;
  +     oputs (r, pContentType) ;
  +     oputs (r, "\n") ;
  +     sprintf (txt, "Content-Length: %d\n", GetContentLength (r) + (r -> 
Component.pCurrEscape?2:0)) ;
  +     oputs (r, txt) ;
  +     if (pCookie)
  +         {
  +         oputs (r, sSetCookie) ;
  +         oputs (r, ": ") ;
  +         oputs (r, SvPV(pCookie, na)) ;
  +         oputs (r, "\n") ;
  +         SvREFCNT_dec (pCookie) ;
  +         }
  +     if (pCookie2)
  +         {
  +         oputs (r, sSetCookie) ;
  +         oputs (r, ": ") ;
  +         oputs (r, SvPV(pCookie2, na)) ;
  +         oputs (r, "\n") ;
  +         SvREFCNT_dec (pCookie2) ;
  +         }
   
  -    /* --- output the content if not alreay done --- */
  +     oputs (r, "\n") ;
   
  -    if (bOutToMem)
  -        pOut = SvRV (pOutData) ;
  +     r -> Component.pOutput -> nMarker = save ;
  +     }
   
  +    return ok ;
  +    }
   
  -#ifdef APACHE
  -    if ((r -> pApacheReq == NULL || !r -> pApacheReq -> header_only) && 
  -     (!(r -> Component.Config.bOptions & optEarlyHttpHeader) || r -> 
Component.bAppendToMainReq))
  -#else
  -    if (!(r -> Component.Config.bOptions & optEarlyHttpHeader) || r -> 
Component.bAppendToMainReq)
  -#endif
  -        {
  -#ifdef EP2
  -     if (r -> Component.Config.bEP1Compat && r -> Component.pCurrEscape)
  -#else
  -     if (r -> Component.pCurrEscape)
  -#endif               
  -         oputs (r, "\r\n") ;
  -#ifdef EP2OLDXSLT
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* End the output stream to memory                                              */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
   
  -        if (bXSLT && !bError && !r -> Component.Config.bEP1Compat)
  -            {
  -            char * pData ;
  -            int    l ;
   
  +static int OutputToMem (/*i/o*/ register req * r)
  +
  +    {
  +    epTHX_
  +    SV * pOut = SvRV (r -> Component.Param.pOutput) ;
  +    char * pData ;
  +    STRLEN    l ;
  +             
  +    if (!r -> bError && r -> Component.pOutputSV && !r -> Component.pImportStash)
  +     {
  +     sv_setsv (pOut, r -> Component.pOutputSV) ;
  +     }
  +    else
  +     {
  +     if (!r -> bError && !r -> Component.pImportStash)
  +         {
            tDomTree * pDomTree = DomTree_self (r -> Component.xCurrDomTree) ;
            Node_toString (r, pDomTree, pDomTree -> xDocument, 0) ;
  +         }
   
  -            pOut = newSVpv ("", 0) ;
  +     if (!r -> Component.Config.bEP1Compat)
            oputs (r, "\r\n") ;
  -            l = GetContentLength (r) + 1 ;
  -            
  -            SvGROW (pOut, l) ;
  -            pData = SvPVX (pOut) ;
  -            oCommitToMem (r, NULL, pData) ;
  -            oRollbackOutput (r, NULL) ;
  -            SvCUR_set (pOut, l - 1) ;
  -
  -            if (r -> Component.bAppendToMainReq)
  -                oBegin (r) ;
  -
  -            
  -            if (strstr (r -> Component.Config.sRecipe, "LibXSLT"))
  -                {
  -#ifdef LIBXSLT
  -                if (r -> Component.Config.bDebug & dbgXSLT)
  -                    lprintf (r -> pApp,  "[%d]XSLT: call libxslt\n", r -> pThread 
-> nPid) ;
  -
  -                if ((rc = embperl_LibXSLT_Text2Text   (r, r -> pConf -> 
pReqParameter, pOut)) != ok)
  -                    return rc ;
  -#else
  -                strcpy (r -> errdat1, "libxslt not supported") ;
  -                return 9999 ;
  -#endif
  -                }
  -            else if (strstr (r -> Component.Config.sRecipe, "Xalan"))
  -                {
  -#ifdef XALAN
  -                if (r -> Component.Config.bDebug & dbgXSLT)
  -                    lprintf (r -> pApp,  "[%d]XSLT: call xalan\n", r -> pThread -> 
nPid) ;
  +     l = GetContentLength (r) + 1 ;
  +    
  +     sv_setpv (pOut, "") ;
  +     SvGROW (pOut, l) ;
  +     pData = SvPVX (pOut) ;
  +     oCommitToMem (r, NULL, pData) ;
  +     SvCUR_set (pOut, l - 1) ;
  +     }
  +    
  +    return ok ;
  +    }
   
  -                if ((rc = embperl_Xalan_Text2Text   (r, r -> pConf -> 
pReqParameter, pOut)) != ok)
  -                    return rc ;
  -#else
  -                strcpy (r -> errdat1, "xalan not supported") ;
  -                return 9999 ;
  -#endif
  -                }
  -            }
  -#endif
   
  -        if (bOutToMem)
  -            {
  -            char * pData ;
  -            STRLEN    l ;
  -#ifdef EP2
  -                     
  -         if (!bError && !r -> Component.Config.bEP1Compat && r -> 
Component.pOutputSV)
  -             {
  -             sv_setsv (pOut, r -> Component.pOutputSV) ;
  -             }
  -         else
  -             {
  -             if (!bError && !r -> Component.Config.bEP1Compat)
  -                 {
  -                 tDomTree * pDomTree = DomTree_self (r -> Component.xCurrDomTree) ;
  -                 Node_toString (r, pDomTree, pDomTree -> xDocument, 0) ;
  -                 }
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* End the output stream to file                                                */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
   
  -             if (!r -> Component.Config.bEP1Compat)
  -                 oputs (r, "\r\n") ;
  -#endif               
  -             l = GetContentLength (r) + 1 ;
  -            
  -             sv_setpv (pOut, "") ;
  -             SvGROW (pOut, l) ;
  -             pData = SvPVX (pOut) ;
  -             oCommitToMem (r, NULL, pData) ;
  -             SvCUR_set (pOut, l - 1) ;
  -#ifdef EP2
  -             }
  -#endif               
  -            }
  -        else
  -            {
  -            if (r -> Component.bAppendToMainReq)
  -                {
  -                tComponent * lc = r -> Component.pPrev ;
   
  +static int OutputToFile (/*i/o*/ register req * r)
   
  -#ifdef EP2
  -                 {
  -                 if (!bError && !r -> Component.pImportStash)
  -                     {
  -                     tDomTree * pDomTree = DomTree_self (r -> 
Component.xCurrDomTree) ;
  -#ifdef EP2OLDXSLT
  -                        if (bXSLT)
  -                            {
  -                            int len = GetContentLength (r) + 1 ;
  -                            char * pData = _malloc (r, len) ;
  -                            oCommitToMem (r, NULL, pData) ;
  -                            oRollbackOutput (r, NULL) ;
  -                            lc -> xCurrNode =  Node_appendChild (r -> pApp, 
DomTree_self (lc -> xCurrDomTree),
  -                                                             lc -> xCurrNode, 
  -                                                             lc -> 
nCurrRepeatLevel, 
  -                                                                 ntypCDATA,
  -                                                                    0,
  -                                                                    pData, len - 1, 
0, 0, "XSLT Result") ;
  -                            }
  -                        else
  -#endif
  -                            {
  -                            if (lc -> xCurrNode)
  -                             {
  -                             if (r -> Component.pOutputSV)
  -                                 {
  -                                 STRLEN len ;
  -                                 char * p = SvPV (r -> Component.pOutputSV, len) ;
  -                                 lc -> xCurrNode = Node_insertAfter_CDATA (r -> 
pApp, p, len, 0, DomTree_self (lc -> xCurrDomTree), lc -> xCurrNode, lc -> 
nCurrRepeatLevel) ;
  -                                 }
  -                             else if (pDomTree -> xDocument)
  -                                 {
  -                                 lc -> xCurrNode = Node_insertAfter (r -> pApp, 
pDomTree, pDomTree -> xDocument, 0, DomTree_self (lc -> xCurrDomTree), lc -> 
xCurrNode, lc -> nCurrRepeatLevel) ;
  -                                 }
  -                             }
  -                            }
  -                     }
  -                 }
  -#endif
  -             }
  -            else
  -             {
  -                oCommit (r, NULL) ;
  -#ifdef EP2
  -             if (!bError && !r -> Component.Config.bEP1Compat && !r -> 
Component.pImportStash 
  -#ifdef EP2OLDXSLT
  -                 && !bXSLT
  -#endif
  -                 )
  -                 {
  -                 if (r -> Component.pOutputSV)
  -                     {
  -                     STRLEN l ;
  -                     char * p = SvPV (r -> Component.pOutputSV, l) ;
  -                     owrite (r, p, l) ;
  -                     }
  -                 else
  -                     {
  -                     tDomTree * pDomTree = DomTree_self (r -> 
Component.xCurrDomTree) ;
  -                     Node_toString (r, pDomTree, pDomTree -> xDocument, 0) ;
  -                     oputs (r, "\r\n") ;
  -                     }
  -                 }
  -#endif
  -             }
  +    {
  +    epTHX_
  +    oCommit (r, NULL) ;
  +    if (!r -> bError && !r -> Component.pImportStash) 
  +     {
  +     if (r -> Component.pOutputSV)
  +         {
  +         STRLEN l ;
  +         char * p = SvPV (r -> Component.pOutputSV, l) ;
  +         owrite (r, p, l) ;
            }
  -        }
  -    else
  -        {
  -        oRollbackOutput (r, NULL) ;
  -        if (bOutToMem)
  -            sv_setsv (pOut, &sv_undef) ;
  -#ifdef EP2
  -     else if (!r -> Component.Config.bEP1Compat)
  +     else
            {
            tDomTree * pDomTree = DomTree_self (r -> Component.xCurrDomTree) ;
            Node_toString (r, pDomTree, pDomTree -> xDocument, 0) ;
  +         oputs (r, "\r\n") ;
            }
  -#endif
  -        }    
  +     }
  +    return ok ;
  +    }
  +
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* Append tree to upper tree                                                    */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
   
   
  +static int AppendToUpperTree (/*i/o*/ register req * r)
  +
  +    {
  +    epTHX_
  +    tDomTree * pDomTree = DomTree_self (r -> Component.xCurrDomTree) ;
  +    tComponent * lc = r -> Component.pPrev ;
  +    if (lc -> xCurrNode)
  +     {
  +     if (r -> Component.pOutputSV)
  +         {
  +         STRLEN len ;
  +         char * p = SvPV (r -> Component.pOutputSV, len) ;
  +         lc -> xCurrNode = Node_insertAfter_CDATA (r -> pApp, p, len, 0, 
DomTree_self (lc -> xCurrDomTree), lc -> xCurrNode, lc -> nCurrRepeatLevel) ;
  +         }
  +     else if (pDomTree -> xDocument)
  +         {
  +         lc -> xCurrNode = Node_insertAfter (r -> pApp, pDomTree, pDomTree -> 
xDocument, 0, DomTree_self (lc -> xCurrDomTree), lc -> xCurrNode, lc -> 
nCurrRepeatLevel) ;
  +         }
  +     }
       return ok ;
       }
  +
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* End the output stream                                                        */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
  +
  +
  +static int EndOutput (/*i/o*/ register req * r,
  +                   /*in*/ int    rc,
  +                      /*in*/ SV *   pOutData) 
  +                      
  +
  +    {
  +    epTHX_
  +
  +    
  +    r -> Component.bEscModeSet = 0 ;
  +
  +    if (rc != ok ||  r -> bError)
  +        { /* --- generate error page if necessary --- */
  +        GenerateErrorPage (r) ;
  +        if (r -> bExit)
  +            return ok ;
  +        }
  +
  +    if (!(r -> Component.Config.bOptions & optEarlyHttpHeader) && 
  +        (r -> Component.Config.bOptions & optSendHttpHeader) && !r -> 
Component.Param.pOutput)
  +        SendHttpHeader (r) ;
  +
  +    if (r -> Component.Param.pOutput)
  +        return OutputToMem (r) ;
       
  +    return OutputToFile (r) ;
  +    }
  +
   
   
   /* ---------------------------------------------------------------------------- */
  @@ -1481,6 +1399,11 @@
       return ok ;
       }
   
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* Run Request                                                                  */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
   
   
   int     embperl_RunRequest  (/*in*/ pTHX_
  @@ -1503,6 +1426,11 @@
       }
       
   
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
  +/* Run Component                                                                */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
   
   int     embperl_RunComponent(/*in*/ tReq *           r,
                                /*in*/ SV *             pPerlParam)
  @@ -1537,10 +1465,17 @@
           LEAVE;
           r -> Component.bReqRunning = 0 ;
   
  -        /* --- send http header and data to the browser if not already done --- */
  -        if ((rc = EndOutput (r, rc, r -> Component.Param.pOutput)) != ok)
  -            LogError (r, rc) ;
   
  +        if (!r -> bError)
  +            {
  +            if (r -> Component.Param.pOutput)
  +                OutputToMem (r) ;
  +            else if (r -> Component.pOutput == r -> Component.pPrev -> pOutput)
  +                AppendToUpperTree (r) ;
  +            else
  +                OutputToFile (r) ;
  +            }
  +        
           embperl_CleanupComponent  (r, pComponent) ;
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to