Initial commit
This commit is contained in:
111
src/constants/httprequest.hpp
Normal file
111
src/constants/httprequest.hpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace HttpRequest
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
GET,
|
||||
HEAD,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
TRACE,
|
||||
OPTIONS,
|
||||
CONNECT,
|
||||
PATCH
|
||||
};
|
||||
|
||||
const std::vector<std::string> typeStrings = {
|
||||
"GET",
|
||||
"HEAD",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"TRACE",
|
||||
"OPTIONS",
|
||||
"CONNECT",
|
||||
"PATCH",
|
||||
};
|
||||
|
||||
enum class Header
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
// https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
|
||||
ACCEPT,
|
||||
ACCEPT_CHARSET,
|
||||
ACCEPT_ENCODING,
|
||||
ACCEPT_LANGUAGE,
|
||||
ACCEPT_DATETIME,
|
||||
ACCESS_CONTROL_REQUEST_METHOD,
|
||||
ACCESS_CONTROL_REQUEST_HEADERS,
|
||||
AUTHORIZATION,
|
||||
CACHE_CONTROL,
|
||||
CONNECTION,
|
||||
COOKIE,
|
||||
CONTENT_LENGTH,
|
||||
CONTENT_MD5, // obsolete
|
||||
CONTENT_TYPE,
|
||||
DATE,
|
||||
EXPECT,
|
||||
FORWARDED,
|
||||
FROM,
|
||||
HOST,
|
||||
IF_MATCH,
|
||||
IF_MODIFIED_SINCE,
|
||||
IF_NONE_MATCH,
|
||||
IF_RANGE,
|
||||
IF_UNMODIFIED_SINCE,
|
||||
MAX_FORWARDS,
|
||||
ORIGIN,
|
||||
PRAGMA,
|
||||
PROXY_AUTHORIZATION,
|
||||
RANGE,
|
||||
REFERER,
|
||||
TE, // transfer encoding
|
||||
USER_AGENT,
|
||||
UPGRADE,
|
||||
VIA,
|
||||
WARNING
|
||||
};
|
||||
|
||||
const std::vector<std::string> headerStrings = {
|
||||
"Accept",
|
||||
"Accept-Charset",
|
||||
"Accept-Encoding",
|
||||
"Accept-Language",
|
||||
"Accept-Datetime",
|
||||
"Access-Control-Request-Method",
|
||||
"Access-Control-Request-Headers",
|
||||
"Authorization",
|
||||
"Cache-Control",
|
||||
"Connection",
|
||||
"Cookie",
|
||||
"Content-Length",
|
||||
"Content-MD5",
|
||||
"Content-Type",
|
||||
"Date",
|
||||
"Expect",
|
||||
"Forwarded",
|
||||
"From",
|
||||
"Host",
|
||||
"If-Match",
|
||||
"If-Modified-Since",
|
||||
"If-None-Match",
|
||||
"If-Range",
|
||||
"If-Unmodified-Since",
|
||||
"Max-Forwards",
|
||||
"Origin",
|
||||
"Pragma",
|
||||
"Proxy-Authorization",
|
||||
"Range",
|
||||
"Referer",
|
||||
"TE",
|
||||
"User-Agent",
|
||||
"Upgrade",
|
||||
"Via",
|
||||
"Warning",
|
||||
};
|
||||
}
|
||||
308
src/constants/httpresponse.hpp
Normal file
308
src/constants/httpresponse.hpp
Normal file
@@ -0,0 +1,308 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace HttpResponse
|
||||
{
|
||||
enum class CodeRange
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
||||
INFORMATIONAL = 100,
|
||||
SUCCESS = 200,
|
||||
REDIRECTION = 300,
|
||||
CLIENT_ERROR = 400,
|
||||
SERVER_ERROR = 500
|
||||
};
|
||||
|
||||
const std::vector<int> codeValues
|
||||
{
|
||||
100,
|
||||
101,
|
||||
102,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
226,
|
||||
300,
|
||||
301,
|
||||
302,
|
||||
303,
|
||||
304,
|
||||
305,
|
||||
306,
|
||||
307,
|
||||
308,
|
||||
400,
|
||||
401,
|
||||
402,
|
||||
403,
|
||||
404,
|
||||
405,
|
||||
406,
|
||||
407,
|
||||
408,
|
||||
409,
|
||||
410,
|
||||
411,
|
||||
412,
|
||||
413,
|
||||
414,
|
||||
415,
|
||||
416,
|
||||
417,
|
||||
418,
|
||||
421,
|
||||
422,
|
||||
423,
|
||||
424,
|
||||
426,
|
||||
428,
|
||||
429,
|
||||
431,
|
||||
451,
|
||||
500,
|
||||
501,
|
||||
502,
|
||||
503,
|
||||
504,
|
||||
505,
|
||||
506,
|
||||
507,
|
||||
508,
|
||||
510,
|
||||
511,
|
||||
};
|
||||
|
||||
enum class Code : int
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
CONTINUE,
|
||||
SWITCHING_PROTOCOLS,
|
||||
PROCESSING,
|
||||
OK,
|
||||
CREATED,
|
||||
ACCEPTED,
|
||||
NON_AUTHORITATIVE_INFORMATION,
|
||||
NO_CONTENT,
|
||||
RESET_CONTENT,
|
||||
PARTIAL_CONTENT,
|
||||
MULTI_STATUS,
|
||||
ALREADY_REPORTED,
|
||||
IM_USED,
|
||||
MULTIPLE_CHOICES,
|
||||
MOVED_PERMANENTLY,
|
||||
FOUND,
|
||||
SEE_OTHER,
|
||||
NOT_MODIFIED,
|
||||
USE_PROXY,
|
||||
UNUSED,
|
||||
TEMPORARY_REDIRECT,
|
||||
PERMANENT_REDIRECT,
|
||||
BAD_REQUEST,
|
||||
UNAUTHORIZED,
|
||||
PAYMENT_REQUIRED,
|
||||
FORBIDDEN,
|
||||
NOT_FOUND,
|
||||
METHOD_NOT_ALLOWED,
|
||||
NOT_ACCEPTABLE,
|
||||
PROXY_AUTHENTICATION_REQUIRED,
|
||||
REQUEST_TIMEOUT,
|
||||
CONFLICT,
|
||||
GONE,
|
||||
LENGTH_REQUIRED,
|
||||
PRECONDITION_FAILED,
|
||||
PAYLOAD_TOO_LARGE,
|
||||
URI_TOO_LONG,
|
||||
UNSUPPORTED_MEDIA_TYPE,
|
||||
RANGE_NOT_SATISFIABLE,
|
||||
EXPECTATION_FAILED,
|
||||
I_AM_A_TEAPOT,
|
||||
MISDIRECTED_REQUEST,
|
||||
UNPROCESSABLE_ENTITY,
|
||||
LOCKED,
|
||||
FAILED_DEPENDENCY,
|
||||
UPGRADE_REQUIRED,
|
||||
PRECONDITION_REQUIRED,
|
||||
TOO_MANY_REQUESTS,
|
||||
REQUEST_HEADER_FIELDS_TOO_LARGE,
|
||||
UNAVAILABLE_FOR_LEGAL_REASONS,
|
||||
INTERNAL_SERVER_ERROR,
|
||||
NOT_IMPLEMENTED,
|
||||
BAD_GATEWAY,
|
||||
SERVICE_UNAVAILABLE,
|
||||
GATEWAY_TIMEOUT,
|
||||
HTTP_VERSION_NOT_SUPPORTED,
|
||||
VARIANT_ALSO_NEGOTIATES,
|
||||
INSUFFICIENT_STORAGE,
|
||||
LOOP_DETECTED,
|
||||
NOT_EXTENDED,
|
||||
NETWORK_AUTHENTICATION_REQUIRED
|
||||
};
|
||||
|
||||
const std::vector<std::string> codeStrings = {
|
||||
"Continue",
|
||||
"Switching Protocols",
|
||||
"Processing",
|
||||
"OK",
|
||||
"Created",
|
||||
"Accepted",
|
||||
"Non-Authoritative Information",
|
||||
"No Content",
|
||||
"Reset Content",
|
||||
"Partial Content",
|
||||
"Multi-Status",
|
||||
"Already Reported",
|
||||
"IM Used",
|
||||
"Multiple Choices",
|
||||
"Moved Permanently",
|
||||
"Found",
|
||||
"See Other",
|
||||
"Not Modified",
|
||||
"Use Proxy",
|
||||
"(Unused)",
|
||||
"Temporary Redirect",
|
||||
"Permanent Redirect",
|
||||
"Bad Request",
|
||||
"Unauthorized",
|
||||
"Payment Required",
|
||||
"Forbidden",
|
||||
"Not Found",
|
||||
"Method Not Allowed",
|
||||
"Not Acceptable",
|
||||
"Proxy Authentication Required",
|
||||
"Request Timeout",
|
||||
"Conflict",
|
||||
"Gone",
|
||||
"Length Required",
|
||||
"Precondition Failed",
|
||||
"Payload Too Large",
|
||||
"URI Too Long",
|
||||
"Unsupported Media Type",
|
||||
"Range Not Satisfiable",
|
||||
"Expectation Failed",
|
||||
"I am a teapot",
|
||||
"Misdirected Request",
|
||||
"Unprocessable Entity",
|
||||
"Locked",
|
||||
"Failed Dependency",
|
||||
"Upgrade Required",
|
||||
"Precondition Required",
|
||||
"Too Many Requests",
|
||||
"Request Header Fields Too Large",
|
||||
"Unavailable For Legal Reasons",
|
||||
"Internal Server Error",
|
||||
"Not Implemented",
|
||||
"Bad Gateway",
|
||||
"Service Unavailable",
|
||||
"Gateway Timeout",
|
||||
"HTTP Version Not Supported",
|
||||
"Variant Also Negotiates",
|
||||
"Insufficient Storage",
|
||||
"Loop Detected",
|
||||
"Not Extended",
|
||||
"Network Authentication Required",
|
||||
};
|
||||
|
||||
enum class Header
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
// https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
|
||||
ACCESS_CONTROL_ALLOW_ORIGIN,
|
||||
ACCESS_CONTROL_ALLOW_CREDENTIALS,
|
||||
ACCESS_CONTROL_EXPOSE_HEADERS,
|
||||
ACCESS_CONTROL_MAX_AGE,
|
||||
ACCESS_CONTROL_ALLOW_METHODS,
|
||||
ACCESS_CONTROL_ALLOW_HEADERS,
|
||||
ACCEPT_PATCH,
|
||||
ACCEPT_RANGES,
|
||||
AGE,
|
||||
ALLOW,
|
||||
ALT_SVC,
|
||||
CACHE_CONTROL,
|
||||
CONNECTION,
|
||||
CONTENT_DISPOSITION,
|
||||
CONTENT_ENCODING,
|
||||
CONTENT_LANGUAGE,
|
||||
CONTENT_LENGTH,
|
||||
CONTENT_LOCATION,
|
||||
CONTENT_MD5,
|
||||
CONTENT_RANGE,
|
||||
CONTENT_TYPE,
|
||||
DATE,
|
||||
ETAG,
|
||||
EXPIRES,
|
||||
LAST_MODIFIED,
|
||||
LINK,
|
||||
LOCATION,
|
||||
P3P,
|
||||
PRAGMA,
|
||||
PROXY_AUTHENTICATE,
|
||||
PUBLIC_KEY_PINS,
|
||||
RETRY_AFTER,
|
||||
SERVER,
|
||||
SET_COOKIE,
|
||||
STRICT_TRANSPORT_SECURITY,
|
||||
TRAILER,
|
||||
TRANSFER_ENCODING,
|
||||
TK,
|
||||
UPGRADE,
|
||||
VARY,
|
||||
VIA,
|
||||
WARNING,
|
||||
WWW_AUTHENTICATE,
|
||||
X_FRAME_OPTION
|
||||
};
|
||||
|
||||
const std::vector<std::string> headerStrings = {
|
||||
"Access-Control-Allow-Origin",
|
||||
"Access-Control-Allow-Credentials",
|
||||
"Access-Control-Expose-Headers",
|
||||
"Access-Control-Max-Age",
|
||||
"Access-Control-Allow-Methods",
|
||||
"Access-Control-Allow-Headers",
|
||||
"Accept-Patch",
|
||||
"Accept-Ranges",
|
||||
"Age",
|
||||
"Allow",
|
||||
"Alt-Svc",
|
||||
"Cache-Control",
|
||||
"Connection",
|
||||
"Content-Disposition",
|
||||
"Content-Encoding",
|
||||
"Content-Language",
|
||||
"Content-Length",
|
||||
"Content-Location",
|
||||
"Content-MD5",
|
||||
"Content-Range",
|
||||
"Content-Type",
|
||||
"Date",
|
||||
"ETag",
|
||||
"Expires",
|
||||
"Last-Modified",
|
||||
"Link",
|
||||
"Location",
|
||||
"P3P",
|
||||
"Pragma",
|
||||
"Proxy-Authenticate",
|
||||
"Public-Key-Pins",
|
||||
"Retry-After",
|
||||
"Server",
|
||||
"Set-Cookie",
|
||||
"Strict-Transport-Security",
|
||||
"Trailer",
|
||||
"Transfer-Encoding",
|
||||
"Tk",
|
||||
"Upgrade",
|
||||
"Vary",
|
||||
"Via",
|
||||
"Warning",
|
||||
"WWW-Authenticate",
|
||||
"X-Frame-Option",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user