eclipse-vertx/vert.x · error

413 Request Entity Too Large

Error message

413 Request Entity Too Large

What it means

SC_REQUEST_ENTITY_TOO_LARGE is the HttpResponseExpectation constant for HTTP 413 Content Too Large (historically 'Request Entity Too Large'). Vert.x provides it for response validation; when the server rejects an oversized request body, applying this expectation surfaces '413 Request Entity Too Large'. The request payload exceeds the size limit the server (or an intermediary) enforces.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/http/HttpResponseExpectation.java:215

  /**
   * 410 Gone
   */
  HttpResponseExpectation SC_GONE = status(410);

  /**
   * 411 Length Required
   */
  HttpResponseExpectation SC_LENGTH_REQUIRED = status(411);

  /**
   * 412 Precondition Failed
   */
  HttpResponseExpectation SC_PRECONDITION_FAILED = status(412);

  /**
   * 413 Request Entity Too Large
   */
  HttpResponseExpectation SC_REQUEST_ENTITY_TOO_LARGE = status(413);

  /**
   * 414 Request-URI Too Long
   */
  HttpResponseExpectation SC_REQUEST_URI_TOO_LONG = status(414);

  /**
   * 415 Unsupported Media Type
   */
  HttpResponseExpectation SC_UNSUPPORTED_MEDIA_TYPE = status(415);

  /**
   * 416 Requested Range Not Satisfiable
   */
  HttpResponseExpectation SC_REQUESTED_RANGE_NOT_SATISFIABLE = status(416);

  /**
   * 417 Expectation Failed

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Split or chunk the payload into smaller requests within the server's limit
  2. Increase the limit on the server/ingress (e.g. nginx client_max_body_size, proxy maxBodySize) if the size is legitimate
  3. Compress the body (gzip) and send with Content-Encoding if the API supports it
  4. Switch to a resumable/multipart upload API for large files
  5. Check response headers/error body for the exact limit the server reports

Example fix

// before
webClient.post(url).sendBuffer(hugeBuffer); // 413
// after
for (Buffer chunk : split(hugeBuffer, MAX_CHUNK)) {
  webClient.post(url + "/chunk").sendBuffer(chunk);
}
Defensive patterns

Strategy: validation

Validate before calling

// Guard client-side before upload
if (buffer.length() > MAX_UPLOAD_BYTES) {
  throw new IllegalArgumentException("payload " + buffer.length() + " exceeds " + MAX_UPLOAD_BYTES);
}

Type guard

boolean isPayloadTooLarge(Throwable t) {
  return t instanceof VertxHttpResponseException
    && ((VertxHttpResponseException) t).getResponse().statusCode() == 413;
}

Try / catch

if (isPayloadTooLarge(t)) { splitAndUploadInChunks(); } else { throw t; }

Prevention

When it happens

Trigger: Uploading a file or sending a large JSON body via Vert.x WebClient/HttpClient to a server whose max body size (e.g. nginx client_max_body_size, Vert.x BodyLimit, Spring/Tomcat max-http-post-size) is smaller than the payload.

Common situations: File-upload endpoints behind nginx/ingress with default 1MB limits, large batch API calls exceeding provider limits, misconfigured maxBodySize on a Vert.x reverse proxy, test fixtures with large payloads hitting prod limits.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/f45ee4b8ccb3bdae. Report an issue: GitHub.