-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MaxContentLength support for Netty pt 2 #3337
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kciesielski
changed the title
MaxContentLength support (non-streaming)
[WIP] MaxContentLength support for Netty (non-streaming)
Nov 23, 2023
kciesielski
force-pushed
the
3056-non-streaming
branch
from
November 23, 2023 09:54
db19d8a
to
a192eb3
Compare
adamw
reviewed
Nov 23, 2023
adamw
reviewed
Nov 23, 2023
server/core/src/main/scala/sttp/tapir/server/interpreter/ServerInterpreter.scala
Outdated
Show resolved
Hide resolved
adamw
reviewed
Nov 24, 2023
...netty-server/cats/src/main/scala/sttp/tapir/server/netty/internal/NettyCatsRequestBody.scala
Outdated
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
server/netty-server/src/main/scala/sttp/tapir/server/netty/internal/NettyToResponseBody.scala
Outdated
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
...ver/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/FileRangePublisher.scala
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
...ver/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/FileRangePublisher.scala
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
...ver/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/FileRangePublisher.scala
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
...ver/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/FileRangePublisher.scala
Outdated
Show resolved
Hide resolved
kciesielski
commented
Nov 27, 2023
...r/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/InputStreamPublisher.scala
Outdated
Show resolved
Hide resolved
adamw
reviewed
Nov 28, 2023
...r/netty-server/src/test/scala/sttp/tapir/server/netty/NettyFutureTestServerInterpreter.scala
Outdated
Show resolved
Hide resolved
kciesielski
changed the title
[WIP] MaxContentLength support for Netty (non-streaming)
[WIP] MaxContentLength support for Netty
Dec 1, 2023
kciesielski
changed the title
[WIP] MaxContentLength support for Netty
MaxContentLength support for Netty pt 2
Dec 1, 2023
adamw
reviewed
Dec 4, 2023
adamw
reviewed
Dec 4, 2023
adamw
reviewed
Dec 4, 2023
server/core/src/main/scala/sttp/tapir/server/model/EndpointExtensions.scala
Show resolved
Hide resolved
adamw
reviewed
Dec 4, 2023
server/netty-server/src/main/scala/sttp/tapir/server/netty/internal/NettyRequestBody.scala
Show resolved
Hide resolved
adamw
reviewed
Dec 4, 2023
server/netty-server/src/main/scala/sttp/tapir/server/netty/internal/NettyRequestBody.scala
Show resolved
Hide resolved
adamw
approved these changes
Dec 4, 2023
Looks good, let's ship it :) |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially addresses #2971
This is a follow-up to PR #3319
Add raw body content length limiting for all Netty backends.
After enabling body length limit on an endpoint, both streaming and non-streaming (raw) requests will be checked. If exceeded,
HTTP 413 Payload Too Large
response is sent.Usage:
Design notes and open questions:
That
EndpointExtensions
andMaxContentLength
types exposed as public API are in thesttp.tapir.server.model
package, in thetapir-server
core module. I'm happy do discuss better alternatives.I heavily refactored all Netty backends to exrtact some repetitions into
NettyRequestBody
,NettyStreamingRequestBody
,NettyToResponseBody
,NettyToStreamsResponseBody
,Fs2StreamsCompatible
,ZioStreamsCompatible
.A critical change was to switch our base Netty pipeline to always use Reactive Streams. This allows to process incoming bytes for raw requests chunk by chunk, and potentially react if total accumulated length is too large. While cats and zio offer simple converters to/from
Subscriber
/Publisher
for their streams, in the Future and Loom backends I had to write manual integrations. They deal with concurrency using lower-level mechanisms, please review them carefully. This includes publishers and subscribers located innetty-server/src/main/scala/sttp/tapir/server/netty/internal/reactivestreams/
.