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

soroban-rpc: lower max http request size #948

Merged
merged 6 commits into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmd/soroban-rpc/internal/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import (
"github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/transactions"
)

// maxHTTPRequestSize defines the largest request size that the http handler
// would be willing to accept before dropping the request. The implementation
// uses the default MaxBytesHandler to limit the request size.
const maxHTTPRequestSize = 512 * 1024 // half a megabyte

// Handler is the HTTP handler which serves the Soroban JSON RPC responses
type Handler struct {
bridge jhttp.Bridge
Expand Down Expand Up @@ -275,8 +280,7 @@ func NewJSONRPCHandler(cfg *config.Config, params HandlerParams) Handler {
globalQueueRequestExecutionDurationLimitCounter,
params.Logger)

// Limit request sizes to 10MB
handler = http.MaxBytesHandler(handler, 1024*1024*10)
handler = http.MaxBytesHandler(handler, maxHTTPRequestSize)

corsMiddleware := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
Expand Down
Loading