Skip to content

jsonrpc: Separate error handling for MaxBytesError#2605

Merged
jrick merged 3 commits intodecred:masterfrom
jholdstock:rpcerrs
Jan 28, 2026
Merged

jsonrpc: Separate error handling for MaxBytesError#2605
jrick merged 3 commits intodecred:masterfrom
jholdstock:rpcerrs

Conversation

@jholdstock
Copy link
Member

POST request handler would previously write 413 Request Too Large regardless of error type, now it only does so when appropriate.

Also a couple of other minor improvements/fixes.


body := http.MaxBytesReader(w, r.Body, maxRequestSize)
rpcRequest, err := io.ReadAll(body)
body.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary. All the documentation for http.Request, both its Close field and the Body describe the server as always closing the request body automatically with no need to do this in the ServeHTTP handler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@jrick jrick merged commit e138188 into decred:master Jan 28, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants