aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/reason_phrase.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/reason_phrase.c')
-rw-r--r--src/daemon/reason_phrase.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/daemon/reason_phrase.c b/src/daemon/reason_phrase.c
new file mode 100644
index 00000000..27d4d73c
--- /dev/null
+++ b/src/daemon/reason_phrase.c
@@ -0,0 +1,108 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007 Lymba
4
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22/**
23 * @file reason_phrase.c
24 * @brief Tables of the string response phrases
25 * @author Elliot Glaysher
26 * @author Christian Grothoff (minor code clean up)
27 */
28
29#include "reason_phrase.h"
30
31static const char * invalid_hundred[] = { };
32
33static const char * one_hundred[] = {
34 "Continue",
35 "Switching Protocols",
36 "Processing"
37};
38
39static const char* two_hundred[] = {
40 "OK",
41 "Created",
42 "Accepted",
43 "Non-Authoritative Information",
44 "No Content",
45 "Reset Content",
46 "Partial Content"
47};
48
49static const char* three_hundred[] = {
50 "Multiple Choices",
51 "Moved Permanently",
52 "Moved Temporarily",
53 "See Other",
54 "Not Modified",
55 "Use Proxy"
56};
57
58static const char* four_hundred[] = {
59 "Bad Request",
60 "Unauthorized",
61 "Payment Required",
62 "Forbidden",
63 "Not Found",
64 "Method Not Allowed",
65 "Not Acceptable",
66 "Proxy Authentication Required",
67 "Request Time-out",
68 "Conflict",
69 "Gone",
70 "Length Required",
71 "Precondition Failed",
72 "Request Entity Too Large",
73 "Request-URI Too Large",
74 "Unsupported Media Type"
75};
76
77static const char* five_hundred[] = {
78 "Internal Server Error",
79 "Bad Gateway",
80 "Service Unavailable",
81 "Gateway Time-out",
82 "HTTP Version not supported"
83};
84
85
86struct MHD_Reason_Block {
87 unsigned int max;
88 const char ** data;
89};
90
91#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
92
93static const struct MHD_Reason_Block reasons[] = {
94 BLOCK(one_hundred),
95 BLOCK(two_hundred),
96 BLOCK(three_hundred),
97 BLOCK(four_hundred),
98 BLOCK(five_hundred),
99};
100
101const char *
102MHD_get_reason_phrase_for(unsigned int code)
103{
104 if ( (code >= 100 && code < 600) &&
105 (reasons[code / 100].max > code % 100) )
106 return reasons[code / 100].data[code % 100];
107 return "Unknown";
108}