6 typedef struct Error Error;
17 /* HInternal */ {"500 Internal Error", "Internal Error",
18 "This server could not process your request due to an internal error."},
19 /* HTempFail */ {"500 Internal Error", "Temporary Failure",
20 "The object %s is currently inaccessible.<p>Please try again later."},
21 /* HUnimp */ {"501 Not implemented", "Command not implemented",
22 "This server does not implement the %s command."},
23 /* HBadReq */ {"400 Bad Request", "Strange Request",
24 "Your client sent a query that this server could not understand."},
25 /* HBadSearch */ {"400 Bad Request", "Inapplicable Search",
26 "Your client sent a search that cannot be applied to %s."},
27 /* HNotFound */ {"404 Not Found", "Object not found",
28 "The object %s does not exist on this server."},
29 /* HUnauth */ {"403 Forbidden", "Forbidden",
30 "You are not allowed to see the object %s."},
31 /* HSyntax */ {"400 Bad Request", "Garbled Syntax",
32 "Your client sent a query with incoherent syntax."},
33 /* HNoSearch */ {"403 Forbidden", "Search not supported",
34 "The object %s does not support the search command."},
35 /* HNoData */ {"403 Forbidden", "No data supplied",
36 "Search or forms data must be supplied to %s."},
37 /* HExpectFail */ {"403 Expectation Failed", "Expectation Failed",
38 "This server does not support some of your request's expectations."},
39 /* HUnkVers */ {"501 Not Implemented", "Unknown http version",
40 "This server does not know how to respond to http version %s."},
41 /* HBadCont */ {"501 Not Implemented", "Impossible format",
42 "This server cannot produce %s in any of the formats your client accepts."},
43 /* HOK */ {"200 OK", "everything is fine"},
47 * write a failure message to the net and exit
50 hfail(HConnect *c, int reason, ...)
53 char makeup[HBufSize];
58 va_start(arg, reason);
59 vseprint(makeup, makeup+HBufSize, errormsg[reason].verbose, arg);
61 n = snprint(c->xferbuf, HBufSize, "<head><title>%s</title></head>\n<body><h1>%s</h1>\n%s</body>\n",
62 errormsg[reason].concise, errormsg[reason].concise, makeup);
64 hprint(hout, "%s %s\r\n", hversion, errormsg[reason].num);
65 hprint(hout, "Date: %D\r\n", time(nil));
66 hprint(hout, "Server: Plan9\r\n");
67 hprint(hout, "Content-Type: text/html\r\n");
68 hprint(hout, "Content-Length: %d\r\n", n);
70 hprint(hout, "Connection: close\r\n");
72 hprint(hout, "Connection: Keep-Alive\r\n");
75 if(c->req.meth == nil || strcmp(c->req.meth, "HEAD") != 0)
76 hwrite(hout, c->xferbuf, n);
79 c->replog(c, "Reply: %s\nReason: %s\n", errormsg[reason].num, errormsg[reason].concise);