52constexpr int NUM_1XX_CODES{2};
53const char* Http1xxCodes[NUM_1XX_CODES];
54const char* Http1xxStr =
"Continue\0"
55 "Switching Protocols\0";
57constexpr int NUM_2XX_CODES{7};
58const char* Http2xxCodes[NUM_2XX_CODES];
59const char* Http2xxStr =
"OK\0"
62 "Non-Authoratative Information\0"
67constexpr int NUM_3XX_CODES{8};
68const char* Http3xxCodes[NUM_3XX_CODES];
69const char* Http3xxStr =
"Multiple Choices\0"
76 "Temporary Redirect\0";
78constexpr int NUM_4XX_CODES{18};
79const char* Http4xxCodes[NUM_4XX_CODES];
80const char* Http4xxStr =
"Bad Request\0"
85 "Method Not Allowed\0"
87 "Proxy Authentication Required\0"
92 "Precondition Failed\0"
93 "Request Entity Too Large\0"
94 "Request-URI Too Long\0"
95 "Unsupported Media Type\0"
96 "Requested Range Not Satisfiable\0"
97 "Expectation Failed\0";
99constexpr int NUM_5XX_CODES{11};
100const char* Http5xxCodes[NUM_5XX_CODES];
101const char* Http5xxStr =
"Internal Server Error\0"
104 "Service Unavailable\0"
106 "HTTP Version Not Supported\0"
107 "Variant Also Negotiates\0"
108 "Insufficient Storage\0"
113bool gInitialized{
false};
128 const char* encoded_str,
134 const char* s = encoded_str;
136 for (i = 0; i < tbl_size; i++) {
138 s += strlen(s) + (size_t)1;
147 init_table(Http1xxStr, Http1xxCodes, NUM_1XX_CODES);
148 init_table(Http2xxStr, Http2xxCodes, NUM_2XX_CODES);
149 init_table(Http3xxStr, Http3xxCodes, NUM_3XX_CODES);
150 init_table(Http4xxStr, Http4xxCodes, NUM_4XX_CODES);
151 init_table(Http5xxStr, Http5xxCodes, NUM_5XX_CODES);
177 if (statusCode < 100 || statusCode >= 600) {
181 index = statusCode % 100;
182 table_num = statusCode / 100;
184 if (table_num == 1 && index < NUM_1XX_CODES) {
185 return Http1xxCodes[index];
188 if (table_num == 2 && index < NUM_2XX_CODES) {
189 return Http2xxCodes[index];
192 if (table_num == 3 && index < NUM_3XX_CODES) {
193 return Http3xxCodes[index];
196 if (table_num == 4 && index < NUM_4XX_CODES) {
197 return Http4xxCodes[index];
200 if (table_num == 5 && index < NUM_5XX_CODES) {
201 return Http5xxCodes[index];