httpcache icon indicating copy to clipboard operation
httpcache copied to clipboard

Fix caching on JSON body read

Open m4ns0ur opened this issue 5 years ago • 8 comments

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.

m4ns0ur avatar Apr 26 '20 19:04 m4ns0ur

/cc @gregjones @willnorris @dmitshur

m4ns0ur avatar Apr 26 '20 21:04 m4ns0ur

We've experience the issue described in the linked issue of go-github. Is there any reason this wasn't merged in?

mkilpatrick avatar Jun 17 '20 21:06 mkilpatrick

@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.

agnivade avatar Jul 08 '20 05:07 agnivade

Can this be merged? I have been forced to use the forked version!

pkmishra avatar Aug 27 '20 21:08 pkmishra

I'll add another voice to this, as I'm hitting the same issue.

seveas avatar Nov 19 '20 11:11 seveas

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 avatar Feb 03 '21 14:02 idefixcert

@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

m4ns0ur avatar Feb 03 '21 18:02 m4ns0ur

your right, that was the problem.

idefixcert avatar Feb 15 '21 07:02 idefixcert