aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-06-12 20:43:17 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-06-20 23:22:55 +0300
commit127a964c7bab61a58fb4b1dc3b112eb784820181 (patch)
tree92d0954184fa37270e0f53795b0adfbc316b36b2 /src/microhttpd/connection.c
parentedde133d39a3475f0adc60493f3a5ae4c1d4a976 (diff)
downloadlibmicrohttpd-127a964c7bab61a58fb4b1dc3b112eb784820181.tar.gz
libmicrohttpd-127a964c7bab61a58fb4b1dc3b112eb784820181.zip
connection.c: corrected error responses
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index eacf7411..be9c5525 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -69,7 +69,7 @@
69#define REQUEST_TOO_BIG \ 69#define REQUEST_TOO_BIG \
70 "<html>" \ 70 "<html>" \
71 "<head><title>Request too big</title></head>" \ 71 "<head><title>Request too big</title></head>" \
72 "<body>Your HTTP header is too big for the memory constraints " \ 72 "<body>Request HTTP header is too big for the memory constraints " \
73 "of this webserver.</body>" \ 73 "of this webserver.</body>" \
74 "</html>" 74 "</html>"
75#else 75#else
@@ -97,7 +97,7 @@
97#define BARE_CR_IN_HEADER \ 97#define BARE_CR_IN_HEADER \
98 "<html>" \ 98 "<html>" \
99 "<head><title>Request broken</title></head>" \ 99 "<head><title>Request broken</title></head>" \
100 "<body>Your HTTP header has bare CR character without " \ 100 "<body>Request HTTP header has bare CR character without " \
101 "following LF character.</body>" \ 101 "following LF character.</body>" \
102 "</html>" 102 "</html>"
103#else 103#else
@@ -112,7 +112,7 @@
112#define BARE_CR_IN_FOOTER \ 112#define BARE_CR_IN_FOOTER \
113 "<html>" \ 113 "<html>" \
114 "<head><title>Request broken</title></head>" \ 114 "<head><title>Request broken</title></head>" \
115 "<body>Your HTTP footer has bare CR character without " \ 115 "<body>Request HTTP footer has bare CR character without " \
116 "following LF character.</body>" \ 116 "following LF character.</body>" \
117 "</html>" 117 "</html>"
118#else 118#else
@@ -127,7 +127,7 @@
127#define BARE_LF_IN_HEADER \ 127#define BARE_LF_IN_HEADER \
128 "<html>" \ 128 "<html>" \
129 "<head><title>Request broken</title></head>" \ 129 "<head><title>Request broken</title></head>" \
130 "<body>Your HTTP header has bare LF character without " \ 130 "<body>Request HTTP header has bare LF character without " \
131 "preceding CR character.</body>" \ 131 "preceding CR character.</body>" \
132 "</html>" 132 "</html>"
133#else 133#else
@@ -142,7 +142,7 @@
142#define BARE_LF_IN_FOOTER \ 142#define BARE_LF_IN_FOOTER \
143 "<html>" \ 143 "<html>" \
144 "<head><title>Request broken</title></head>" \ 144 "<head><title>Request broken</title></head>" \
145 "<body>Your HTTP footer has bare LF character without " \ 145 "<body>Request HTTP footer has bare LF character without " \
146 "preceding CR character.</body>" \ 146 "preceding CR character.</body>" \
147 "</html>" 147 "</html>"
148#else 148#else
@@ -156,7 +156,7 @@
156#define RQ_TARGET_INVALID_CHAR \ 156#define RQ_TARGET_INVALID_CHAR \
157 "<html>" \ 157 "<html>" \
158 "<head><title>Request broken</title></head>" \ 158 "<head><title>Request broken</title></head>" \
159 "<body>Your HTTP request has invalid characters in " \ 159 "<body>HTTP request has invalid characters in " \
160 "the request-target.</body>" \ 160 "the request-target.</body>" \
161 "</html>" 161 "</html>"
162#else 162#else
@@ -170,7 +170,7 @@
170#define ERR_RSP_OBS_FOLD \ 170#define ERR_RSP_OBS_FOLD \
171 "<html>" \ 171 "<html>" \
172 "<head><title>Request broken</title></head>" \ 172 "<head><title>Request broken</title></head>" \
173 "<body>Obsolete line folding is used in your HTTP request header.</body>" \ 173 "<body>Obsolete line folding is used in HTTP request header.</body>" \
174 "</html>" 174 "</html>"
175#else 175#else
176#define ERR_RSP_OBS_FOLD "" 176#define ERR_RSP_OBS_FOLD ""
@@ -183,7 +183,7 @@
183#define ERR_RSP_OBS_FOLD_FOOTER \ 183#define ERR_RSP_OBS_FOLD_FOOTER \
184 "<html>" \ 184 "<html>" \
185 "<head><title>Request broken</title></head>" \ 185 "<head><title>Request broken</title></head>" \
186 "<body>Obsolete line folding is used in your HTTP request footer.</body>" \ 186 "<body>Obsolete line folding is used in HTTP request footer.</body>" \
187 "</html>" 187 "</html>"
188#else 188#else
189#define ERR_RSP_OBS_FOLD_FOOTER "" 189#define ERR_RSP_OBS_FOLD_FOOTER ""
@@ -197,7 +197,7 @@
197#define ERR_RSP_WSP_BEFORE_HEADER \ 197#define ERR_RSP_WSP_BEFORE_HEADER \
198 "<html>" \ 198 "<html>" \
199 "<head><title>Request broken</title></head>" \ 199 "<head><title>Request broken</title></head>" \
200 "<body>Your HTTP request has whitespace between the request line and " \ 200 "<body>HTTP request has whitespace between the request line and " \
201 "the first header.</body>" \ 201 "the first header.</body>" \
202 "</html>" 202 "</html>"
203#else 203#else
@@ -212,7 +212,7 @@
212#define ERR_RSP_WSP_BEFORE_FOOTER \ 212#define ERR_RSP_WSP_BEFORE_FOOTER \
213 "<html>" \ 213 "<html>" \
214 "<head><title>Request broken</title></head>" \ 214 "<head><title>Request broken</title></head>" \
215 "<body>Your first HTTP footer line has whitespace at the first " \ 215 "<body>First HTTP footer line has whitespace at the first " \
216 "position.</body>" \ 216 "position.</body>" \
217 "</html>" 217 "</html>"
218#else 218#else
@@ -227,7 +227,7 @@
227#define ERR_RSP_WSP_IN_HEADER_NAME \ 227#define ERR_RSP_WSP_IN_HEADER_NAME \
228 "<html>" \ 228 "<html>" \
229 "<head><title>Request broken</title></head>" \ 229 "<head><title>Request broken</title></head>" \
230 "<body>Your HTTP request has whitespace before the first colon " \ 230 "<body>HTTP request has whitespace before the first colon " \
231 "in header line.</body>" \ 231 "in header line.</body>" \
232 "</html>" 232 "</html>"
233#else 233#else
@@ -242,7 +242,7 @@
242#define ERR_RSP_WSP_IN_FOOTER_NAME \ 242#define ERR_RSP_WSP_IN_FOOTER_NAME \
243 "<html>" \ 243 "<html>" \
244 "<head><title>Request broken</title></head>" \ 244 "<head><title>Request broken</title></head>" \
245 "<body>Your HTTP request has whitespace before the first colon " \ 245 "<body>HTTP request has whitespace before the first colon " \
246 "in footer line.</body>" \ 246 "in footer line.</body>" \
247 "</html>" 247 "</html>"
248#else 248#else
@@ -256,7 +256,7 @@
256#define ERR_RSP_INVALID_CHR_IN_HEADER \ 256#define ERR_RSP_INVALID_CHR_IN_HEADER \
257 "<html>" \ 257 "<html>" \
258 "<head><title>Request broken</title></head>" \ 258 "<head><title>Request broken</title></head>" \
259 "<body>Your HTTP request has invalid character in header.</body>" \ 259 "<body>HTTP request has invalid character in header.</body>" \
260 "</html>" 260 "</html>"
261#else 261#else
262#define ERR_RSP_INVALID_CHR_IN_HEADER "" 262#define ERR_RSP_INVALID_CHR_IN_HEADER ""
@@ -269,7 +269,7 @@
269#define ERR_RSP_INVALID_CHR_IN_FOOTER \ 269#define ERR_RSP_INVALID_CHR_IN_FOOTER \
270 "<html>" \ 270 "<html>" \
271 "<head><title>Request broken</title></head>" \ 271 "<head><title>Request broken</title></head>" \
272 "<body>Your HTTP request has invalid character in footer.</body>" \ 272 "<body>HTTP request has invalid character in footer.</body>" \
273 "</html>" 273 "</html>"
274#else 274#else
275#define ERR_RSP_INVALID_CHR_IN_HEADER "" 275#define ERR_RSP_INVALID_CHR_IN_HEADER ""
@@ -282,7 +282,7 @@
282#define ERR_RSP_HEADER_WITHOUT_COLON \ 282#define ERR_RSP_HEADER_WITHOUT_COLON \
283 "<html>" \ 283 "<html>" \
284 "<head><title>Request broken</title></head>" \ 284 "<head><title>Request broken</title></head>" \
285 "<body>Your HTTP request header line has no colon character.</body>" \ 285 "<body>HTTP request header line has no colon character.</body>" \
286 "</html>" 286 "</html>"
287#else 287#else
288#define ERR_RSP_INVALID_CHR_IN_HEADER "" 288#define ERR_RSP_INVALID_CHR_IN_HEADER ""
@@ -295,7 +295,7 @@
295#define ERR_RSP_FOOTER_WITHOUT_COLON \ 295#define ERR_RSP_FOOTER_WITHOUT_COLON \
296 "<html>" \ 296 "<html>" \
297 "<head><title>Request broken</title></head>" \ 297 "<head><title>Request broken</title></head>" \
298 "<body>Your HTTP request footer line has no colon character.</body>" \ 298 "<body>HTTP request footer line has no colon character.</body>" \
299 "</html>" 299 "</html>"
300#else 300#else
301#define ERR_RSP_FOOTER_WITHOUT_COLON "" 301#define ERR_RSP_FOOTER_WITHOUT_COLON ""
@@ -308,7 +308,7 @@
308#define ERR_RSP_EMPTY_HEADER_NAME \ 308#define ERR_RSP_EMPTY_HEADER_NAME \
309 "<html>" \ 309 "<html>" \
310 "<head><title>Request broken</title></head>" \ 310 "<head><title>Request broken</title></head>" \
311 "<body>Your HTTP request header has empty header name.</body>" \ 311 "<body>HTTP request header has empty header name.</body>" \
312 "</html>" 312 "</html>"
313#else 313#else
314#define ERR_RSP_EMPTY_HEADER_NAME "" 314#define ERR_RSP_EMPTY_HEADER_NAME ""
@@ -321,7 +321,7 @@
321#define ERR_RSP_EMPTY_FOOTER_NAME \ 321#define ERR_RSP_EMPTY_FOOTER_NAME \
322 "<html>" \ 322 "<html>" \
323 "<head><title>Request broken</title></head>" \ 323 "<head><title>Request broken</title></head>" \
324 "<body>Your HTTP request footer has empty header name.</body>" \ 324 "<body>HTTP request footer has empty footer name.</body>" \
325 "</html>" 325 "</html>"
326#else 326#else
327#define ERR_RSP_EMPTY_FOOTER_NAME "" 327#define ERR_RSP_EMPTY_FOOTER_NAME ""
@@ -336,7 +336,11 @@
336 */ 336 */
337#ifdef HAVE_MESSAGES 337#ifdef HAVE_MESSAGES
338#define REQUEST_LACKS_HOST \ 338#define REQUEST_LACKS_HOST \
339 "<html><head><title>&quot;Host:&quot; header required</title></head><body>In HTTP 1.1, requests must include a &quot;Host:&quot; header, and your HTTP 1.1 request lacked such a header.</body></html>" 339 "<html>" \
340 "<head><title>&quot;Host:&quot; header required</title></head>" \
341 "<body>HTTP/1.1 request without <b>&quot;Host:&quot;</b>.</body>"\
342 "</html>"
343
340#else 344#else
341#define REQUEST_LACKS_HOST "" 345#define REQUEST_LACKS_HOST ""
342#endif 346#endif
@@ -378,7 +382,8 @@
378 */ 382 */
379#ifdef HAVE_MESSAGES 383#ifdef HAVE_MESSAGES
380#define REQUEST_MALFORMED \ 384#define REQUEST_MALFORMED \
381 "<html><head><title>Request malformed</title></head><body>Your HTTP request is syntactically incorrect.</body></html>" 385 "<html><head><title>Request malformed</title></head>" \
386 "<body>HTTP request is syntactically incorrect.</body></html>"
382#else 387#else
383#define REQUEST_MALFORMED "" 388#define REQUEST_MALFORMED ""
384#endif 389#endif
@@ -389,7 +394,8 @@
389 */ 394 */
390#ifdef HAVE_MESSAGES 395#ifdef HAVE_MESSAGES
391#define REQUEST_CHUNKED_MALFORMED \ 396#define REQUEST_CHUNKED_MALFORMED \
392 "<html><head><title>Request malformed</title></head><body>Your HTTP chunked encoding was syntactically incorrect.</body></html>" 397 "<html><head><title>Request malformed</title></head>" \
398 "<body>HTTP chunked encoding is syntactically incorrect.</body></html>"
393#else 399#else
394#define REQUEST_CHUNKED_MALFORMED "" 400#define REQUEST_CHUNKED_MALFORMED ""
395#endif 401#endif
@@ -399,7 +405,9 @@
399 */ 405 */
400#ifdef HAVE_MESSAGES 406#ifdef HAVE_MESSAGES
401#define REQUEST_CHUNK_TOO_LARGE \ 407#define REQUEST_CHUNK_TOO_LARGE \
402 "<html><head><title>Request content too large</title></head><body>The chunk size used in your HTTP chunked encoded request is too large.</body></html>" 408 "<html><head><title>Request content too large</title></head>" \
409 "<body>The chunk size used in HTTP chunked encoded " \
410 "request is too large.</body></html>"
403#else 411#else
404#define REQUEST_CHUNK_TOO_LARGE "" 412#define REQUEST_CHUNK_TOO_LARGE ""
405#endif 413#endif
@@ -410,7 +418,8 @@
410#ifdef HAVE_MESSAGES 418#ifdef HAVE_MESSAGES
411#define REQUEST_CONTENTLENGTH_TOOLARGE \ 419#define REQUEST_CONTENTLENGTH_TOOLARGE \
412 "<html><head><title>Request content too large</title></head>" \ 420 "<html><head><title>Request content too large</title></head>" \
413 "<body>Your HTTP request has too large value for <b>Content-Length</b> header.</body></html>" 421 "<body>HTTP request has too large value for " \
422 "<b>Content-Length</b> header.</body></html>"
414#else 423#else
415#define REQUEST_CONTENTLENGTH_TOOLARGE "" 424#define REQUEST_CONTENTLENGTH_TOOLARGE ""
416#endif 425#endif
@@ -422,7 +431,8 @@
422#ifdef HAVE_MESSAGES 431#ifdef HAVE_MESSAGES
423#define REQUEST_CONTENTLENGTH_MALFORMED \ 432#define REQUEST_CONTENTLENGTH_MALFORMED \
424 "<html><head><title>Request malformed</title></head>" \ 433 "<html><head><title>Request malformed</title></head>" \
425 "<body>Your HTTP request has wrong value for <b>Content-Length</b> header.</body></html>" 434 "<body>HTTP request has wrong value for " \
435 "<b>Content-Length</b> header.</body></html>"
426#else 436#else
427#define REQUEST_CONTENTLENGTH_MALFORMED "" 437#define REQUEST_CONTENTLENGTH_MALFORMED ""
428#endif 438#endif
@@ -435,7 +445,10 @@
435 */ 445 */
436#ifdef HAVE_MESSAGES 446#ifdef HAVE_MESSAGES
437#define INTERNAL_ERROR \ 447#define INTERNAL_ERROR \
438 "<html><head><title>Internal server error</title></head><body>Please ask the developer of this Web server to carefully read the GNU libmicrohttpd documentation about connection management and blocking.</body></html>" 448 "<html><head><title>Internal server error</title></head>" \
449 "<body>Please ask the developer of this Web server to carefully " \
450 "read the GNU libmicrohttpd documentation about connection "\
451 "management and blocking.</body></html>"
439#else 452#else
440#define INTERNAL_ERROR "" 453#define INTERNAL_ERROR ""
441#endif 454#endif
@@ -445,7 +458,9 @@
445 */ 458 */
446#ifdef HAVE_MESSAGES 459#ifdef HAVE_MESSAGES
447#define REQ_HTTP_VER_IS_TOO_OLD \ 460#define REQ_HTTP_VER_IS_TOO_OLD \
448 "<html><head><title>Requested HTTP version is not supported</title></head><body>Requested HTTP version is too old and not supported.</body></html>" 461 "<html><head><title>Requested HTTP version is not supported</title></head>" \
462 "<body>Requested HTTP version is too old and not " \
463 "supported.</body></html>"
449#else 464#else
450#define REQ_HTTP_VER_IS_TOO_OLD "" 465#define REQ_HTTP_VER_IS_TOO_OLD ""
451#endif 466#endif
@@ -455,7 +470,8 @@
455 */ 470 */
456#ifdef HAVE_MESSAGES 471#ifdef HAVE_MESSAGES
457#define REQ_HTTP_VER_IS_NOT_SUPPORTED \ 472#define REQ_HTTP_VER_IS_NOT_SUPPORTED \
458 "<html><head><title>Requested HTTP version is not supported</title></head><body>Requested HTTP version is not supported.</body></html>" 473 "<html><head><title>Requested HTTP version is not supported</title></head>" \
474 "<body>Requested HTTP version is not supported.</body></html>"
459#else 475#else
460#define REQ_HTTP_VER_IS_NOT_SUPPORTED "" 476#define REQ_HTTP_VER_IS_NOT_SUPPORTED ""
461#endif 477#endif