Class LengthRequiredException

All Implemented Interfaces:
Serializable

public class LengthRequiredException extends AxiomException
An endpoint's refusal of a request that does not declare its length (411). The HTTP listener never throws it: a request without Content-Length or Transfer-Encoding has an empty body (RFC 9112 section 6.3), and chunked bodies are accepted. A handler that wants only bodies with a declared length, for example an upload endpoint that refuses chunked content, checks the header and throws it:

 app.post("/upload", ctx -> {
     if (ctx.header("Content-Length").isEmpty()) { throw new LengthRequiredException(); }
     return ctx.status(201).text("stored");
 });
 
See Also:
  • Constructor Details

    • LengthRequiredException

      public LengthRequiredException()
      Creates the exception with code length_required.
    • LengthRequiredException

      public LengthRequiredException(String code)
      Creates the exception with a specific safe code.
      Parameters:
      code - machine-readable code