diff options
| author | tjp <tjp@ctrl-c.club> | 2024-01-09 09:53:15 -0700 |
|---|---|---|
| committer | tjp <tjp@ctrl-c.club> | 2024-01-09 09:53:15 -0700 |
| commit | a44a063c1a60ca11066d21d49aca95cfed7d3499 (patch) | |
| tree | 65bcb597fd77e27a2c93ca10ce06a0add80d9384 /handlers.go | |
| parent | 15214b7c98cbe77bddb2a52e0849abdfa7953747 (diff) | |
mimetype handling
upon general navigation:
1. check for any configured handlers for the mimetype
2. normal printing for gophermap, gemtext, and text/plain
3. save the file to downloads folder
Diffstat (limited to 'handlers.go')
| -rw-r--r-- | handlers.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/handlers.go b/handlers.go index d918fd0..64ea5c0 100644 --- a/handlers.go +++ b/handlers.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "mime" + "net/http" "net/url" "strings" @@ -57,6 +58,14 @@ func docType(u *url.URL, response *sliderule.Response) string { } } + if u.Scheme == "http" || u.Scheme == "https" { + resp := response.Meta.(*http.Response) + mtype, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err == nil { + return mtype + } + } + return "text/plain" } |
