new object $http_page_file: $http_page; var $root inited = 1; public method .generate() { arg page, args; var stat, head, filename; filename = args || "/index.html"; // Try to stat the file (| stat = $file.stat(filename) |); if (stat && stat[1][1] == "4") { // If it's a directory, try to stat index.html in that directory filename += "/index.html"; stat = (| $file.stat(filename) |); } if (!stat) { return $http_lib.error(404, "/" + page + args + " could not be found on this server."); } // Now add the headers head = #[["Content-type", $mime_lib.mime_type(filename)], ["Content-length", stat[2]], ["Date", $http_lib.RFC1123GMT()], ["Last-modified", $http_lib.RFC1123GMT(stat[4])]]; // We return 'file as the first element of the text to be printed. // When this is done, $http_connection uses a native method to dump // out the whole file. This keeps us from having to slurp in the // whole file and return that data--the file could be many megabytes // in size and this might cause big performace problems! return [200, head, ['file, filename, stat]]; };