Monday, November 08, 2010 at 12:02 AM.

system.verbs.apps.WebStar.initReplyText

on initReplyText (status = "200 OK", mimeOrLoc = "text/html") {
	<<This script produces standard HTTP Headers using this syntax:
		<<initReplyText ([status], [mimeOrLoc])
		<<the parameters are:
			<<type: default = "200 OK", This is the standard HTTP status code
			<<mimeOrLoc : default = "text/html", This is either the content type of the data
				<<returned.  In the case of a 302 FOUND header this parameter is the location (URL)
				<<to redirect the request.
		<<initReplyText () will return the most commonly used header for cgi's.
	
	local (s);
	case status {
		"401 UNAUTHORIZED" {
			s = "HTTP/1.0 " + status + "\r\nWWW-Authenticate: Basic realm=\"" + mimeOrLoc + "\"\r\n";
			s = s + "Server: WebSTAR/1.2 ID/CGI\r\n\r\n"};
		"302 FOUND" {
			s = "HTTP/1.0 302 FOUND\r\nLocation: " + mimeOrLoc + "\r\n"; << old redirect standard
			s = s + "URI: " + mimeOrLoc + "\r\n"; << new redirect standard
			s = s + "Server: WebSTAR/1.2 ID/CGI\r\n\r\n"}}
	else {
		s = "HTTP/1.0 " + status + "\r\nServer: WebSTAR/1.2 ID/CGI\r\n";
		s = s + "MIME-Version: 1.0\r\nContent-type: " + mimeOrLoc + "\r\n\r\n"};
	return (s)}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.