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.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/httpcache/httpcache.go b/lib/httpcache/httpcache.go
index 91a37c2..b2cc7fe 100644
--- a/lib/httpcache/httpcache.go
+++ b/lib/httpcache/httpcache.go
@@ -16,7 +16,11 @@ import (
"strings"
)
-var UserAgent string
+var (
+ UserAgent string
+ ModifyResponse func(url string, entry CacheEntry, resp *http.Response) *http.Response
+ CheckRedirect func(req *http.Request, via []*http.Request) error
+)
type CacheEntry string
@@ -122,6 +126,9 @@ end:
if err != nil {
panic(fmt.Errorf("invalid cache entry: %v", err))
}
+ if ModifyResponse != nil {
+ ret_resp = ModifyResponse(u, entry, ret_resp)
+ }
case strings.HasPrefix(string(entry), "CLIENT/"):
ret_err = errors.New(string(entry)[len("CLIENT/"):])
default:
@@ -150,7 +157,8 @@ func Get(u string, hdr map[string]string) (string, error) {
req.Header.Add(k, v)
}
client := &http.Client{
- Transport: &transport{},
+ Transport: &transport{},
+ CheckRedirect: CheckRedirect,
}
resp, err := client.Do(req)
if err != nil {