diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-04-04 19:39:38 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-04-04 19:39:38 +0300 |
commit | 07657b8a9f5c2fd9047594ec8604b9c439a999e4 (patch) | |
tree | efc15cde781a74f5782c780422dde6ec0dfb1af4 /src/error.c | |
parent | cb6a86b8db5a26b92073c4fc5ceffffa8cd842c2 (diff) | |
download | magi-07657b8a9f5c2fd9047594ec8604b9c439a999e4.tar magi-07657b8a9f5c2fd9047594ec8604b9c439a999e4.tar.xz magi-07657b8a9f5c2fd9047594ec8604b9c439a999e4.zip |
[magi] Finalization.
Diffstat (limited to 'src/error.c')
-rw-r--r-- | src/error.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/error.c b/src/error.c index a1c3153..eb16eb6 100644 --- a/src/error.c +++ b/src/error.c @@ -1,9 +1,11 @@ #include "error.h" +#include <stdio.h> + const char *magi_error_message(magi_error error) { - const char *const messages[] = { + static const char *const messages[] = { 0, /* magi_error_none */ "No boundary for multipart.", /* magi_error_nobound */ "Content-Type is unknown.", /* magi_error_unknown */ @@ -17,3 +19,18 @@ const char *magi_error_message(magi_error error) }; return messages[error]; } + +void magi_error_response(magi_error error) +{ + fputs("Status: 400 Bad Request\r\n" + "Content-Type: text/html\r\n\r\n" + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' " + "'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>" + "<html xmlns='http://www.w3.org/1999/xhtml'>" + "<head><title>400 Bad Request</title></head>" + "<body>" + "<h1>400 <i>Bad Request</i></h1>" + "<h2>", stdout); + fputs(magi_error_message(error), stdout); + fputs("</h2></body></html>", stdout); +} |