-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
golang ethclient recieve gzip response #26337
Comments
code:
error: get BlockByNumber err {"error": "invalid character 'H' looking for beginning of value"} this was i recieved : H4sIAAAAAAAA/6pWyirOzysqSFayUjLSM1DSUcpMUbIy1FEqSi0uzSlRslIyqEgzM7W0MFWq5QIEAAD//zIR804tAAAA |
I can reproduce this if I explicitly set cl, err := rpc.DialContext(ctx, path)
if err != nil {
fmt.Errorf("err: %v\n", err)
return
}
cl.SetHeader("Accept-Encoding", "gzip")
ecl := ethclient.NewClient(cl)
num, err := ecl.BlockNumber(context.Background()) Interestingly if I don't set the header, the request and response will look exactly the same over the wire, but somehow there is no error. The gzip write was modified in #25457 but this issue doesn't seem to stem from there. It seems to have existed before. |
BTW to configure the headers you can use my example from above and change this line: cl.SetHeader("Accept-Encoding", "identity") |
Thanks for your help, that's useful! |
I read somewhere that if we manually set I still don't understand the cause of error for you. Can you explain how is the RPC server setup? geth doesn't support HTTPS API so it seems you have a custom setup. Edit: you're probably using an external service, right? |
I use geth's ethclient but it doesn't set any headers. But by capturing the network packets, I found that it automatically adds the header |
I'm not convinced it has anything to do with @s1na when you reproed the problem, did your data also look like base64 data? |
@holiman this is the error I get |
However, the original reporter @0127abcd is not having gzip problems, but rather problems with base64. (Which, incidentally, is how golang by default would encode a |
That makes sense, and yes, it fully explains the behaviour @s1na is seeing. With that, I think we can close this, because the original error does not seem to be an error in the go-ethereum codebase. |
I used ethclient(https) to call BlockNumber and more interface, but i found the Accept-Encoding header of https request always was gzip, it cause a error, how should i config it?
The text was updated successfully, but these errors were encountered: