-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
add toStrictEntity and extractStrictEntity directive #20953
Conversation
Can one of the repo owners verify this patch? |
OK TO TEST |
* | ||
* @group basic | ||
*/ | ||
def extractStrictEntity(timeout: FiniteDuration): Directive1[HttpEntity.Strict] = BasicDirectives._extractStrictEntity(timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a warning that this will read the entire request entity into memory regardless of size and also a doc entry about the timeout parameter.
Needs a Java DSL counterpart as well and should also have an entries in the respective basic-directives docs, thanks! |
I'd prefer this directive to trigger toStrict however not extract it - we have directives that extract the entity, please see my comment here: #20881 (comment) |
Test FAILed. |
@ktoso Your proposal make sense and I have tried to implement what you prefer, however, just like @Joe-Edwards have replied you in #20881(comment) , it will lost the strict info and I have to do some other stuffs to get the strict entity. Do you have some good idea to deal with that? |
Like I said, we can have both – but the more composable |
Hmm, since the strict info will be lost in the |
No it will not be "lost", only the type will, which is the smallest difference the toStrict call makes. It changes semantics and behaviour of the server / routes. One might not want to access the entity at all, just change the semantics. |
It sounds making sense. working on it now. |
a415001
to
609dc56
Compare
@ktoso @johanandren PR is updated. |
Test FAILed. |
609dc56
to
80fea5b
Compare
Test PASSed. |
/** | ||
* WARNING: This will read the entire request entity into memory regardless of size and effectively disable streaming. | ||
* | ||
* Extracts the [[akka.http.javadsl.model.HttpEntity.Strict]] from the [[akka.http.javadsl.server.RequestContext]]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit more precise maybe:
Converts the HttpEntity from the [[akka.http.javadsl.server.RequestContext]] into an
[[akka.http.javadsl.model.HttpEntity.Strict]], or fails the route if unable to drain the
entire request body within the timeout.
Looks good, only needs to get java part of docs now. |
80fea5b
to
aff60e8
Compare
@ktoso PR is updated. |
Test PASSed. |
Ping |
|
||
.. warning:: | ||
|
||
The directive will read the entire request entity into memory regardless of size and effectively disable streaming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not regardless of size, there is the default size limit of 8M that may be overriden by wrapping with the size limit directives, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, limiting the size should be another directive's responsibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the http server puts a stage in the entity stream that will limit it by default. Unless you explicitly opt out of it with the withoutSizeLimit
directive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm pretty sure this is doc statement not true (and the other places where it is stated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I misunderstood your first comment. so how about changing the doc to:
The directive will read the request entity into memory within the size limit(8M by default) and effectively disable streaming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, maybe mention it can be configured globally with akka.http.parsing.max-content-length
and add links to the withSizeLimit
and withoutSizeLimit
directives for route local overriding also?
LGTM after some minor fixes |
aff60e8
to
a96ee64
Compare
@johanandren PR is updated according to your comments. |
Test PASSed. |
Awesome work @Hawstein ! |
Ref #20881