cgistarthdrs(), cgiendhdrs() - start/end HTTP headers


#include "cgi.h"

int  cgistarthdrs(cp, type)
CGI  *cp;
char *type;

int  cgiendhdrs(cp)
CGI  *cp;

The cgistarthdrs() function is called to start printing the HTTP headers for the CGI program's output. As it begins the headers, it must be called before any other output is printed. The type parameter is a string indicating what Content-Type should be printed; it defaults to "text/html" if CHARPN is given. Further headers (if any) can be printed after the cgistarthdrs() call.

The cgiendhdrs() function is called after all headers are printed, and before the CGI program's document content is printed; it prints a newline to indicate the end of headers. Both cgistarthdrs() and cgiendhdrs() return 1 if successful and 0 on error.

Even if a given CGI program doesn't make use of HTTP headers directly, it should still call cgistarthdrs() and cgiendhdrs(). Among other things, this will allow the state variables set with putcgi() to be sent/saved; otherwise they may be lost.


Copyright © Thunderstone Software     Last updated: May 19 2023
Copyright © 2023 Thunderstone Software LLC. All rights reserved.