Loading ...
Sorry, an error occurred while loading the content.

FW: $r->headers_out Location and Set-Cookie

Expand Messages
  • Garrett Goebel
    [Note: reposting, the original post appears to have dropped through the cracks] ... Why? ... And gives the following recipe: Example A-3. redirect_cookie.pl
    Message 1 of 3 , Sep 4, 2003
    • 0 Attachment
      FW: $r->headers_out Location and Set-Cookie

      [Note: reposting, the original post appears to have dropped through the cracks]

      Geoffrey Young wrote:
      > > That's when you use Apache::compat, doing the mp1 syntax.
      > > In mp2-speak that would be:
      > >
      > >   $r->err_headers_out->add('Set-Cookie' => $packed_cookie);
      > >   $r->headers_out->set('Location' => $url);
      > >   $r->status(REDIRECT);
      > >
      > > notice that you don't need to call $r->send_http_header, it
      > > doesn't exist in mp2.
      >
      > not to mention it's entirely unnecessary (and undesirable) to
      > send headers on error responses such as redirects.

      Why?

      Appendix A.7 from the Stas' Practical mod_perl book states:

      > You should use err_headers_out( ), not headers_out( ),
      > when you want to send cookies in a REDIRECT response or
      > in any other non-2XX response

      And gives the following recipe:

        Example A-3. redirect_cookie.pl
        use Apache::Constants qw(REDIRECT OK);
        my $r = shift;
        # prepare the cookie in $cookie
        $r->err_headers_out->add('Set-Cookie' => $cookie);
        $r->headers_out->set(Location => $location);
        $r->status(REDIRECT);
        $r->send_http_header;
        return OK;

      How would you have written it?

       
      > and you should never set $r->status from a handler - for
      > Registry scripts it's ok, since we use it as a hack to get
      > around some things, but handlers should never manipulate the
      > value of $r->status.

      Why is that?


      --
      Garrett Goebel
      IS Development Specialist

      ScriptPro                   Direct: 913.403.5261
      5828 Reeds Road               Main: 913.384.1008
      Mission, KS 66202              Fax: 913.384.2180
      www.scriptpro.com          garrett at scriptpro dot com

    • Geoffrey Young
      ... not only did I get two of these already, but I also posted a reply :) --Geoff -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info:
      Message 2 of 3 , Sep 4, 2003
      • 0 Attachment
        Garrett Goebel wrote:
        > [Note: reposting, the original post appears to have dropped through the
        > cracks]

        not only did I get two of these already, but I also posted a reply :)

        --Geoff



        --
        Reporting bugs: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
      • Garrett Goebel
        ... My bad. It was an old thread and I didn t scan far enough through the list archives. Problem must be at the company mail server. I ve been getting
        Message 3 of 3 , Sep 4, 2003
        • 0 Attachment
          RE: FW: $r->headers_out Location and Set-Cookie

          Geoffrey Young wrote:
          > Garrett Goebel wrote:
          > > [Note: reposting, the original post appears to have dropped
          > > through the cracks]
          >
          > not only did I get two of these already, but I also posted a reply :)

          My bad. It was an old thread and I didn't scan far enough through the list archives.

          Problem must be at the company mail server. I've been getting infrequent diagnostic messages from various mailing list daemons.

          Apologies...

          --
          Garrett Goebel
          IS Development Specialist

          ScriptPro                   Direct: 913.403.5261
          5828 Reeds Road               Main: 913.384.1008
          Mission, KS 66202              Fax: 913.384.2180
          www.scriptpro.com          garrett at scriptpro dot com

        Your message has been successfully submitted and would be delivered to recipients shortly.