From: Ruby Tuesday Date: 2004-02-23T10:54:50+09:00 Subject: Re: Puzzling... > The following works for me: > > #!C:/ruby/bin/ruby.exe > print "Content-type: text/html\n\n" <<<<< > print "1st line " > print "2nd line " > print "3rd line " The above works for me as well on both IE6 and Mozilla. But try to change the header to the following: > #!C:/ruby/bin/ruby.exe > print "Content-type: text/plain\n\n" <<<<<<< > print "1st line " > print "2nd line " > print "3rd line " Again, both method works with Mozilla. So, I am begining to think that IE is mis-behaving! Unfortunately, this is the basic RFC for header. Please confirm. Thanks "Trey Campbell" wrote in message news:4038C68E.8010805@midsouth.rr.com... > Ruby Tuesday wrote: > > >I've tried both using \n\n and \r\n\r\n on Perl and Ruby as well. Both > >resulted the same. > > > >When I tried it with Mozilla, the "Content-type: text/plain" works. Do you > >guys think it is the IE things? Thanks > > > > > > > I doubt that it's an IE vs. Mozilla. This is just basic HTTP stuff. The > RFC specifies that each message header end with a CRLF, with a "line" > containing only a CRLF separating the headers from the message body. So > your Content-type header, ending with two (or more) such sequences > should work; the first to terminate the header the second to separate > the header and body, and any subsequent ones are treated as part of the > body. > > print "Content-type: text/html\r\n\r\n" > print "Your body goes here..." > > Should and, at least in my experience, does work. > > The RFC also admonishes applications to be tolerant and accept slightly > incorrectly formed documents: > > "The line terminator for message-header fields is the sequence CRLF. > However, we recommend that applications, when parsing such headers, > recognize a single LF as a line terminator and ignore the leading CR." > > (from http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.3) > > The following works for me: > > #!C:/ruby/bin/ruby.exe > print "Content-type: text/html\n\n" > print "1st line " > print "2nd line " > print "3rd line " > > I can replace the first line with one ending in \r\n\r\n (what I had > originally because it's correct, not just tolerated by well-behaved > applications). I can also replace with \n\n\n (or \r\n\r\n\r\n) which > generates an extra blank line in the document. > > BTW, I'm running on WinXP SP1 with Apache 2.0.47 and Ruby 1.8.0. I > tested with IE 6.0 and FireFox 0.8. The directory that contains the > scripts is set up as follows in httpd.conf: > > > Options Indexes FollowSymLinks ExecCGI > Order allow,deny > Allow from all > > > Bottom line, what you posted *should* work. It seems like something else > must be going on (that is, the problem's not in your Ruby script itself). > > Cheers, > Trey > > >