summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/relayd/log.c')
-rw-r--r--usr.sbin/relayd/log.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c
index 44724696450..2f2e37ce781 100644
--- a/usr.sbin/relayd/log.c
+++ b/usr.sbin/relayd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.8 2007/11/04 22:09:02 reyk Exp $ */
+/* $OpenBSD: log.c,v 1.9 2007/11/20 15:54:55 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -246,3 +246,59 @@ print_time(struct timeval *a, struct timeval *b, char *buf, size_t len)
snprintf(buf, len, "%.2lu:%.2lu:%.2lu", h, min, sec);
return (buf);
}
+
+const char *
+print_httperror(u_int code)
+{
+ u_int i;
+ struct {
+ u_int ht_code;
+ const char *ht_err;
+ } httperr[] = {
+ { 100, "Continue" },
+ { 101, "Switching Protocols" },
+ { 200, "OK" },
+ { 201, "Created" },
+ { 202, "Accepted" },
+ { 203, "Non-Authorative Information" },
+ { 204, "No Content" },
+ { 205, "Reset Content" },
+ { 206, "Partial Content" },
+ { 300, "Multiple Choices" },
+ { 301, "Moved Permanently" },
+ { 302, "Moved Temporarily" },
+ { 303, "See Other" },
+ { 304, "Not Modified" },
+ { 307, "Temporary Redirect" },
+ { 400, "Bad Request" },
+ { 401, "Unauthorized" },
+ { 402, "Payment Required" },
+ { 403, "Forbidden" },
+ { 404, "Not Found" },
+ { 405, "Method Not Allowed" },
+ { 406, "Not Acceptable" },
+ { 407, "Proxy Authentication Required" },
+ { 408, "Request Timeout" },
+ { 409, "Conflict" },
+ { 410, "Gone" },
+ { 411, "Length Required" },
+ { 412, "Precondition Failed" },
+ { 413, "Request Entity Too Large" },
+ { 414, "Request-URL Too Long" },
+ { 415, "Unsupported Media Type" },
+ { 416, "Requested Range Not Satisfiable" },
+ { 417, "Expectation Failed" },
+ { 500, "Internal Server Error" },
+ { 501, "Not Implemented" },
+ { 502, "Bad Gateway" },
+ { 503, "Service Unavailable" },
+ { 504, "Gateway Timeout" },
+ { 505, "HTTP Version Not Supported" },
+ { 0 }
+ };
+
+ for (i = 0; httperr[i].ht_code != 0; i++)
+ if (httperr[i].ht_code == code)
+ return (httperr[i].ht_err);
+ return ("Unknown Error");
+}