Il 14/12/10 00.44, Francesco Vollero ha scritto:
Il 13/12/10 22.56, Gerhard Hoffmann ha scritto:
endl is a so-called manipulator in C++. It outputs '\n'
and flushes the output buffer (using the flush method in the stream).

So, I would change the order:

cout<< "Content-type: text/plain"<< endl<< endl<< "Hello, World!"<< endl;

Since the most smart way to do is *following* HTTP Protocol [1]:
"HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body (see appendix 19.3 for tolerant applications)."

That mean, the most common way is to use my function or just:
cout << "Content-Type: text/plain\r\n\r\n"<<"Hello World, it's me"<<endl;

And i can use endl on the last line, because hello world message is an entity-body.

Regards,
Francesco

Sorry i forgot to paste the link

[1] http://www.ietf.org/rfc/rfc2616.txt
Don't know if that solves it.

Regards


On Mon, Dec 13, 2010 at 10:18:58PM +0100, Jean-Francois wrote:
Hello,

Sorry for posting basic question here, would you please let me know why such
script does'nt work (error with "Premature end of script headers") ?


#include<iostream>
using namespace std;

int main()
{
cout<<  "Content-type: text/plain"<<  endl<<  endl<<  "Hello, World!";
}


It actually shows flush needed on google but I'm not able to do a hello world
CGI in C++.

Thjanks for your help,

Reagrds

Reply via email to