1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-01 07:08:59 +00:00
Files
norman/parse/browser.go
Darren Shepherd c8cab3f4f8 More initial dev
2017-11-10 21:46:30 -07:00

19 lines
420 B
Go

package parse
import (
"net/http"
"strings"
)
func IsBrowser(req *http.Request, checkAccepts bool) bool {
accepts := strings.ToLower(req.Header.Get("Accept"))
userAgent := strings.ToLower(req.Header.Get("User-Agent"))
if accepts == "" || !checkAccepts {
accepts = "*/*"
}
// User agent has Mozilla and browser accepts */*
return strings.Contains(userAgent, "mozilla") && strings.Contains(accepts, "*/*")
}