Package com.jsgalactic.axiom.error
Class LengthRequiredException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.jsgalactic.axiom.error.AxiomException
com.jsgalactic.axiom.error.LengthRequiredException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionCreates the exception with codelength_required.Creates the exception with a specific safe code. -
Method Summary
Methods inherited from class com.jsgalactic.axiom.error.AxiomException
code, headers, status, violationsMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
LengthRequiredException
public LengthRequiredException()Creates the exception with codelength_required. -
LengthRequiredException
Creates the exception with a specific safe code.- Parameters:
code- machine-readable code
-