Re: PHP - I give up.
From: Michael Wojcik (mwojcik_at_newsguy.com)
Date: 03/01/04
- Next message: TLOlczyk: "Re: EOL Anchor under Windows"
- Previous message: Chee Liang: "Algorithm for reading from continuous stream"
- Next in thread: TLOlczyk: "Re: PHP - I give up."
- Reply: TLOlczyk: "Re: PHP - I give up."
- Reply: Richard Heathfield: "Re: PHP - I give up."
- Reply: Bill Godfrey: "Re: PHP - I give up."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Mar 2004 16:23:08 GMT
In article <c1q0mn$bli$1@sparta.btinternet.com>, Richard Heathfield <dontmail@address.co.uk.invalid> writes:
>
> #include <stdio.h>
> int main(void)
> {
> printf("Content-Type: text/html\n\n");
Bill's already noted that he no longer has the account to test this,
but I thought I'd point out that this program may not be correct,
depending on C implementation behavior. The HTTP specs (1.0 or 1.1)
require that headers be terminated with the sequence CR LF, and the
content-body be separated from the headers with an empty line
terminated with CR LF.
If the C implementation is one that translates \n into CR LF for
text-mode streams (typical for implementations on Windows), then
this printf will produce valid HTTP output. If the implementation
translates \n into a bare LF (typical for Unix), then it won't.
Servers may recognize bare LF as equivalent to CR LF, but they are
not obligated to by the HTTP (or CGI) standards.
The simple program Bill posted also had this implementation-defined
behavior, which could have been the source of his problem.
Unfortunately there's no portable solution to this, since there's no
portable way to determine what an implementation does with \n, or to
force standard output into binary mode, or to write to standard
output in binary mode regardless of how it's opened. Of course it's
relatively easy to handle once you know what your implementation
does.
-- Michael Wojcik michael.wojcik@microfocus.com Most people believe that anything that is true is true for a reason. These theorems show that some things are true for no reason at all, i.e., accidentally, or at random. -- G J Chaitin
- Next message: TLOlczyk: "Re: EOL Anchor under Windows"
- Previous message: Chee Liang: "Algorithm for reading from continuous stream"
- Next in thread: TLOlczyk: "Re: PHP - I give up."
- Reply: TLOlczyk: "Re: PHP - I give up."
- Reply: Richard Heathfield: "Re: PHP - I give up."
- Reply: Bill Godfrey: "Re: PHP - I give up."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|