|
Packit |
875988 |
/*
|
|
Packit |
875988 |
This file is part of libmicrohttpd
|
|
Packit |
875988 |
Copyright (C) 2007, 2011, 2017 Christian Grothoff, Karlson2k (Evgeny Grin)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
This library is free software; you can redistribute it and/or
|
|
Packit |
875988 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
875988 |
License as published by the Free Software Foundation; either
|
|
Packit |
875988 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
This library is distributed in the hope that it will be useful,
|
|
Packit |
875988 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
875988 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
875988 |
Lesser General Public License for more details.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
875988 |
License along with this library; if not, write to the Free Software
|
|
Packit |
875988 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
875988 |
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* @file reason_phrase.c
|
|
Packit |
875988 |
* @brief Tables of the string response phrases
|
|
Packit |
875988 |
* @author Elliot Glaysher
|
|
Packit |
875988 |
* @author Christian Grothoff (minor code clean up)
|
|
Packit |
875988 |
* @author Karlson2k (Evgeny Grin)
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#include "platform.h"
|
|
Packit |
875988 |
#include "microhttpd.h"
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifndef NULL
|
|
Packit |
875988 |
#define NULL ((void*)0)
|
|
Packit |
875988 |
#endif
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const invalid_hundred[] = {
|
|
Packit |
875988 |
NULL
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const one_hundred[] = {
|
|
Packit |
875988 |
"Continue",
|
|
Packit |
875988 |
"Switching Protocols",
|
|
Packit |
875988 |
"Processing"
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const two_hundred[] = {
|
|
Packit |
875988 |
"OK",
|
|
Packit |
875988 |
"Created",
|
|
Packit |
875988 |
"Accepted",
|
|
Packit |
875988 |
"Non-Authoritative Information",
|
|
Packit |
875988 |
"No Content",
|
|
Packit |
875988 |
"Reset Content",
|
|
Packit |
875988 |
"Partial Content",
|
|
Packit |
875988 |
"Multi-Status",
|
|
Packit |
875988 |
"Already Reported",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 210 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 215 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 220 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 225 */
|
|
Packit |
875988 |
"IM Used"
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const three_hundred[] = {
|
|
Packit |
875988 |
"Multiple Choices",
|
|
Packit |
875988 |
"Moved Permanently",
|
|
Packit |
875988 |
"Found",
|
|
Packit |
875988 |
"See Other",
|
|
Packit |
875988 |
"Not Modified",
|
|
Packit |
875988 |
"Use Proxy",
|
|
Packit |
875988 |
"Switch Proxy",
|
|
Packit |
875988 |
"Temporary Redirect",
|
|
Packit |
875988 |
"Permanent Redirect"
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const four_hundred[] = {
|
|
Packit |
875988 |
"Bad Request",
|
|
Packit |
875988 |
"Unauthorized",
|
|
Packit |
875988 |
"Payment Required",
|
|
Packit |
875988 |
"Forbidden",
|
|
Packit |
875988 |
"Not Found",
|
|
Packit |
875988 |
"Method Not Allowed",
|
|
Packit |
875988 |
"Not Acceptable",
|
|
Packit |
875988 |
"Proxy Authentication Required",
|
|
Packit |
875988 |
"Request Timeout",
|
|
Packit |
875988 |
"Conflict",
|
|
Packit |
875988 |
"Gone",
|
|
Packit |
875988 |
"Length Required",
|
|
Packit |
875988 |
"Precondition Failed",
|
|
Packit |
875988 |
"Payload Too Large",
|
|
Packit |
875988 |
"URI Too Long",
|
|
Packit |
875988 |
"Unsupported Media Type",
|
|
Packit |
875988 |
"Range Not Satisfiable",
|
|
Packit |
875988 |
"Expectation Failed",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 420 */
|
|
Packit |
875988 |
"Misdirected Request",
|
|
Packit |
875988 |
"Unprocessable Entity",
|
|
Packit |
875988 |
"Locked",
|
|
Packit |
875988 |
"Failed Dependency",
|
|
Packit |
875988 |
"Unordered Collection",
|
|
Packit |
875988 |
"Upgrade Required",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Precondition Required",
|
|
Packit |
875988 |
"Too Many Requests",
|
|
Packit |
875988 |
"Unknown", /* 430 */
|
|
Packit |
875988 |
"Request Header Fields Too Large",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 435 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown", /* 440 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"No Response",
|
|
Packit |
875988 |
"Unknown", /* 445 */
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Unknown",
|
|
Packit |
875988 |
"Retry With",
|
|
Packit |
875988 |
"Blocked by Windows Parental Controls", /* 450 */
|
|
Packit |
875988 |
"Unavailable For Legal Reasons"
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const char *const five_hundred[] = {
|
|
Packit |
875988 |
"Internal Server Error",
|
|
Packit |
875988 |
"Not Implemented",
|
|
Packit |
875988 |
"Bad Gateway",
|
|
Packit |
875988 |
"Service Unavailable",
|
|
Packit |
875988 |
"Gateway Timeout",
|
|
Packit |
875988 |
"HTTP Version Not Supported",
|
|
Packit |
875988 |
"Variant Also Negotiates",
|
|
Packit |
875988 |
"Insufficient Storage",
|
|
Packit |
875988 |
"Loop Detected",
|
|
Packit |
875988 |
"Bandwidth Limit Exceeded",
|
|
Packit |
875988 |
"Not Extended",
|
|
Packit |
875988 |
"Network Authentication Required"
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
struct MHD_Reason_Block
|
|
Packit |
875988 |
{
|
|
Packit |
875988 |
size_t max;
|
|
Packit |
875988 |
const char *const*data;
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
|
|
Packit |
875988 |
|
|
Packit |
875988 |
static const struct MHD_Reason_Block reasons[] = {
|
|
Packit |
875988 |
BLOCK (invalid_hundred),
|
|
Packit |
875988 |
BLOCK (one_hundred),
|
|
Packit |
875988 |
BLOCK (two_hundred),
|
|
Packit |
875988 |
BLOCK (three_hundred),
|
|
Packit |
875988 |
BLOCK (four_hundred),
|
|
Packit |
875988 |
BLOCK (five_hundred),
|
|
Packit |
875988 |
};
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
const char *
|
|
Packit |
875988 |
MHD_get_reason_phrase_for (unsigned int code)
|
|
Packit |
875988 |
{
|
|
Packit |
875988 |
if ( (code >= 100) &&
|
|
Packit |
875988 |
(code < 600) &&
|
|
Packit |
875988 |
(reasons[code / 100].max > (code % 100)) )
|
|
Packit |
875988 |
return reasons[code / 100].data[code % 100];
|
|
Packit |
875988 |
return "Unknown";
|
|
Packit |
875988 |
}
|