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

large http payload issue #1330

Open
umutbasal opened this issue Jun 15, 2023 · 0 comments
Open

large http payload issue #1330

umutbasal opened this issue Jun 15, 2023 · 0 comments

Comments

@umutbasal
Copy link

umutbasal commented Jun 15, 2023

While trying the project, I made an http request with a large payload with post and got an error like
{"error":{"code":400,"message":"error reading body params '*': proto: syntax error (line 2:12): invalid character '\\x00' in string","details":null,"Body":"","Header":null,"Errors":null}}%

this line needs all bytes to unmarshall

source.P(" if err := resttools.FromJSON().Unmarshal(rBytes, %s); err != nil {", handler.RequestVariable)

after some debugging and reproducing bug on simple go server i've found out this, giving r.body directly to teereader wont be able to read all data.

source.P(" bodyReader := io.TeeReader(r.Body, &jsonReader)")

image image image

red dots are null bytes \x00

TeeReader returns a Reader that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.

https://cs.opensource.google/go/go/+/go1.20.5:src/io/io.go;l=603

@umutbasal umutbasal changed the title large http payload issue due to teereader usage large http payload issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant