`http_status` Paquete de Dart: Una Guía Completa

http_status Paquete de Dart: Una Guía Completa

Descripción

  • Constantes:http_status proporciona constantes estáticas que representan todos los códigos de estado HTTP definidos en RFC 1945 (HTTP/1.0), RFC 2616 (HTTP/1.1), y RFC 2518 (WebDAV).

  • Claridad: Cada constante ofrece un nombre claro (por ejemplo, ok, notFound, forbidden), facilitando la comprensión del significado de un código de estado de un vistazo.

  • Información: Las constantes también ofrecen una descripción concisa del código de estado, que puede ser útil para depurar o entender las respuestas de la API.

Códigos de estado HTTP

CódigoNombre de estado HTTPhttp_status (v1.x - v2.x Deprecated [obsoleto])http_status (v2.x - v3.x)
100ContinueContinue / CONTINUEcontinue_
101Switching ProtocolsSwitching_Protocols / SWITCHING_PROTOCOLSswitchingProtocols
102ProcessingProcessing / PROCESSINGprocessing
103Early Hints-earlyHints
200OKOk / OKok
201CreatedCreated / CREATEDcreated
202AcceptedAccepted / ACCEPTEDaccepted
203Non Authoritative InformationNonAuthoritative_Information / NON_AUTHORITATIVE_INFORMATIONnonAuthoritativeInformation
204No ContentNo_Content / NO_CONTENTnoContent
205Reset ContentReset_Content / RESET_CONTENTresetContent
206Partial ContentPartial_Content / PARTIAL_CONTENTpartialContent
207Multi-StatusMultiStatus / MULTISTATUSmultiStatus
208Already ReportedAlready_Reported / ALREADY_REPORTEDalreadyReported
226I'M UsedIM_Used / IM_USEDimUsed
300Multiple ChoicesMultiple_Choices / MULTIPLE_CHOICESmultipleChoices
301Moved PermanentlyMoved_Permanently / MOVED_PERMANENTLYmovedPermanently
302Found / Moved TemporarilyFound / Moved_Temporarily / FOUND / MOVED_TEMPORARILYfound / movedTemporarily
303See OtherSee_Other / SEE_OTHERseeOther
304Not ModifiedNot_Modified / NOT_MODIFIEDnotModified
305Use ProxyUse_Proxy / USE_PROXYuseProxy
307Temporary RedirectTemporary_Redirect / TEMPORARY_REDIRECTtemporaryRedirect
308Permanent RedirectPermanent_Redirect / PERMANENT_REDIRECTpermanentRedirect
400Bad RequestBad_Request / BAD_REQUESTbadRequest
401UnauthorizedUnauthorized / UNAUTHORIZEDunauthorized
402Payment RequiredPayment_Required / PAYMENT_REQUIREDpaymentRequired
403ForbiddenForbidden / FORBIDDENforbidden
404Not FoundNot_Found / NOT_FOUNDnotFound
405Method Not AllowedMethod_Not_Allowed / METHOD_NOT_ALLOWEDmethodNotAllowed
406Not AcceptableNot_Acceptable / NOT_ACCEPTABLEnotAcceptable
407Proxy Authentication RequiredProxy_Authentication_Required / PROXY_AUTHENTICATION_REQUIREDproxyAuthenticationRequired
408Request TimeoutRequest_Timeout / REQUEST_TIMEOUTrequestTimeout
409ConflictConflict / CONFLICTconflict
410GoneGone / GONEgone
411Length RequiredLength_Required / LENGTH_REQUIREDlengthRequired
412Precondition FailedPrecondition_Failed / PRECONDITION_FAILEDpreconditionFailed
413Request Entity Too LargePayload_Too_Large / PAYLOAD_TOO_LARGE / Request_Entity_Too_Large / REQUEST_ENTITY_TOO_LARGErequestEntityTooLarge
414Request-URI Too LongRequestURI_Too_Long / REQUESTURI_TOO_LONG / Request_Uri_Too_Long / REQUEST_URI_TOO_LONGrequestUriTooLong
415Unsupported Media TypeUnsupported_Media_Type / UNSUPPORTED_MEDIA_TYPEunsupportedMediaType
416Requested Range Not SatisfiableRequested_Range_Not_Satisfiable / REQUESTED_RANGE_NOT_SATISFIABLErequestedRangeNotSatisfiable
417Expectation FailedExpectation_Failed / EXPECTATION_FAILEDexpectationFailed
418I'm a teapot-imATeapot
419Insufficient Space on Resource-insufficientSpaceOnResource
420Method Failure-methodFailure
421Misdirected RequestMisdirected_Request / MISDIRECTED_REQUESTmisdirectedRequest
422Unprocessable EntityUnprocessable_Entity / UNPROCESSABLE_ENTITYunprocessableEntity
423LockedLocked / LOCKEDlocked
424Failed DependencyFailed_Dependency / FAILED_DEPENDENCYfailedDependency
426Upgrade RequiredUpgrade_Required / UPGRADE_REQUIREDupgradeRequired
428Precondition RequiredPrecondition_Required / PRECONDITION_REQUIREDpreconditionRequired
429Too Many RequestsToo_Many_Requests / TOO_MANY_REQUESTStooManyRequests
431Request Header Fields Too LargeRequest_Header_Fields_Too_Large / REQUEST_HEADER_FIELDS_TOO_LARGErequestHeaderFieldsTooLarge
444Connection Closed Without ResponseConnection_Closed_Without_Response / CONNECTION_CLOSED_WITHOUT_RESPONSEconnectionClosedWithoutResponse
451Unavailable For Legal ReasonsUnavailable_For_Legal_Reasons / UNAVAILABLE_FOR_LEGAL_REASONSunavailableForLegalReasons
499Client Closed RequestClient_Closed_Request / CLIENT_CLOSED_REQUESTclientClosedRequest
500Internal Server ErrorInternal_Server_Error / INTERNAL_SERVER_ERRORinternalServerError
501Not ImplementedNot_Implemented / NOT_IMPLEMENTEDnotImplemented
502Bad GatewayBad_Gateway / BAD_GATEWAYbadGateway
503Service UnavailableService_Unavailable / SERVICE_UNAVAILABLEserviceUnavailable
504Gateway TimeoutGateway_Timeout / GATEWAY_TIMEOUTgatewayTimeout
505HTTP Version Not SupportedHTTP_Version_Not_Supported / HTTP_VERSION_NOT_SUPPORTEDhttpVersionNotSupported
506Variant Also NegotiatesVariant_Also_Negotiates / VARIANT_ALSO_NEGOTIATESvariantAlsoNegotiates
507Insufficient StorageInsufficient_Storage / INSUFFICIENT_STORAGEinsufficientStorage
508Loop DetectedLoop_Detected / LOOP_DETECTEDloopDetected
510Not ExtendedNot_Extended / NOT_EXTENDEDnotExtended
511Network Authentication RequiredNetwork_Authentication_Required / NETWORK_AUTHENTICATION_REQUIREDnetworkAuthenticationRequired
599Network Connect Timeout ErrorNetwork_Connect_Timeout_Error / NETWORK_CONNECT_TIMEOUT_ERRORnetworkConnectTimeoutError

Una librería Dart para debuguear y mostrar códigos de estado http. Incluye 63 códigos de estado, mensajes y descripciones extraídos de las especificaciones oficiales https://tools.ietf.org/html/rfc723 y https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/

Características principales

  • API limpia: La interfaz es sencilla e intuitiva, simplificando el uso de códigos de estado en sus aplicaciones Dart.

  • Legibilidad: Los nombres y descripciones de las constantes mejoran la claridad del código y su mantenimiento.

  • Seguridad tipográfica: Las constantes estáticas evitan errores tipográficos y el uso accidental de códigos de estado incorrectos.

  • Completitud: Una amplia cobertura de los códigos de estado HTTP asegura un manejo fiable de varios escenarios de respuesta.

Instalación

Continúe este artículo en mi blog personal aquí.