Try parsing HTML even if content-type is empty.

This commit is contained in:
Musab Gültekin
2019-06-18 13:00:16 +03:00
parent 4177f10de9
commit f384fc2c13
4 changed files with 11 additions and 26 deletions

View File

@@ -4,7 +4,6 @@ import (
"github.com/PuerkitoBio/goquery"
"net/http"
"net/url"
"strings"
)
// Response type wraps http.Response
@@ -27,16 +26,3 @@ func (r *Response) JoinURL(relativeURL string) string {
joinedURL := r.Response.Request.URL.ResolveReference(parsedRelativeURL)
return joinedURL.String()
}
func (r *Response) isHTML() bool {
if r.Response == nil {
return len(r.Body) != 0
}
contentType := r.Header.Get("Content-Type")
for _, htmlContentType := range []string{"text/html", "application/xhtml+xml", "application/vnd.wap.xhtml+xml"} {
if strings.Contains(contentType, htmlContentType) {
return true
}
}
return false
}