aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/reason_phrase.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-05-05 18:07:33 +0000
committerChristian Grothoff <christian@grothoff.org>2013-05-05 18:07:33 +0000
commit9eb27c8dbe1939344ccced9c498895f0e92e8197 (patch)
treea97d1b7caf1e5dc79c22b08d58be70bc8c205cba /src/microhttpd/reason_phrase.c
parent1725bcf3c546fccbf22d7794bf7290fcc28c385d (diff)
downloadlibmicrohttpd-9eb27c8dbe1939344ccced9c498895f0e92e8197.tar.gz
libmicrohttpd-9eb27c8dbe1939344ccced9c498895f0e92e8197.zip
-changing directory name
Diffstat (limited to 'src/microhttpd/reason_phrase.c')
-rw-r--r--src/microhttpd/reason_phrase.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/src/microhttpd/reason_phrase.c b/src/microhttpd/reason_phrase.c
new file mode 100644
index 00000000..843f47a9
--- /dev/null
+++ b/src/microhttpd/reason_phrase.c
@@ -0,0 +1,159 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007, 2011 Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21/**
22 * @file reason_phrase.c
23 * @brief Tables of the string response phrases
24 * @author Elliot Glaysher
25 * @author Christian Grothoff (minor code clean up)
26 */
27
28#include "reason_phrase.h"
29
30#ifndef NULL
31#define NULL (void*)0
32#endif
33
34static const char *invalid_hundred[] = { NULL };
35
36static const char *const one_hundred[] = {
37 "Continue",
38 "Switching Protocols",
39 "Processing"
40};
41
42static const char *const two_hundred[] = {
43 "OK",
44 "Created",
45 "Accepted",
46 "Non-Authoritative Information",
47 "No Content",
48 "Reset Content",
49 "Partial Content",
50 "Multi Status"
51};
52
53static const char *const three_hundred[] = {
54 "Multiple Choices",
55 "Moved Permanently",
56 "Moved Temporarily",
57 "See Other",
58 "Not Modified",
59 "Use Proxy",
60 "Switch Proxy",
61 "Temporary Redirect"
62};
63
64static const char *const four_hundred[] = {
65 "Bad Request",
66 "Unauthorized",
67 "Payment Required",
68 "Forbidden",
69 "Not Found",
70 "Method Not Allowed",
71 "Not Acceptable",
72 "Proxy Authentication Required",
73 "Request Time-out",
74 "Conflict",
75 "Gone",
76 "Length Required",
77 "Precondition Failed",
78 "Request Entity Too Large",
79 "Request-URI Too Large",
80 "Unsupported Media Type",
81 "Requested Range Not Satisfiable",
82 "Expectation Failed",
83 "Unknown",
84 "Unknown",
85 "Unknown", /* 420 */
86 "Unknown",
87 "Unprocessable Entity",
88 "Locked",
89 "Failed Dependency",
90 "Unordered Collection",
91 "Upgrade Required",
92 "Unknown",
93 "Unknown",
94 "Unknown",
95 "Unknown", /* 430 */
96 "Unknown",
97 "Unknown",
98 "Unknown",
99 "Unknown",
100 "Unknown", /* 435 */
101 "Unknown",
102 "Unknown",
103 "Unknown",
104 "Unknown",
105 "Unknown", /* 440 */
106 "Unknown",
107 "Unknown",
108 "Unknown",
109 "No Response",
110 "Unknown", /* 445 */
111 "Unknown",
112 "Unknown",
113 "Unknown",
114 "Retry With",
115 "Blocked by Windows Parental Controls", /* 450 */
116 "Unavailable For Legal Reasons"
117};
118
119static const char *const five_hundred[] = {
120 "Internal Server Error",
121 "Not Implemented",
122 "Bad Gateway",
123 "Service Unavailable",
124 "Gateway Time-out",
125 "HTTP Version not supported",
126 "Variant Also Negotiates",
127 "Insufficient Storage",
128 "Unknown",
129 "Bandwidth Limit Exceeded",
130 "Not Extended"
131};
132
133
134struct MHD_Reason_Block
135{
136 unsigned int max;
137 const char *const*data;
138};
139
140#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
141
142static const struct MHD_Reason_Block reasons[] = {
143 BLOCK (invalid_hundred),
144 BLOCK (one_hundred),
145 BLOCK (two_hundred),
146 BLOCK (three_hundred),
147 BLOCK (four_hundred),
148 BLOCK (five_hundred),
149};
150
151const char *
152MHD_get_reason_phrase_for (unsigned int code)
153{
154 if ( (code >= 100) &&
155 (code < 600) &&
156 (reasons[code / 100].max > (code % 100)) )
157 return reasons[code / 100].data[code % 100];
158 return "Unknown";
159}