Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fix caching on JSON body read #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m4ns0ur
Copy link

@m4ns0ur m4ns0ur commented Apr 26, 2020

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.

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
Copy link
Author

m4ns0ur commented Apr 26, 2020

/cc @gregjones @willnorris @dmitshur

@mkilpatrick
Copy link

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

@agnivade
Copy link

agnivade commented Jul 8, 2020

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

@pkmishra
Copy link

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

@seveas
Copy link

seveas commented Nov 19, 2020

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

@idefixcert
Copy link

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)

@m4ns0ur
Copy link
Author

m4ns0ur commented Feb 3, 2021

@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: golang/go#40735

@idefixcert
Copy link

your right, that was the problem.

@alexbaeza alexbaeza mentioned this pull request Dec 21, 2021
whywaita added a commit to whywaita/myshoes that referenced this pull request Jan 17, 2022
saschagrunert added a commit to saschagrunert/release-sdk that referenced this pull request Jun 13, 2022
The httpcache transport is breaking authentication where no fix seems to
be implemented yet. I'd propose to revert the change for now to be able
to use authenticated requests in tools like
`k/release/cmd/release-notes`.

Refers to: google/go-github#1503,
gregjones/httpcache#104

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Repository owner deleted a comment from yuriy-yarosh Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants