summaryrefslogtreecommitdiff
path: root/lib/httpcache/httpcache.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/httpcache/httpcache.go')
-rw-r--r--lib/httpcache/httpcache.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/httpcache/httpcache.go b/lib/httpcache/httpcache.go
index 0fb8268..aded85c 100644
--- a/lib/httpcache/httpcache.go
+++ b/lib/httpcache/httpcache.go
@@ -11,6 +11,8 @@ import (
"sort"
)
+var UserAgent string
+
type httpCacheEntry struct {
Body string
Err error
@@ -39,6 +41,9 @@ func (e *httpStatusError) Error() string {
}
func Get(u string, hdr map[string]string) (string, error) {
+ if UserAgent == "" {
+ panic("main() must set the user agent string")
+ }
cacheKey := url.QueryEscape(u)
hdrKeys := make([]string, 0, len(hdr))
for k := range hdr {
@@ -72,7 +77,7 @@ func Get(u string, hdr map[string]string) (string, error) {
httpCache[cacheKey] = httpCacheEntry{Err: err}
return "", err
}
- req.Header.Set("User-Agent", "https://git.lukeshu.com/www/tree/cmd/gen-imworkingon")
+ req.Header.Set("User-Agent", UserAgent)
for k, v := range hdr {
req.Header.Add(k, v)
}