Rack::Cascade is a hack that probably should be avoided. I use 404
because then you can layer apps that were not written for use with
Cascade in mind (you can easily override the statuses).
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
The problem with using any HTTP status is that it makes it impossible
to return that status.
As long as middlewares must return a special response, how about using
Ruby programming instead (like throw/catch) instead of an HTTP
convention?
jeremy
Or take a clue form raggi's async rack stuff and return a negative
number for status that means cascade so it will never conflict with
any real http status codes.
Cheers-
-Ezra
Alternately, I could see a 417 being an appropriate type of default
catch code. I like the idea of Rack middle ware treated as interal
proxies.
--
stadik.net
> 417 is an acceptable HTTP response code to use, but if we decide
> that cascading should be done without these, I think an Exception
> should be raised. If an endpoint doesn't know how to do something
> that is expected of it, I believe that an exception is appropriate.
> An HTTP response code is just a way of communicating exceptional
> state, correct?
>
> Matt
The reason I eventually settled on -1 for async stuff is in several
parts:
- Ruby will very likely never have an unsigned numeric type.
- HTTP Status codes will very likely never become signed numerals.
- Using actual HTTP status codes, appropriate or not, stops them
from being used in a 'regular' manner from an application.
I was using HTTPs CONTINUE originally, to prevent http servers from
doing a terminate response and close connection.
The problem is, there are some situations (mostly proxy related) where
an app genuinely wants to send a 100 out. Sure, none of the OSS stuff
I've seen uses this, but someone on this ML does.
Rack::PassThru, Rack::Skip, Rack::MiddlewareSkippingFactoryFactoryFactory ?
> Why not a "throw :pass"? Do we need the backtrace an exception would
> generate (which also is quite expensive)?
>
> //Magnus Holm
When I benched this, the difference between unrolling a stack via
throw and via an exception is comparable.
IMO both are not acceptable for flow control.
class Appdef call(env)return [env['rack.cascade.code'], {}, []] unless can_service?(env)endend
Again, I'd like to put forth for consideration the idea that Rack middleware is effectively a proxy. In that context, returning a 417 makes perfect sense and isn't going to conflict with a real app (an *application* should never return a 417).
On Thu, Jan 29, 2009 at 10:17 AM, Matt Todd <chio...@gmail.com> wrote:One improvement would be to change it to env['rack.unserviceable.code'] or something which would be 404 normally but then Cascade would change this to -1 or whatever and handle it internally.
--
stadik.net