Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Status.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_IO_Network_HTTP_Status_h_
5#define _Stroika_Foundation_IO_Network_HTTP_Status_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9/**
10 */
11
13
14 /**
15 * See https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes for details on these status codes.
16 */
17 using Status = unsigned int;
18
19 /*
20 * See https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes for details on these status codes.
21 */
22 namespace StatusCodes {
23 constexpr Status kOK = 200;
24 constexpr Status kCreated = 201;
25 constexpr Status kNoContent = 204;
26
27 constexpr Status kMovedPermanently = 301;
28 constexpr Status kNotModified = 304;
29
30 /*
31 * Bad CLIENT request.
32 * The request could not be understood by the server due to malformed syntax.
33 * The client SHOULD NOT repeat the request without modifications.
34 */
35 constexpr Status kBadRequest = 400;
36 constexpr Status kUnauthorized = 401;
37 constexpr Status kNotFound = 404;
38 constexpr Status kMethodNotAllowed = 405;
39 /**
40 * The server did not receive a complete request message within the time that it was prepared to wait.
41 */
42 constexpr Status kRequestTimeout = 408;
43 constexpr Status kConflict = 408;
44
45 /**
46 * \brief The 429 status code indicates that the user has sent too many requests in a given amount of time ("rate limiting").
47 *
48 * https://www.rfc-editor.org/rfc/rfc6585.html#section-4
49 */
50 constexpr Status kTooManyRequests = 429;
51
52 /*
53 * This is principally for internal server exceptions.
54 */
55 constexpr Status kInternalError = 500;
56 /*
57 * Indicates that the server is temporarily unavailable, usually due to high load or maintenance.
58 */
59 constexpr Status kServiceUnavailable = 503;
60 /*
61 * The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP)
62 * or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
63 */
64 constexpr Status kGatewayTimeout = 504;
65 }
66
67 /**
68 * \brief several status codes considered OK, so check if it is among them
69 */
70 constexpr bool IsOK (Status s);
71
72 /**
73 * \brief several status codes considered client error, so check if it is among them
74 */
75 constexpr bool IsClientError (Status s);
76
77 /**
78 * \brief several status codes considered Server Error, so check if it is among them
79 */
80 constexpr bool IsServerError (Status s);
81
82}
83
84/*
85 ********************************************************************************
86 ***************************** Implementation Details ***************************
87 ********************************************************************************
88 */
89#include "Status.inl"
90
91#endif /*_Stroika_Foundation_IO_Network_HTTP_Status_h_*/
constexpr bool IsClientError(Status s)
several status codes considered client error, so check if it is among them
Definition Status.inl:22
constexpr bool IsOK(Status s)
several status codes considered OK, so check if it is among them
Definition Status.inl:12
constexpr bool IsServerError(Status s)
several status codes considered Server Error, so check if it is among them
Definition Status.inl:32