> On May 22, 2013, at 6:44 AM, Roberto De Ioris <[email protected]> wrote:
>
>> I think this is more "right" check:
>
> Thanks! That seems to have done the trick.
>
> Regarding your suggestion of using error-route-status. I couldn't find any
> info in the documentation about error routes or final routes. Why "error"?

"error routes" have been added in 1.9.11 while talking about custom error
pages (currently uWSGI simply spit out the HTTP message).

This is why the "error" prefix. The relevant issue:

https://github.com/unbit/uwsgi/issues/254


>
> Anyway, what I want is to return Keep-alive when the response status is
> 200 or 206. "close" otherwise. I've tried things like:
>
> error-route-status = ^20[0,6]$ addheader:Connection: Keep-alive
> error-route-status = ! ^20[0,6]$ addheader:Connection: close
>

error-route-status is the "fast/simple" approach not supporting regexps or
conditions. You need the "if" variant:

error-route-if = equal:${uwsgi[status]};200 goto:keepalive
error-route-if = equal:${uwsgi[status]};206 goto:keepalive
error-route-run = addheader:Connection: close
error-route-run = last:
error-route-label = keepalive
error-route-run = addheader:Connection: Keep-alive

this is voluntary "complex" to let you understand how many "magix things
you can do" :) You can rewrite it in 2 lines:

error-route-if = startswith:${uwsgi[status]};20 addheader:Connection:
Keep-alive
error-route-if-not = startswith:${uwsgi[status]};20 addheader:Connection:
close

or

error-route-if = regexp:${uwsgi[status]};^20[0,6]$ addheader:Connection:
Keep-alive
error-route-if = >=:${uwsgi[status]};300 addheader:Connection: close

If you search for the fastest approach, use this rule:

- regexp are slower -

;)

-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to