00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #include "reason_phrase.h"
00029
00030 static const char *invalid_hundred[] = { };
00031
00032 static const char *one_hundred[] = {
00033 "Continue",
00034 "Switching Protocols",
00035 "Processing"
00036 };
00037
00038 static const char *two_hundred[] = {
00039 "OK",
00040 "Created",
00041 "Accepted",
00042 "Non-Authoritative Information",
00043 "No Content",
00044 "Reset Content",
00045 "Partial Content",
00046 "Multi Status"
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 "Switch Proxy",
00057 "Temporary Redirect"
00058 };
00059
00060 static const char *four_hundred[] = {
00061 "Bad Request",
00062 "Unauthorized",
00063 "Payment Required",
00064 "Forbidden",
00065 "Not Found",
00066 "Method Not Allowed",
00067 "Not Acceptable",
00068 "Proxy Authentication Required",
00069 "Request Time-out",
00070 "Conflict",
00071 "Gone",
00072 "Length Required",
00073 "Precondition Failed",
00074 "Request Entity Too Large",
00075 "Request-URI Too Large",
00076 "Unsupported Media Type",
00077 "Requested Range Not Satisfiable",
00078 "Expectation Failed",
00079 "Unprocessable Entity",
00080 "Locked",
00081 "Failed Dependency",
00082 "Unordered Collection",
00083 "Upgrade Required",
00084 "Retry With"
00085 };
00086
00087 static const char *five_hundred[] = {
00088 "Internal Server Error",
00089 "Not Implemented",
00090 "Bad Gateway",
00091 "Service Unavailable",
00092 "Gateway Time-out",
00093 "HTTP Version not supported",
00094 "Variant Also Negotiates",
00095 "Insufficient Storage",
00096 "Bandwidth Limit Exceeded",
00097 "Not Extended"
00098 };
00099
00100
00101 struct MHD_Reason_Block
00102 {
00103 unsigned int max;
00104 const char **data;
00105 };
00106
00107 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
00108
00109 static const struct MHD_Reason_Block reasons[] = {
00110 BLOCK (invalid_hundred),
00111 BLOCK (one_hundred),
00112 BLOCK (two_hundred),
00113 BLOCK (three_hundred),
00114 BLOCK (four_hundred),
00115 BLOCK (five_hundred),
00116 };
00117
00118 const char *
00119 MHD_get_reason_phrase_for (unsigned int code)
00120 {
00121 if ((code >= 100 && code < 600) && (reasons[code / 100].max > code % 100))
00122 return reasons[code / 100].data[code % 100];
00123 return "Unknown";
00124 }