1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-29 20:05:23 +00:00

More fine-grained error codes, support client cert errors

This commit is contained in:
makeworld 2020-11-04 20:55:34 -05:00
parent 6993c24470
commit 277cc91881
2 changed files with 36 additions and 4 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Edit current URL with <kbd>e</kbd> (#87) - Edit current URL with <kbd>e</kbd> (#87)
- If `emoji_favicons` is enabled, new bookmarks will have the domain's favicon prepended (#69, #90) - If `emoji_favicons` is enabled, new bookmarks will have the domain's favicon prepended (#69, #90)
- The `BROWSER` env var is now also checked when opening web links on Unix (#93) - The `BROWSER` env var is now also checked when opening web links on Unix (#93)
- More accurate error messages based on server response code
### Changed ### Changed
- Disabling the `color` config setting also disables ANSI colors in pages (#79, #86) - Disabling the `color` config setting also disables ANSI colors in pages (#79, #86)

View File

@ -478,8 +478,8 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
// Could be a non 20 (or 21) status code, or a different kind of document // Could be a non 20 (or 21) status code, or a different kind of document
// Handle each status code // Handle each status code
switch gemini.SimplifyStatus(res.Status) { switch res.Status {
case 10: case 10, 11:
userInput, ok := Input(res.Meta) userInput, ok := Input(res.Meta)
if ok { if ok {
// Make another request with the query string added // Make another request with the query string added
@ -492,7 +492,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
return ret(handleURL(t, parsed.String(), 0)) return ret(handleURL(t, parsed.String(), 0))
} }
return ret("", false) return ret("", false)
case 30: case 30, 31:
parsedMeta, err := url.Parse(res.Meta) parsedMeta, err := url.Parse(res.Meta)
if err != nil { if err != nil {
Error("Redirect Error", "Invalid URL: "+err.Error()) Error("Redirect Error", "Invalid URL: "+err.Error())
@ -520,13 +520,44 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
case 40: case 40:
Error("Temporary Failure", cview.Escape(res.Meta)) Error("Temporary Failure", cview.Escape(res.Meta))
return ret("", false) return ret("", false)
case 41:
Error("Server Unavailable", cview.Escape(res.Meta))
return ret("", false)
case 42:
Error("CGI Error", cview.Escape(res.Meta))
return ret("", false)
case 43:
Error("Proxy Failure", cview.Escape(res.Meta))
return ret("", false)
case 44:
Error("Slow Down", "You should wait "+cview.Escape(res.Meta)+" seconds before making another request.")
return ret("", false)
case 50: case 50:
Error("Permanent Failure", cview.Escape(res.Meta)) Error("Permanent Failure", cview.Escape(res.Meta))
return ret("", false) return ret("", false)
case 51:
Error("Not Found", cview.Escape(res.Meta))
return ret("", false)
case 52:
Error("Gone", cview.Escape(res.Meta))
return ret("", false)
case 53:
Error("Proxy Request Refused", cview.Escape(res.Meta))
return ret("", false)
case 59:
Error("Bad Request", cview.Escape(res.Meta))
return ret("", false)
case 60: case 60:
Info("The server requested a certificate. Cert handling is coming to Amfora soon!") Error("Client Certificate Required", cview.Escape(res.Meta))
return ret("", false)
case 61:
Error("Certificate Not Authorised", cview.Escape(res.Meta))
return ret("", false)
case 62:
Error("Certificate Not Valid", cview.Escape(res.Meta))
return ret("", false) return ret("", false)
} }
// Status code 20, but not a document that can be displayed // Status code 20, but not a document that can be displayed
go dlChoice("That file could not be displayed. What would you like to do?", u, res) go dlChoice("That file could not be displayed. What would you like to do?", u, res)
return ret("", false) return ret("", false)