www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/11/08:38:53

Message-Id: <199910110416.HAA05344@ankara.Foo.COM>
From: "S. M. Halloran" <mitch AT duzen DOT com DOT tr>
Organization: User RFC 822- and 1123-compliant
To: bub <bub AT null DOT videotron DOT ca>, djgpp AT delorie DOT com
Date: Mon, 11 Oct 1999 08:22:36 +0200
MIME-Version: 1.0
Subject: Re: Question regarding CGI
In-reply-to: <38010A1D.BCF60B35@null.videotron.ca>
X-mailer: Pegasus Mail for Win32 (v3.12)
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 
> Been using djgpp for a little while now on windows nt.
> Today I decided to try to write a CGI application to use via
> Windows NT's Peer web service's web server. The code ( fairly
> simplistic, included below ). I get an error when I try to run
> it, claiming that the application didn't return the proper http
> headers, it then includes nothing as the error.
> I compiled the same code under Visual C++ on my work PC, and
> it runs fine... what gives ?
> 
> I couldn't find any references to CGI or problems related to it
> in the DJGPP FAQ.
> 
> TIA !
> 
> 
> - Bub
> 
> /*----------- foo.c --------------------
>    cgi app that prints blah blah in red 
> */
> 
> #include <stdio.h>
> 
> int 
> main(int argc, char **argv)
> {
>   fprintf(stdout,"Content-Type: text/html\n\n");
                                           ^^^^^
Try this: "Content-Type: text/html\r\n\r\n"
Read the RFCs on HTTP 1.0 and 1.1 so that you understand why.

You should also be aware of your server's capabilities.  The server must lead 
the response to the client with a 3-digit code and an optional message, 
followed by valid HTTP headers, and then the message body.  If your CGI app is 
expected to supply all headers and the server merely transfers the output, you 
may have to supply an entire response that conforms with HTTP.  If so, then 
know the spec.

The Visual C++ compiler may be translating the '\n' as '\r\n' for you.  Try 
this:  instead of stdout, save to a file the DJGPP- and Visual C++ output and 
look at it with a binary editor (such as MS-DOS Edit with the 'open binary' 
checked).

>   fprintf(stdout,"<html> <body bgcolor='000000' text='ff0000'>\n"
>                  "<h1> Blah blah blah </h1>\n"
>                  "</body> </html>");
> 
> return 0;
> }



Mitch Halloran
Research (Bio)chemist
Duzen Laboratories Group
Ankara       TURKEY

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019