If the entity is not a HttpEntity.Default, Akka can't provide a length without buffering the stream first. Which is why one doesn't see the length of the entity in the HttpRequest.
If there was Content-Length header but it was inaccurate, does that leave a careless implementation around it open to a DOS attack? For instance if I accept the request because the length seems acceptable but the actual data stream does not end. I'm guessing the application would just patiently wait for the toolkit to return, and the toolkit would not have been informed about the bounds. I'm not the best person to answer this, just tossing out ideas. It does seem like it would be useful to match against various HttpEntity types. I wonder if it would be possible to provide a directive like http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/scala/http/routing-dsl/directives/basic-directives/mapRouteResultPF.html#maprouteresultpf that accepted a partial function for matching pretty much anything in the request closure relatively easily? Cheers, Brian On Wednesday, June 3, 2015 at 4:43:36 AM UTC+7, Michael Hamrah wrote: > > I'd like to create a directive that matches when the request.entity is of > type HttpEntity.Default. Specifically, I'd like to know when the > Content-Length header is set. It seems that I can't use any of the > HeaderDirectives because Content-Length is not part of request.headers, but > instead a property of the http entity property, depending on the type of > entity. > > Do you have suggestions on either: > > * Filtering on Content-Length being set in a header in a route > * Calling extractRequest, but only if the request.entity is of > HttpEntity.Default > * Adding a directive matching on HttpEntity.Default. > > Thanks, > > Mike > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
