On Sun, Jul 08, 2018 at 07:53:41AM -0500, Edgar Pettijohn III wrote:
> I am playing around with cgi written in c. I am getting what seems like a
> weird error though. I'm starting off with a very basic program:
> 
> #include <stdio.h>
> 
> int
> main(void)
> {
>         fprintf(stdout,
>                "<html>\n"
>                "<head>\n"
>                "<title>test</title>\n"
>                "</head>\n"
>                "<body>\n"
>                );

you need to output a header, something like
printf("Status: 200 OK\r\nContent-Type: text/html\r\n\r\n");

you might also want to consider using kcgi (in ports)

https://kristaps.bsd.lv/kcgi/

> 
>         fprintf(stdout, "it works\n");
> 
>         fprintf(
>                stdout,
>                "</body>\n"
>                "</html>\n"
>               );
> 
>         return (0);
> }
> 
> I set up bgplg to make sure that httpd and slowcgi are working correctly.
> Here is the only debug info I could find.
> 
> doas httpd -dvv
> startup
> server_privinit: adding server default
> socket_rlimit: max open files 1024
> socket_rlimit: max open files 1024
> socket_rlimit: max open files 1024
> server_launch: configuring server default
> server_launch: running server default
> server_launch: configuring server default
> server_launch: configuring server default
> server_launch: running server default
> server_launch: running server default
> default 127.0.0.1 - - [08/Jul/2018:07:45:51 -0500] "GET /cgi-bin/bgplg
> HTTP/1.1" 200 0
> default 127.0.0.1 - - [08/Jul/2018:07:45:55 -0500] "GET /cgi-bin/test
> HTTP/1.1" 500 0
> server default, client 1 (1 active), 127.0.0.1:46773 -> 127.0.0.1, empty
> stdout (500 Internal Server Error)
> 
> I'm not sure what `empty stdout' means.
> 
> Thanks,
> 
> Edgar
> 

-- 
I'm not entirely sure you are real.

Reply via email to