Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: json decoding fails from httptest in tip, works in 1.4 and over bytes.Buffer #11893

Closed
ThomasHabets opened this issue Jul 27, 2015 · 4 comments

Comments

Projects
None yet
5 participants
@ThomasHabets
Copy link
Contributor

commented Jul 27, 2015

Code

http://play.golang.org/p/DPZUao3rPB

Should output (and does under Go 1.4)

Decoding with bytes.Buffer: <nil>, {"bar"}
Decoding with http stream: <nil>, {"bar"}
Decoding with http stream bouncing on bytes.Buffer: <nil>, {"bar"}
Yes, "{ \"foo\": \"bar\" }" really is "{ \"foo\": \"bar\" }"

With tip(129cfa2) outputs

$ go run lalatest.go
Decoding with bytes.Buffer: <nil>, {"bar"}
Decoding with http stream: EOF, {""}
Decoding with http stream bouncing on bytes.Buffer: <nil>, {"bar"}
Yes, "{ \"foo\": \"bar\" }" really is "{ \"foo\": \"bar\" }"

Expected

not EOF. Doesn't matter which io.Reader it's read from, it should either be seen as valid or it shouldn't.

@ianlancetaylor ianlancetaylor changed the title json decoding fails from httptest in tip, works in 1.4 and over bytes.Buffer net/http: json decoding fails from httptest in tip, works in 1.4 and over bytes.Buffer Jul 27, 2015

@ianlancetaylor ianlancetaylor added this to the Go1.5 milestone Jul 27, 2015

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2015

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jul 27, 2015

This is a recent regression.

Trying to find where. Rev a60c536 is bad.

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jul 27, 2015

Rev 9c55792 is good, and rev 0cf48b4 is bad. So the break came at:
0cf48b4: encoding/json: add JSON streaming parse API

/cc @rsc

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2015

Fixed by CL 12726 and by CL 12740. (The release is getting closer so we double-fix things now.)

@rsc rsc closed this Jul 28, 2015

@golang golang locked and limited conversation to collaborators Aug 5, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.