Skip to content

Commit

Permalink
Udpated documentation and javadocs.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Dec 14, 2023
1 parent 030cc1c commit 15b0224
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@ Server
└── ContextHandler N
----

[[pg-server-http-handler-use-sizelimit]]
====== SizeLimitHandler

`SizeLimitHandler` tracks the sizes of request content and response content, and fails the request processing with an HTTP status code of link:https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-large[`413 Content Too Large`].

Server applications can set up the `SizeLimitHandler` before or after handlers that modify the request content or response content such as xref:pg-server-http-handler-use-gzip[`GzipHandler`].
When `SizeLimitHandler` is before `GzipHandler` in the `Handler` tree, it will limit the compressed content; when it is after, it will limit the uncompressed content.

The `Handler` tree structure look like the following, to limit uncompressed content:

[source,screen]
----
Server
└── GzipHandler
└── SizeLimitHandler
└── ContextHandlerCollection
├── ContextHandler 1
:── ...
└── ContextHandler N
----

[[pg-server-http-handler-use-statistics]]
====== StatisticsHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.util.Callback;

/**
* A handler that can limit the size of message bodies in requests and responses.
*
* <p>A {@link Handler} that can limit the size of message bodies in requests and responses.</p>
* <p>The optional request and response limits are imposed by checking the {@code Content-Length}
* header or observing the actual bytes seen by the handler. Handler order is important, in as much
* as if this handler is before a the {@link org.eclipse.jetty.server.handler.gzip.GzipHandler},
* then it will limit compressed sized, if it as after the {@link
* org.eclipse.jetty.server.handler.gzip.GzipHandler} then the limit is applied to uncompressed
* bytes. If a size limit is exceeded then {@link BadMessageException} is thrown with a {@link
* org.eclipse.jetty.http.HttpStatus#PAYLOAD_TOO_LARGE_413} status.
* header or observing the actual bytes seen by this Handler.</p>
* <p>Handler order is important; for example, if this handler is before the {@link GzipHandler},
* then it will limit compressed sizes, if it as after the {@link GzipHandler} then it will limit
* uncompressed sizes.</p>
* <p>If a size limit is exceeded then {@link BadMessageException} is thrown with a
* {@link HttpStatus#PAYLOAD_TOO_LARGE_413} status.</p>
*/
public class SizeLimitHandler extends Handler.Wrapper
{
Expand Down

0 comments on commit 15b0224

Please sign in to comment.