IntHttpStatusCodeExtension extension
Extension IntHttpStatusCodeExtension
on int
This extension provides additional functionality to integer values, allowing them to be easily checked against common HTTP status code ranges. HTTP status codes are divided into five distinct classes, each representing a type of response the server will send in answer to a client's request.
Usage of this extension simplifies checking the category of an HTTP status code without needing to remember the specific ranges for each category. It extends the built-in int type with simple, readable properties.
Examples:
int statusCode = 200;
bool isSuccess = statusCode.isSuccessfulHttpStatusCode; // true
statusCode = 404;
bool isClientError = statusCode.isClientErrorHttpStatusCode; // true
This makes your code cleaner and more expressive when handling HTTP responses.
- on
Properties
- isClientErrorHttpStatusCode → bool
-
Checks if the integer represents a client error HTTP status code.
no setter
- isInformationHttpStatusCode → bool
-
Checks if the integer represents an informational HTTP status code.
no setter
- isRedirectHttpStatusCode → bool
-
Checks if the integer represents a redirection HTTP status code.
no setter
- isServerErrorHttpStatusCode → bool
-
Checks if the integer represents a server error HTTP status code.
no setter
- isSuccessfulHttpStatusCode → bool
-
Checks if the integer represents a successful HTTP status code.
no setter