// vim:noexpandtab:syntax=lpc // $Id: header.i,v 1.10 2008/08/05 12:21:33 lynx Exp $ #include volatile int headerDone = 0; http_ok(string prot, string type, string extra) { string out; // yes, this is compatible to pre-HTTP/1.0 browsers. sick, i know. if (!prot || headerDone++) return; out = type || extra ? htheaders(type, extra) +"\n" : "Content-type: " DEFAULT_CONTENT_TYPE "\n\n"; emit(out = HTTP_SVERS " 200 Sure\n"+ out); P3((out)) } varargs http_error(string prot, int code, string comment, string html) { string out; // apparently there isn't a single app that calls this with "html" P2(("hterror(%O,%O,%O,%O) in %O\n", prot,code,comment,html, ME)) #if defined(T) // use the textdb if available out = psyctext( T("_PAGES_error", "[_code]\n" "

[_comment]

\n"), ([ "_comment": comment, "_code": code ]) ); #else // use some hardcoded defaults out = "\n"; if (html) out = sprintf("%s\n%s%s", comment, out, html); else out = sprintf("\ error %d\n\ %s\n\


\n\n\ %s\n\n\

\n\ ", code, out, comment ); // %s\n //, WEBMASTER_EMAIL, comment, WEBMASTER_EMAIL #endif // yes, this is compatible to pre-HTTP/1.0 browsers. sick, i know. if (!headerDone++ && prot) { // I used to output the comment, but Id have to cut out the // newline from the db emit(out = sprintf(HTTP_SVERS " 200 Actually %03d but MSIE steals my error page\n%s\n%s", code, htheaders(), out)); P3((out)) } else emit(out); }