Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 02b8c3b

Browse files
committed
Add HttpStatus table
1 parent 678dc00 commit 02b8c3b

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

src/ServiceStack.Text/HttpUtils.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,4 +1259,93 @@ public static string GetExtension(string compressionType)
12591259
}
12601260
}
12611261
}
1262+
1263+
public static class HttpStatus
1264+
{
1265+
public static string GetStatusDescription(int statusCode)
1266+
{
1267+
if (statusCode >= 100 && statusCode < 600)
1268+
{
1269+
int i = statusCode / 100;
1270+
int j = statusCode % 100;
1271+
1272+
if (j < Descriptions[i].Length)
1273+
return Descriptions[i][j];
1274+
}
1275+
1276+
return string.Empty;
1277+
}
1278+
1279+
private static readonly string[][] Descriptions = new string[][]
1280+
{
1281+
null,
1282+
new[]
1283+
{
1284+
/* 100 */ "Continue",
1285+
/* 101 */ "Switching Protocols",
1286+
/* 102 */ "Processing"
1287+
},
1288+
new[]
1289+
{
1290+
/* 200 */ "OK",
1291+
/* 201 */ "Created",
1292+
/* 202 */ "Accepted",
1293+
/* 203 */ "Non-Authoritative Information",
1294+
/* 204 */ "No Content",
1295+
/* 205 */ "Reset Content",
1296+
/* 206 */ "Partial Content",
1297+
/* 207 */ "Multi-Status"
1298+
},
1299+
new[]
1300+
{
1301+
/* 300 */ "Multiple Choices",
1302+
/* 301 */ "Moved Permanently",
1303+
/* 302 */ "Found",
1304+
/* 303 */ "See Other",
1305+
/* 304 */ "Not Modified",
1306+
/* 305 */ "Use Proxy",
1307+
/* 306 */ string.Empty,
1308+
/* 307 */ "Temporary Redirect"
1309+
},
1310+
new[]
1311+
{
1312+
/* 400 */ "Bad Request",
1313+
/* 401 */ "Unauthorized",
1314+
/* 402 */ "Payment Required",
1315+
/* 403 */ "Forbidden",
1316+
/* 404 */ "Not Found",
1317+
/* 405 */ "Method Not Allowed",
1318+
/* 406 */ "Not Acceptable",
1319+
/* 407 */ "Proxy Authentication Required",
1320+
/* 408 */ "Request Timeout",
1321+
/* 409 */ "Conflict",
1322+
/* 410 */ "Gone",
1323+
/* 411 */ "Length Required",
1324+
/* 412 */ "Precondition Failed",
1325+
/* 413 */ "Request Entity Too Large",
1326+
/* 414 */ "Request-Uri Too Long",
1327+
/* 415 */ "Unsupported Media Type",
1328+
/* 416 */ "Requested Range Not Satisfiable",
1329+
/* 417 */ "Expectation Failed",
1330+
/* 418 */ string.Empty,
1331+
/* 419 */ string.Empty,
1332+
/* 420 */ string.Empty,
1333+
/* 421 */ string.Empty,
1334+
/* 422 */ "Unprocessable Entity",
1335+
/* 423 */ "Locked",
1336+
/* 424 */ "Failed Dependency"
1337+
},
1338+
new[]
1339+
{
1340+
/* 500 */ "Internal Server Error",
1341+
/* 501 */ "Not Implemented",
1342+
/* 502 */ "Bad Gateway",
1343+
/* 503 */ "Service Unavailable",
1344+
/* 504 */ "Gateway Timeout",
1345+
/* 505 */ "Http Version Not Supported",
1346+
/* 506 */ string.Empty,
1347+
/* 507 */ "Insufficient Storage"
1348+
}
1349+
};
1350+
}
12621351
}

0 commit comments

Comments
 (0)