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 [HUnkVers] {"501 Not Implemented", "Unknown http version",
24 "This server does not know how to respond to http version %s."},
25 [HBadCont] {"501 Not Implemented", "Impossible format",
26 "This server cannot produce %s in any of the formats your client accepts."},
27 [HBadReq] {"400 Bad Request", "Strange Request",
28 "Your client sent a query that this server could not understand."},
29 [HSyntax] {"400 Bad Request", "Garbled Syntax",
30 "Your client sent a query with incoherent syntax."},
31 [HBadSearch] {"400 Bad Request", "Inapplicable Search",
32 "Your client sent a search that cannot be applied to %s."},
33 [HNotFound] {"404 Not Found", "Object not found",
34 "The object %s does not exist on this server."},
35 [HNoSearch] {"403 Forbidden", "Search not supported",
36 "The object %s does not support the search command."},
37 [HNoData] {"403 Forbidden", "No data supplied",
38 "Search or forms data must be supplied to %s."},
39 [HExpectFail] {"403 Expectation Failed", "Expectation Failed",
40 "This server does not support some of your request's expectations."},
41 [HUnauth] {"403 Forbidden", "Forbidden",
42 "You are not allowed to see the object %s."},
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], err[ERRMAX];
57 rerrstr(err, sizeof err);
59 va_start(arg, reason);
60 vseprint(makeup, makeup+HBufSize, errormsg[reason].verbose, arg);
63 * this additional information has proved useful when debugging
64 * complex http configuration problems.
66 n = snprint(c->xferbuf, HBufSize, "<head><title>%s</title></head>\n"
67 "<body><h1>%s</h1>\n%s<p>\n"
70 "header host: %s<br>\nactual host: %s\n</body>\n",
71 errormsg[reason].concise, errormsg[reason].concise, makeup,
73 (c->req.urihost? c->req.urihost: ""),
74 c->head.host, hmydomain);
76 hprint(hout, "%s %s\r\n", hversion, errormsg[reason].num);
77 hprint(hout, "Date: %D\r\n", time(nil));
78 hprint(hout, "Server: Plan9\r\n");
79 hprint(hout, "Content-Type: text/html\r\n");
80 hprint(hout, "Content-Length: %d\r\n", n);
82 hprint(hout, "Connection: close\r\n");
84 hprint(hout, "Connection: Keep-Alive\r\n");
87 if(c->req.meth == nil || strcmp(c->req.meth, "HEAD") != 0)
88 hwrite(hout, c->xferbuf, n);
91 c->replog(c, "Reply: %s\nReason: %s\n", errormsg[reason].num, errormsg[reason].concise);