summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/httpcache/httpcache.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/httpcache/httpcache.go b/lib/httpcache/httpcache.go
index 38cffcb..91a37c2 100644
--- a/lib/httpcache/httpcache.go
+++ b/lib/httpcache/httpcache.go
@@ -2,6 +2,8 @@ package httpcache
import (
"bufio"
+ hash "crypto/md5"
+ "encoding/hex"
"encoding/json"
"errors"
"fmt"
@@ -68,6 +70,12 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
for _, k := range hdrKeys {
cacheKey += "|" + url.QueryEscape(k) + ":" + url.QueryEscape(req.Header[k][0])
}
+ if len(cacheKey) >= 255 {
+ prefix := cacheKey[:255-(hash.Size*2)]
+ csum := hash.Sum([]byte(cacheKey))
+ suffix := hex.EncodeToString(csum[:])
+ cacheKey = prefix + suffix
+ }
cacheFile := filepath.Join(".http-cache", cacheKey)
// Check the mem cache.