S H Mohanjith
By: a guest | Aug 25th, 2009 | Syntax:
None | Size: 1.03 KB | Hits: 917 | Expires: Never
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
if ( obj.status >= 500 && obj.status <= 505) {
C{
#include <stdio.h>
#include <string.h>
FILE * pFile;
char content [100];
char page [10240];
char fname [50];
page[0] = '\0';
sprintf(fname, "/var/www/errors/%d.html", VRT_r_obj_status(sp));
pFile = fopen(fname, "r");
while (fgets(content, 100, pFile)) {
strcat(page, content);
}
fclose(pFile);
VRT_synth_page(sp, 0, page, "<!-- XID: ", VRT_r_req_xid(sp), " -->", vrt_magic_string_end);
}C
} else {
synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>"} obj.status " " obj.response {"</title>
</head>
<body>
<h1>Error "} obj.status " " obj.response {"</h1>
<p>"} obj.response {"</p>
<h3>Guru Meditation:</h3>
<p>XID: "} req.xid {"</p>
<address>
<a href="http://www.varnish-cache.org/">Varnish</a>
</address>
</body>
</html>
"};
}
return (deliver);
}