2022-07-23 00:19:12 +00:00
|
|
|
#ifndef TELODENDRIA_HTTP_H
|
|
|
|
#define TELODENDRIA_HTTP_H
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
typedef enum HttpRequestMethod
|
|
|
|
{
|
2022-07-23 00:19:12 +00:00
|
|
|
HTTP_GET,
|
|
|
|
HTTP_HEAD,
|
|
|
|
HTTP_POST,
|
|
|
|
HTTP_PUT,
|
|
|
|
HTTP_DELETE,
|
|
|
|
HTTP_CONNECT,
|
|
|
|
HTTP_OPTIONS,
|
|
|
|
HTTP_TRACE,
|
|
|
|
HTTP_PATCH
|
|
|
|
} HttpRequestMethod;
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
typedef enum HttpStatus
|
|
|
|
{
|
2022-07-23 00:19:12 +00:00
|
|
|
/* Informational responses */
|
|
|
|
HTTP_CONTINUE = 100,
|
|
|
|
HTTP_SWITCHING_PROTOCOLS = 101,
|
|
|
|
HTTP_EARLY_HINTS = 103,
|
2022-07-25 19:25:06 +00:00
|
|
|
|
2022-07-23 00:19:12 +00:00
|
|
|
/* Successful responses */
|
|
|
|
HTTP_OK = 200,
|
|
|
|
HTTP_CREATED = 201,
|
|
|
|
HTTP_ACCEPTED = 202,
|
|
|
|
HTTP_NON_AUTHORITATIVE_INFORMATION = 203,
|
|
|
|
HTTP_NO_CONTENT = 204,
|
|
|
|
HTTP_RESET_CONTENT = 205,
|
|
|
|
HTTP_PARTIAL_CONTENT = 206,
|
2022-07-25 19:25:06 +00:00
|
|
|
|
2022-07-23 00:19:12 +00:00
|
|
|
/* Redirection messages */
|
|
|
|
HTTP_MULTIPLE_CHOICES = 300,
|
|
|
|
HTTP_MOVED_PERMANENTLY = 301,
|
|
|
|
HTTP_FOUND = 302,
|
|
|
|
HTTP_SEE_OTHER = 303,
|
|
|
|
HTTP_NOT_MODIFIED = 304,
|
|
|
|
HTTP_TEMPORARY_REDIRECT = 307,
|
|
|
|
HTTP_PERMANENT_REDIRECT = 308,
|
2022-07-25 19:25:06 +00:00
|
|
|
|
2022-07-23 00:19:12 +00:00
|
|
|
/* Client error messages */
|
|
|
|
HTTP_BAD_REQUEST = 400,
|
|
|
|
HTTP_UNAUTHORIZED = 401,
|
|
|
|
HTTP_FORBIDDEN = 403,
|
|
|
|
HTTP_NOT_FOUND = 404,
|
|
|
|
HTTP_METHOD_NOT_ALLOWED = 405,
|
|
|
|
HTTP_NOT_ACCEPTABLE = 406,
|
|
|
|
HTTP_PROXY_AUTH_REQUIRED = 407,
|
|
|
|
HTTP_REQUEST_TIMEOUT = 408,
|
|
|
|
HTTP_CONFLICT = 409,
|
|
|
|
HTTP_GONE = 410,
|
|
|
|
HTTP_LENGTH_REQUIRED = 411,
|
|
|
|
HTTP_PRECONDITION_FAILED = 412,
|
|
|
|
HTTP_PAYLOAD_TOO_LARGE = 413,
|
|
|
|
HTTP_URI_TOO_LONG = 414,
|
|
|
|
HTTP_UNSUPPORTED_MEDIA_TYPE = 415,
|
|
|
|
HTTP_RANGE_NOT_SATISFIABLE = 416,
|
|
|
|
HTTP_EXPECTATION_FAILED = 417,
|
|
|
|
HTTP_TEAPOT = 418,
|
|
|
|
HTTP_UPGRADE_REQUIRED = 426,
|
|
|
|
HTTP_PRECONDITION_REQUIRED = 428,
|
|
|
|
HTTP_TOO_MANY_REQUESTS = 429,
|
|
|
|
HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
|
|
HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
2022-07-25 19:25:06 +00:00
|
|
|
|
2022-07-23 00:19:12 +00:00
|
|
|
/* Server error responses */
|
|
|
|
HTTP_INTERNAL_SERVER_ERROR = 500,
|
|
|
|
HTTP_NOT_IMPLEMENTED = 501,
|
|
|
|
HTTP_BAD_GATEWAY = 502,
|
|
|
|
HTTP_SERVICE_UNAVAILABLE = 503,
|
|
|
|
HTTP_GATEWAY_TIMEOUT = 504,
|
|
|
|
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
|
|
HTTP_VARIANT_ALSO_NEGOTIATES = 506,
|
|
|
|
HTTP_NOT_EXTENDED = 510,
|
|
|
|
HTTP_NETWORK_AUTH_REQUIRED = 511
|
|
|
|
} HttpStatus;
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
struct HttpRequest
|
|
|
|
{
|
2022-07-23 00:19:12 +00:00
|
|
|
HttpRequestMethod method;
|
|
|
|
};
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
struct HttpResponse
|
|
|
|
{
|
2022-07-23 00:19:12 +00:00
|
|
|
HttpStatus status;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern char *
|
2022-07-25 19:25:06 +00:00
|
|
|
HttpGetStatusString(const HttpStatus httpStatus);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern HttpRequestMethod
|
2022-07-25 19:25:06 +00:00
|
|
|
HttpRequestMethodFromString(const char *requestMethod);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
typedef struct HttpRequest HttpRequest;
|
|
|
|
typedef struct HttpResponse HttpResponse;
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
typedef void (*HttpHandler) (HttpRequest *, HttpResponse *);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
#endif
|