Skip to main content
Version: 2.0.x

Status

HTTP status codes are standard response codes given by web services on the Internet. The codes help identify the cause of the problem when a web page or other resource does not load properly.

In ZIO HTTP, Status is a sealed trait that represents the status code of an HTTP response. It is designed to encode HTTP status codes and headers along with custom methods and headers (as defined in RFC2615).

The ZIO HTTP has a predefined set of constructors for Response for the most common status codes. To create a Response with a status code, we can use the predefined constructors for the most common status codes, like Response.ok, Response.notFound, Response.forbidden, etc.

But, if we need a specific status code, we can pass one of the following status codes to the Response.status constructor:

import zio.http._

Response.status(Status.PermanentRedirect)
// res0: Response = Response(
// status = PermanentRedirect,
// headers = Iterable(),
// body = Body.empty
// )

Here is a list of status codes and their descriptions:

CategoryStatus Class NameDescriptionCode Range
InformationalContinueThe server has received the request headers, and the client should proceed to send the request body.100
SwitchingProtocolsThe server is switching protocols according to the client's request.101
ProcessingThe server is processing the request but has not completed it yet.102
SuccessOkThe request has succeeded.200
CreatedThe request has been fulfilled and resulted in a new resource being created.201
AcceptedThe request has been accepted for processing but has not been completed.202
NonAuthoritativeInformationThe returned meta-information in the entity-header is not the definitive set available from the origin server.203
NoContentThe server successfully processed the request and is not returning any content.204
ResetContentThe server successfully processed the request but is not returning any content.205
PartialContentThe server successfully processed only part of the request.206
MultiStatusThe server has multiple status codes for different independent operations.207
RedirectionMultipleChoicesThe request has multiple possible responses and the user or user agent can choose the correct one.300
MovedPermanentlyThe requested page has been permanently moved to a new location.301
FoundThe requested page has been found but is temporarily located at another URI.302
SeeOtherThe response to the request can be found under another URI using a GET method.303
NotModifiedThe resource has not been modified since the last request.304
UseProxyThe requested resource is available only through a proxy, whose address is provided in the response.305
TemporaryRedirectThe requested resource has been temporarily moved to a different URI.307
PermanentRedirectThe requested resource has been permanently moved to a different URI.308
Client ErrorBadRequestThe request cannot be fulfilled due to bad syntax.400
UnauthorizedThe request requires user authentication.401
PaymentRequiredReserved for future use.402
ForbiddenThe server understood the request, but is refusing to fulfill it.403
NotFoundThe requested resource could not be found but may be available again in the future.404
MethodNotAllowedThe method specified in the request is not allowed for the resource identified by the request URI.405
NotAcceptableThe resource identified by the request is only capable of generating response entities that have content characteristics not acceptable according to the accept headers sent in the request.406
ProxyAuthenticationRequiredSimilar to 401 but authentication is needed for accessing the proxy.407
RequestTimeoutThe server timed out waiting for the request.408
ConflictIndicates that the request could not be processed because of conflict in the request.409
GoneThe requested resource is no longer available at the server and no forwarding address is known.410
LengthRequiredThe server refuses to accept the request without a defined Content-Length.411
PreconditionFailedThe precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.412
RequestEntityTooLargeThe server is refusing to service the request because the request entity is larger than the server is willing or able to process.413
RequestUriTooLongThe server is refusing to interpret the request because the Request-URI is longer than the server is willing to interpret.414
UnsupportedMediaTypeThe request entity has a media type that the server or resource does not support.415
RequestedRangeNotSatisfiableThe client has asked for a portion of the file, but the server cannot supply that portion.416
ExpectationFailedThe server cannot meet the requirements of the Expect request-header field.417
MisdirectedRequestThe request was directed at a server that is not able to produce a response.421
UnprocessableEntityThe request was well-formed but was unable to be followed due to semantic errors.422
LockedThe resource that is being accessed is locked.423
FailedDependencyThe method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.424
UnorderedCollectionThe server is not able to produce a response representing the current state of the target resource due to some internal error.425
UpgradeRequiredThe server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.426
PreconditionRequiredThe origin server requires the request to be conditional.428
TooManyRequestsThe user has sent too many requests in a given amount of time ("rate limiting").429
RequestHeaderFieldsTooLargeThe server is unwilling to process the request because either an individual header field or all the header fields collectively are too large.431
Server ErrorInternalServerErrorA generic error message, given when an unexpected condition was encountered and no more specific message is suitable.500
NotImplementedThe server either does not recognize the request method, or it lacks the ability to fulfill the request.501
BadGatewayThe server was acting as a gateway or proxy and received an invalid response from the upstream server.502
ServiceUnavailableThe server is currently unable to handle the request due to a temporary overload or maintenance of the server.503
GatewayTimeoutThe server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI.504
HttpVersionNotSupportedThe server does not support the HTTP protocol version that was used in the request.505
VariantAlsoNegotiatesTransparent content negotiation for the request results in a circular reference.506
InsufficientStorageThe server is unable to store the representation needed to complete the request.507
NotExtendedFurther extensions to the request are required for the server to fulfill it.510
NetworkAuthenticationRequiredThe client needs to authenticate to gain network access.511