ref: fa1ae165d7d8ff9211035b9eb5fce3268e97be47
parent: ae34f0dfa3ccf127d7eed4fcf0191e5e44d538de
author: Philip Silva <[email protected]>
date: Tue Dec 29 18:33:46 EST 2020
Error handling, handle empty mime types
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -1267,7 +1267,9 @@
buf, contentType, err := b.get(url, true)
if err != nil {
log.Errorf("error loading %v: %v", addr, err)
- err = errors.Unwrap(err)
+ if er := errors.Unwrap(err); er != nil {
+ err = er
+ }
if strings.Contains(err.Error(), "HTTP response to HTTPS client") {
b.LocationField.Text = strings.Replace(url.String(), "https://", "http://", 1)
return b.LoadUrl()
@@ -1275,7 +1277,7 @@
b.showBodyMessage(err.Error())
return
}
- if contentType.IsHTML() || contentType.IsPlain() {
+ if contentType.IsHTML() || contentType.IsPlain() || contentType.IsEmpty() {
b.render(buf)
} else {
done := make(chan int)
--- a/opossum.go
+++ b/opossum.go
@@ -40,10 +40,16 @@
return NewContentType("image/png", u)
case "gif":
return NewContentType("image/gif", u)
+ default:
+ return ContentType{}, nil
}
}
c.MediaType, c.Params, err = mime.ParseMediaType(s)
return
+}
+
+func (c ContentType) IsEmpty() bool {
+ return c.MediaType == ""
}
func (c ContentType) IsHTML() bool {