summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-20 23:20:40 -0400
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-21 00:06:48 -0400
commit52176f77e06f6ae68bf16dc170e664c71dd1da8c (patch)
treec1dcd71003643d2dbfdd6895c967cd9f13203818 /lib
parent49413ff54541637b1309498eccea599566b75890 (diff)
httpcache: Handle real long URLs
Diffstat (limited to 'lib')
-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.