http_status 3.0.0 http_status: ^3.0.0 copied to clipboard
Constants enumerating the HTTP status codes in Dart. All status codes defined in RFC1945 (HTTP/1.0, RFC2616 (HTTP/1.1), and RFC2518 (WebDAV) are supported.
// Copyright (c) 2017, Era Productions.
// Copyright (c) 2024, TECH-ANDGAR.
// All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:http_status/http_status.dart';
void main() {
print('${HttpStatusCode.ok}');
print('${HttpStatus.ok}');
print('${HttpStatusCode.noContent}');
print('${HttpStatus.fromCode(404)}');
// isInformation (HttpStatusCode 200-299)
print(HttpStatusCode.processing.isInformationHttpStatusCode); // true
print(HttpStatusCode.notFound.isInformationHttpStatusCode); // false
// isSuccessful (HttpStatusCode 200-299)
print(200.isSuccessfulHttpStatusCode);
print(400.isSuccessfulHttpStatusCode);
print(HttpStatusCode.accepted.isSuccessfulHttpStatusCode);
print(HttpStatusCode.notFound.isSuccessfulHttpStatusCode);
// isRedirect (HttpStatusCode 300-399)
print(HttpStatusCode.permanentRedirect.isRedirectHttpStatusCode); // true
print(HttpStatusCode.notFound.isRedirectHttpStatusCode); // false
// isClientError (HttpStatusCode 400-499)
print(HttpStatusCode.notFound.isClientErrorHttpStatusCode); // true
print(HttpStatusCode.processing.isClientErrorHttpStatusCode); // false
// isServerError (HttpStatusCode 500-599)
print(HttpStatusCode.internalServerError.isServerErrorHttpStatusCode); // true
print(HttpStatusCode.notFound.isServerErrorHttpStatusCode); // false;
}