GNU libmicrohttpd 0.9.73
Loading...
Searching...
No Matches
reason_phrase.c
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007, 2011, 2017, 2019 Christian Grothoff, Karlson2k (Evgeny Grin)
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*/
27#include "platform.h"
28#include "microhttpd.h"
29
30#ifndef NULL
31#define NULL ((void*) 0)
32#endif
33
34static const char *const invalid_hundred[] = {
35 NULL
36};
37
38static const char *const one_hundred[] = {
39 /* 100 */ "Continue", /* RFC7231, Section 6.2.1 */
40 /* 101 */ "Switching Protocols", /* RFC7231, Section 6.2.2 */
41 /* 102 */ "Processing", /* RFC2518 */
42 /* 103 */ "Early Hints" /* RFC8297 */
43};
44
45static const char *const two_hundred[] = {
46 /* 200 */ "OK", /* RFC7231, Section 6.3.1 */
47 /* 201 */ "Created", /* RFC7231, Section 6.3.2 */
48 /* 202 */ "Accepted", /* RFC7231, Section 6.3.3 */
49 /* 203 */ "Non-Authoritative Information", /* RFC7231, Section 6.3.4 */
50 /* 204 */ "No Content", /* RFC7231, Section 6.3.5 */
51 /* 205 */ "Reset Content", /* RFC7231, Section 6.3.6 */
52 /* 206 */ "Partial Content", /* RFC7233, Section 4.1 */
53 /* 207 */ "Multi-Status", /* RFC4918 */
54 /* 208 */ "Already Reported", /* RFC5842 */
55 /* 209 */ "Unknown", /* Not used */
56 /* 210 */ "Unknown", /* Not used */
57 /* 211 */ "Unknown", /* Not used */
58 /* 212 */ "Unknown", /* Not used */
59 /* 213 */ "Unknown", /* Not used */
60 /* 214 */ "Unknown", /* Not used */
61 /* 215 */ "Unknown", /* Not used */
62 /* 216 */ "Unknown", /* Not used */
63 /* 217 */ "Unknown", /* Not used */
64 /* 218 */ "Unknown", /* Not used */
65 /* 219 */ "Unknown", /* Not used */
66 /* 220 */ "Unknown", /* Not used */
67 /* 221 */ "Unknown", /* Not used */
68 /* 222 */ "Unknown", /* Not used */
69 /* 223 */ "Unknown", /* Not used */
70 /* 224 */ "Unknown", /* Not used */
71 /* 225 */ "Unknown", /* Not used */
72 /* 226 */ "IM Used" /* RFC3229 */
73};
74
75static const char *const three_hundred[] = {
76 /* 300 */ "Multiple Choices", /* RFC7231, Section 6.4.1 */
77 /* 301 */ "Moved Permanently", /* RFC7231, Section 6.4.2 */
78 /* 302 */ "Found", /* RFC7231, Section 6.4.3 */
79 /* 303 */ "See Other", /* RFC7231, Section 6.4.4 */
80 /* 304 */ "Not Modified", /* RFC7232, Section 4.1 */
81 /* 305 */ "Use Proxy", /* RFC7231, Section 6.4.5 */
82 /* 306 */ "Switch Proxy", /* Not used! RFC7231, Section 6.4.6 */
83 /* 307 */ "Temporary Redirect", /* RFC7231, Section 6.4.7 */
84 /* 308 */ "Permanent Redirect" /* RFC7538 */
85};
86
87static const char *const four_hundred[] = {
88 /* 400 */ "Bad Request", /* RFC7231, Section 6.5.1 */
89 /* 401 */ "Unauthorized", /* RFC7235, Section 3.1 */
90 /* 402 */ "Payment Required", /* RFC7231, Section 6.5.2 */
91 /* 403 */ "Forbidden", /* RFC7231, Section 6.5.3 */
92 /* 404 */ "Not Found", /* RFC7231, Section 6.5.4 */
93 /* 405 */ "Method Not Allowed", /* RFC7231, Section 6.5.5 */
94 /* 406 */ "Not Acceptable", /* RFC7231, Section 6.5.6 */
95 /* 407 */ "Proxy Authentication Required", /* RFC7235, Section 3.2 */
96 /* 408 */ "Request Timeout", /* RFC7231, Section 6.5.7 */
97 /* 409 */ "Conflict", /* RFC7231, Section 6.5.8 */
98 /* 410 */ "Gone", /* RFC7231, Section 6.5.9 */
99 /* 411 */ "Length Required", /* RFC7231, Section 6.5.10 */
100 /* 412 */ "Precondition Failed", /* RFC7232, Section 4.2; RFC8144, Section 3.2 */
101 /* 413 */ "Payload Too Large", /* RFC7231, Section 6.5.11 */
102 /* 414 */ "URI Too Long", /* RFC7231, Section 6.5.12 */
103 /* 415 */ "Unsupported Media Type", /* RFC7231, Section 6.5.13; RFC7694, Section 3 */
104 /* 416 */ "Range Not Satisfiable", /* RFC7233, Section 4.4 */
105 /* 417 */ "Expectation Failed", /* RFC7231, Section 6.5.14 */
106 /* 418 */ "Unknown", /* Not used */
107 /* 419 */ "Unknown", /* Not used */
108 /* 420 */ "Unknown", /* Not used */
109 /* 421 */ "Misdirected Request", /* RFC7540, Section 9.1.2 */
110 /* 422 */ "Unprocessable Entity", /* RFC4918 */
111 /* 423 */ "Locked", /* RFC4918 */
112 /* 424 */ "Failed Dependency", /* RFC4918 */
113 /* 425 */ "Too Early", /* RFC8470 */
114 /* 426 */ "Upgrade Required", /* RFC7231, Section 6.5.15 */
115 /* 427 */ "Unknown", /* Not used */
116 /* 428 */ "Precondition Required", /* RFC6585 */
117 /* 429 */ "Too Many Requests", /* RFC6585 */
118 /* 430 */ "Unknown", /* Not used */
119 /* 431 */ "Request Header Fields Too Large", /* RFC6585 */
120 /* 432 */ "Unknown", /* Not used */
121 /* 433 */ "Unknown", /* Not used */
122 /* 434 */ "Unknown", /* Not used */
123 /* 435 */ "Unknown", /* Not used */
124 /* 436 */ "Unknown", /* Not used */
125 /* 437 */ "Unknown", /* Not used */
126 /* 438 */ "Unknown", /* Not used */
127 /* 439 */ "Unknown", /* Not used */
128 /* 440 */ "Unknown", /* Not used */
129 /* 441 */ "Unknown", /* Not used */
130 /* 442 */ "Unknown", /* Not used */
131 /* 443 */ "Unknown", /* Not used */
132 /* 444 */ "Unknown", /* Not used */
133 /* 445 */ "Unknown", /* Not used */
134 /* 446 */ "Unknown", /* Not used */
135 /* 447 */ "Unknown", /* Not used */
136 /* 448 */ "Unknown", /* Not used */
137 /* 449 */ "Reply With", /* MS IIS extension */
138 /* 450 */ "Blocked by Windows Parental Controls", /* MS extension */
139 /* 451 */ "Unavailable For Legal Reasons" /* RFC7725 */
140};
141
142static const char *const five_hundred[] = {
143 /* 500 */ "Internal Server Error", /* RFC7231, Section 6.6.1 */
144 /* 501 */ "Not Implemented", /* RFC7231, Section 6.6.2 */
145 /* 502 */ "Bad Gateway", /* RFC7231, Section 6.6.3 */
146 /* 503 */ "Service Unavailable", /* RFC7231, Section 6.6.4 */
147 /* 504 */ "Gateway Timeout", /* RFC7231, Section 6.6.5 */
148 /* 505 */ "HTTP Version Not Supported", /* RFC7231, Section 6.6.6 */
149 /* 506 */ "Variant Also Negotiates", /* RFC2295 */
150 /* 507 */ "Insufficient Storage", /* RFC4918 */
151 /* 508 */ "Loop Detected", /* RFC5842 */
152 /* 509 */ "Bandwidth Limit Exceeded", /* Apache extension */
153 /* 510 */ "Not Extended", /* RFC2774 */
154 /* 511 */ "Network Authentication Required" /* RFC6585 */
155};
156
157
158struct MHD_Reason_Block
159{
160 size_t max;
161 const char *const*data;
162};
163
164#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
165
166static const struct MHD_Reason_Block reasons[] = {
173};
174
175
176const char *
177MHD_get_reason_phrase_for (unsigned int code)
178{
179 if ( (code >= 100) &&
180 (code < 600) &&
181 (reasons[code / 100].max > (code % 100)) )
182 return reasons[code / 100].data[code % 100];
183 return "Unknown";
184}
#define NULL
Definition: reason_phrase.c:30
static const struct MHD_Reason_Block reasons[]
static const char *const two_hundred[]
Definition: reason_phrase.c:43
#define BLOCK(m)
static const char *const five_hundred[]
static const char *const invalid_hundred[]
Definition: reason_phrase.c:33
static const char *const three_hundred[]
Definition: reason_phrase.c:73
static const char *const four_hundred[]
Definition: reason_phrase.c:85
const char * MHD_get_reason_phrase_for(enum MHD_HTTP_StatusCode code)
static const char *const one_hundred[]
Definition: reason_phrase.c:37
public interface to libmicrohttpd
void * data
Definition: microhttpd.h:3125
platform-specific includes for libmicrohttpd