Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: CGI error: "Invalid header value contains a newline not followed by whitespace"

by MyMonkName (Acolyte)
on Feb 04, 2012 at 21:08 UTC ( [id://951853]=note: print w/replies, xml ) Need Help??


in reply to Re^3: CGI error: "Invalid header value contains a newline not followed by whitespace"
in thread CGI error: "Invalid header value contains a newline not followed by whitespace"

Not really. Per the documentation, apache will ignore cookie headers in a redirect request.
  • Comment on Re^4: CGI error: "Invalid header value contains a newline not followed by whitespace"

Replies are listed 'Best First'.
Re^5: CGI error: "Invalid header value contains a newline not followed by whitespace"
by tobyink (Canon) on Feb 04, 2012 at 21:20 UTC

    You say this because you've tried it? Or you say this because you trust the documentation?

    The documentation doesn't say that Apache ignores the cookie - it claims that browsers ignore cookies when they are redirected. It's wrong. They don't. (Though in some early versions of Safari there was a bug where it did. This was fixed though.)

    And if they did ignore cookies when redirecting, then why do you think that structuring your code slightly differently will change things? However your code works internally, if you're printing the same HTTP headers, restructuring the code won't change anything. Browsers don't see your code - they see the HTTP headers.

      You are right, I meant browser, not apache. At any rate, on my platform, for whatever reason, your code does not result in my browsers (FF, Chrome) storing the cookies it sends. My "incorrect" code does, though; all the more reason to not trust documentation...

      --EDIT--

      Nevermind. Your code works actually! What can I say.

      In exactly what version of CGI.pm did this behaviour change remains an open question, though. I was using the code in my OP quite satisfactorily for at least a year and a half...

        Then you're probably doing something else wrong. Go to http://buzzword.org.uk/2012/ and click on redir-cookie.cgi. It will redirect you. Now check your browser's cookie jar.

        The source for redir-cookie.cgi is:

        #!/usr/bin/perl use CGI; my $cgi = CGI->new; print $cgi->redirect( -uri => "http://buzzword.org.uk/", -cookie => [ $cgi->cookie(-name=>'foobar', -value=>123) ], );

        I've tested this in Opera 12, Firefox 3.6.9, Lynx 2.8.6rel.4 and Internet Explorer 8.0. It works.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-23 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found