Fix caching on JSON body read
When response is JSON and it doesn't have Content-length header and Transfer-encoding header is not chunked, reader will use bufio where we miss the EOF and it never set the refreshed cache.
This fix will check the read length besides EOF err.
/cc @gregjones @willnorris @dmitshur
We've experience the issue described in the linked issue of go-github. Is there any reason this wasn't merged in?
@dmitshur - Do you have powers to merge this? Without it, we are forced to use the forked version of the repo as you can see in the linked PR.
Can this be merged? I have been forced to use the forked version!
I'll add another voice to this, as I'm hitting the same issue.
I tried this fix but I get the following error when executing the testcases:
=== RUN TestCacheOnJsonBodyRead
httpcache_test.go:420: Get "http://127.0.0.1:49353/json": net/http: HTTP/1.x transport connection broken: unsupported transfer encoding: "identity"
--- FAIL: TestCacheOnJsonBodyRead (0.00s)
@idefixcert tests are passing for me
$ GO111MODULE=off go test
PASS
ok _/home/mansour/workspace/httpcache 3.014s
$ go version
go version go1.14.2 linux/amd64
Which version do you have? It seems you have this issue: https://github.com/golang/go/issues/40735
your right, that was the problem.