reason_phrase.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #include "reason_phrase.h"
00030
00031 static const char *invalid_hundred[] = { };
00032
00033 static const char *one_hundred[] = {
00034 "Continue",
00035 "Switching Protocols",
00036 "Processing"
00037 };
00038
00039 static const char *two_hundred[] = {
00040 "OK",
00041 "Created",
00042 "Accepted",
00043 "Non-Authoritative Information",
00044 "No Content",
00045 "Reset Content",
00046 "Partial Content"
00047 };
00048
00049 static const char *three_hundred[] = {
00050 "Multiple Choices",
00051 "Moved Permanently",
00052 "Moved Temporarily",
00053 "See Other",
00054 "Not Modified",
00055 "Use Proxy"
00056 };
00057
00058 static const char *four_hundred[] = {
00059 "Bad Request",
00060 "Unauthorized",
00061 "Payment Required",
00062 "Forbidden",
00063 "Not Found",
00064 "Method Not Allowed",
00065 "Not Acceptable",
00066 "Proxy Authentication Required",
00067 "Request Time-out",
00068 "Conflict",
00069 "Gone",
00070 "Length Required",
00071 "Precondition Failed",
00072 "Request Entity Too Large",
00073 "Request-URI Too Large",
00074 "Unsupported Media Type"
00075 };
00076
00077 static const char *five_hundred[] = {
00078 "Internal Server Error",
00079 "Bad Gateway",
00080 "Service Unavailable",
00081 "Gateway Time-out",
00082 "HTTP Version not supported"
00083 };
00084
00085
00086 struct MHD_Reason_Block
00087 {
00088 unsigned int max;
00089 const char **data;
00090 };
00091
00092 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
00093
00094 static const struct MHD_Reason_Block reasons[] = {
00095 BLOCK (invalid_hundred),
00096 BLOCK (one_hundred),
00097 BLOCK (two_hundred),
00098 BLOCK (three_hundred),
00099 BLOCK (four_hundred),
00100 BLOCK (five_hundred),
00101 };
00102
00103 const char *
00104 MHD_get_reason_phrase_for (unsigned int code)
00105 {
00106 if ((code >= 100 && code < 600) && (reasons[code / 100].max > code % 100))
00107 return reasons[code / 100].data[code % 100];
00108 return "Unknown";
00109 }