diff options
author | tjp <tjp@ctrl-c.club> | 2024-01-10 11:07:17 -0700 |
---|---|---|
committer | tjp <tjp@ctrl-c.club> | 2024-01-10 11:10:09 -0700 |
commit | b2ff86d213128bb6f9ec9fa017ee4d566c77a397 (patch) | |
tree | 57283cba10a0d5331cc12194530e2a8158bf4da2 | |
parent | b6c0ba24cf5902e6bafff4243979bb12010aa142 (diff) |
function to get names of gemini response codes
-rw-r--r-- | gemini/response.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gemini/response.go b/gemini/response.go index b3e53aa..ec4ac2b 100644 --- a/gemini/response.go +++ b/gemini/response.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "errors" + "fmt" "io" "strconv" "sync" @@ -249,6 +250,49 @@ func CertInvalid(msg string) *types.Response { } } +func StatusName(status types.Status) string { + switch status { + case StatusInput: + return "StatusInput" + case StatusSensitiveInput: + return "StatusSensitiveInput" + case StatusSuccess: + return "StatusSuccess" + case StatusTemporaryRedirect: + return "StatusTemporaryRedirect" + case StatusPermanentRedirect: + return "StatusPermanentRedirect" + case StatusTemporaryFailure: + return "StatusTemporaryFailure" + case StatusServerUnavailable: + return "StatusServerUnavailable" + case StatusCGIError: + return "StatusCGIError" + case StatusProxyError: + return "StatusProxyError" + case StatusSlowDown: + return "StatusSlowDown" + case StatusPermanentFailure: + return "StatusPermanentFailure" + case StatusNotFound: + return "StatusNotFound" + case StatusGone: + return "StatusGone" + case StatusProxyRequestRefused: + return "StatusProxyRequestRefused" + case StatusBadRequest: + return "StatusBadRequest" + case StatusClientCertificateRequired: + return "StatusClientCertificateRequired" + case StatusCertificateNotAuthorized: + return "StatusCertificateNotAuthorized" + case StatusCertificateNotValid: + return "StatusCertificateNotValid" + default: + return fmt.Sprintf("Unknown (%d)", status) + } +} + // InvalidResponseLineEnding indicates that a gemini response header didn't end with "\r\n". var InvalidResponseLineEnding = errors.New("Invalid response line ending.") |