-
Notifications
You must be signed in to change notification settings - Fork 28
Added map with status texts #214
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package sttp.model | ||
|
||
import sttp.model.StatusCode._ | ||
|
||
object StatusTexts { | ||
|
||
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 get(statusCode: StatusCode): String = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to return an Are these texts "default" descriptions, that is, might they differ in actual server responses? Why would need this map in the first place? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so maybe let's call this method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
statusTexts.getOrElse(statusCode, "") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this models a status code, why would it include a status text? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As if I think correctly status text is to a degree part of status code as it should be same as name of status code https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks as if it's a different property on a
Response
class, which can be usually calculated from the status code, but definitely not part of itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fixes incoming