celluloid / reel

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid::IO-powered web server
https://celluloid.io
MIT License
596 stars 87 forks source link

Maybe implement RequestBody#empty? #109

Closed adstage-david closed 9 years ago

adstage-david commented 10 years ago

Just upgraded to Webmachine 1.2.1+Reel 0.4.0 and found that request.body was now returning Reel RequestBody objects no matter what. This breaks the way request.has_body? works in webmachine, since RequestBody doesn't respond to #empty?:

https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/request.rb#L39

Easy enough to work around in my code, but maybe a function should be added so that #has_body? can return the right value in webmachine?

digitalextremist commented 10 years ago

Might be slightly messy way to do it, but maybe .to_s.empty? can be the .empty? contents?

tarcieri commented 10 years ago

It depends on where #empty? occurs in the request lifecycle. It would be bad if it triggered an eager early read of a large request body

digitalextremist commented 10 years ago

@tarcieri, would it be cool to begin reading the input stream asynchronously after the first read, and respond false for #empty? once one read succeeds?

Seems a bit extreme to defer reading just for #empty? but I think it would have benefits outside that.

tarcieri commented 10 years ago

@digitalextremist that should be possible

digitalextremist commented 9 years ago

Released in 0.6.0.pre1