Skip to content

Core: Expose max HTTP body size control (#218) - #224

Open
Aditya-9-6 wants to merge 1 commit into
prebid:masterfrom
Aditya-9-6:expose-max-http-body-size
Open

Aditya-9-6 wants to merge 1 commit into
prebid:masterfrom
Aditya-9-6:expose-max-http-body-size

Conversation

@Aditya-9-6

Copy link
Copy Markdown

Resolves #218 by porting PBC-Java PR prebid/prebid-cache-java#192.

Description

In high-throughput environments and large VAST store requests, operators need control over incoming HTTP body sizes to prevent unbounded memory consumption while also having the flexibility to allow legitimate larger payloads (>256KB/512KB).

This PR:

  1. Adds request_limits.max_body_size_bytes configuration option in bytes (following request_limits.max_header_size_bytes convention introduced in Config max request header size #174).
  2. Defaults to 262,144 bytes (256 KB), matching PBC-Java.
  3. Provides backwards-compatible parsing for server.max-http-body-size-kb (PBC-Java syntax), automatically converting KB to bytes.
  4. Enforces the limit in PUT requests using http.MaxBytesReader.
  5. When a request exceeds the limit, returns HTTP 413 Payload Too Large (http.StatusRequestEntityTooLarge) with error message "Request body exceeded maximum size." and records bad request metrics. Setting the limit to 0 disables body size limiting.
  6. Adds unit tests covering configuration validation, PBC-Java property mapping, and handler responses for within-limit, exceeded-limit, and unlimited cases.

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.

Port PR from PBC-Java: Core: Expose max HTTP body size control

1 participant