summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gemini/response.go44
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.")