in reply to (Ovid) Re: Apache+cgi problem
in thread Apache+cgi problem

Not sure how to say this without sounding as if I am nitpicking an otherwise great post (++), but ah well, I feel bold.

I just would like to point out that while "Content-type: text/html\n\n" works often, if you are gonna do that instead of useing CGI, you should really end the lines with double "\015\012" instead, like this:print "Content-type: text/html\015\012\015\012";.

This is more cross-platform, and would work on most machines, except (I think ) VMS and non-ASCII machines. "\015\012" is the defined CRLF sequence for HTTP-headers.

In reality though, I think that it is just as good to get into the habit of useing the CGI module right away. Just like you say. It takes care of all such concerns. :)

Replies are listed 'Best First'.
(Ovid) Re(3): Apache+cgi problem
by Ovid (Cardinal) on Feb 16, 2002 at 17:10 UTC

    I can't find the link, but I seem to recall a response from Tom Christiansen to Abigail where he points out that the line endings are typically a non-issue. This is due to this being such a ubiquitous issue that every Web server (that I am aware of) checks the line endings and adjusts them as necessary. Otherwise, the vast majority of scripts ported to another OS could potentially die a horrible death.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      I remember the post on clpm too .... I think the point here is that what your program is emitting are CGI headers and not HTTP ones where the line separators should be as described. Indeed the draft CGI/1.2 Specification says :

         The server must translate the header data from the CGI
         header field syntax to the HTTP header field syntax if
         these differ. For example, the character sequence for
         newline (such as Unix's ASCII NL) used by CGI scripts 
         may not be the same as that used by HTTP (ASCII CR
         followed by LF). The server must also resolve any
         conflicts between header fields returned by the script
         and header fields that it would otherwise send itself.
      

      Update: I didn't find the original post to which Ovid referred however i did find This thread in CLPM which has all manner of good stuff in it

      /J\