Skip to content
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

Merged
merged 1 commit into from
Jul 22, 2016

Conversation

Hawstein
Copy link
Contributor

Ref #20881

@akka-ci
Copy link

akka-ci commented Jul 13, 2016

Can one of the repo owners verify this patch?

@johanandren
Copy link
Member

OK TO TEST

*
* @group basic
*/
def extractStrictEntity(timeout: FiniteDuration): Directive1[HttpEntity.Strict] = BasicDirectives._extractStrictEntity(timeout)
Copy link
Member

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.

@akka-ci akka-ci added the validating PR is currently being validated by Jenkins label Jul 14, 2016
@johanandren
Copy link
Member

Needs a Java DSL counterpart as well and should also have an entries in the respective basic-directives docs, thanks!

@ktoso
Copy link
Member

ktoso commented Jul 14, 2016

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)

@akka-ci akka-ci added the needs-attention Indicates a PR validation failure (set by CI infrastructure) label Jul 14, 2016
@akka-ci
Copy link

akka-ci commented Jul 14, 2016

Test FAILed.

@akka-ci akka-ci removed the validating PR is currently being validated by Jenkins label Jul 14, 2016
@Hawstein
Copy link
Contributor Author

@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?

@ktoso
Copy link
Member

ktoso commented Jul 14, 2016

Like I said, we can have both – but the more composable toStrictEntity one is a must, the extractStrictEntity is a nice to have. Both should be documented with a big fat warning that they effectively disable streaming

@Hawstein
Copy link
Contributor Author

Hmm, since the strict info will be lost in the RequestContext even after the toStrictEntity is applied, it seems that it makes no big differences and may confuse the users. However, I have no strong options on that. If you still consider it a must, I will work on to implement both:)

@ktoso
Copy link
Member

ktoso commented Jul 14, 2016

Hmm, since the strict info will be lost in the RequestContext even after the toStrictEntity is applied,

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.

@Hawstein
Copy link
Contributor Author

It sounds making sense. working on it now.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) labels Jul 14, 2016
@Hawstein
Copy link
Contributor Author

@ktoso @johanandren PR is updated.

@akka-ci akka-ci added needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Jul 14, 2016
@akka-ci
Copy link

akka-ci commented Jul 14, 2016

Test FAILed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jul 14, 2016
@akka-ci
Copy link

akka-ci commented Jul 14, 2016

Test PASSed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Jul 15, 2016
/**
* 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]].
Copy link
Member

@ktoso ktoso Jul 18, 2016

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.

@ktoso
Copy link
Member

ktoso commented Jul 18, 2016

Looks good, only needs to get java part of docs now.

@Hawstein
Copy link
Contributor Author

@ktoso PR is updated.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jul 18, 2016
@akka-ci
Copy link

akka-ci commented Jul 18, 2016

Test PASSed.

@Hawstein
Copy link
Contributor Author

Ping


.. warning::

The directive will read the entire request entity into memory regardless of size and effectively disable streaming.
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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)

Copy link
Contributor Author

@Hawstein Hawstein Jul 22, 2016

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

Copy link
Member

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?

@johanandren
Copy link
Member

LGTM after some minor fixes

@Hawstein
Copy link
Contributor Author

@johanandren PR is updated according to your comments.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jul 22, 2016
@akka-ci
Copy link

akka-ci commented Jul 22, 2016

Test PASSed.

@ktoso
Copy link
Member

ktoso commented Jul 22, 2016

Awesome work @Hawstein !
LGTM :-)

@ktoso ktoso merged commit 6fb2d17 into akka:master Jul 22, 2016
@Hawstein Hawstein deleted the strict-entity-directive branch July 22, 2016 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants