Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added map with status texts #214

Merged
merged 3 commits into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions core/src/main/scala/sttp/model/StatusText.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package sttp.model

import sttp.model.StatusCode._

case class StatusText(text: String)

object StatusText {

private val statusTexts: Map[StatusCode, String] = Map(
Continue -> "Continue",
SwitchingProtocols -> "Switching Protocols",
Processing -> "Processing",
EarlyHints -> "Early Hints",
Ok -> "Ok",
Created -> "Created",
Accepted -> "Accepted",
NonAuthoritativeInformation -> "Non Authoritative Information",
NoContent -> "No Content",
ResetContent -> "Reset Content",
PartialContent -> "Partial Content",
MultiStatus -> "Multi Status",
AlreadyReported -> "Already Reported",
ImUsed -> "Im Used",
MultipleChoices -> "Multiple Choices",
MovedPermanently -> "Moved Permanently",
Found -> "Found",
SeeOther -> "See Other",
NotModified -> "Not Modified",
UseProxy -> "Use Proxy",
TemporaryRedirect -> "Temporary Redirect",
PermanentRedirect -> "Permanent Redirect",
BadRequest -> "Bad Request",
Unauthorized -> "Unauthorized",
PaymentRequired -> "Payment Required",
Forbidden -> "Forbidden",
NotFound -> "Not Found",
MethodNotAllowed -> "Method Not Allowed",
NotAcceptable -> "Not Acceptable",
ProxyAuthenticationRequired -> "Proxy Authentication Required",
RequestTimeout -> "Request Timeout",
Conflict -> "Conflict",
Gone -> "Gone",
LengthRequired -> "Length Required",
PreconditionFailed -> "Precondition Failed",
PayloadTooLarge -> "Payload Too Large",
UriTooLong -> "Uri Too Long",
UnsupportedMediaType -> "Unsupported MediaType",
RangeNotSatisfiable -> "Range Not Satisfiable",
ExpectationFailed -> "Expectation Failed",
MisdirectedRequest -> "Misdirected Request",
UnprocessableEntity -> "Unprocessable Entity",
Locked -> "Locked",
FailedDependency -> "Failed Dependency",
UpgradeRequired -> "Upgrade Required",
PreconditionRequired -> "Precondition Required",
TooManyRequests -> "Too Many Requests",
RequestHeaderFieldsTooLarge -> "RequestHeader Fields Too Large",
UnavailableForLegalReasons -> "Unavailable For Legal Reasons",
InternalServerError -> "Internal Server Error",
NotImplemented -> "Not Implemented",
BadGateway -> "Bad Gateway",
ServiceUnavailable -> "Service Unavailable",
GatewayTimeout -> "Gateway Timeout",
HttpVersionNotSupported -> "Http Version Not Supported",
VariantAlsoNegotiates -> "Variant Also Negotiates",
InsufficientStorage -> "Insufficient Storage",
LoopDetected -> "Loop Detected",
NotExtended -> "Not Extended",
NetworkAuthenticationRequired -> "Network Authentication Required"
)

def default(statusCode: StatusCode): Option[String] =
statusTexts.get(statusCode)
}