El 2013-09-08 08:43, Roberto De Ioris escribió:

El 2013-09-07 20:12, Roberto De Ioris escribió:
Hello,

I have configured uWSGI in order to proxy to an http server and,
after
that, transform the response from the http server through the XSLT
transformation plugin. It works. The relevant config is:

route= ^/
toxslt:stylesheet=/whatever/template.xslt,content_type=text/html
route= ^/ proxyhttp:127.0.0.1:8002

With this I am able to XSLT-transform every response from the
127.0.0.1:8002 server.

The problem is that I would like to do this *only* when the response
is
a Content-type=text/html (whatever the URL is, i.e. it cannot be
done by
file extension. It must be by the Content-type header of the
response)

Is there a way to apply the transformation depending on the response
from the server?

I also considered using python code to setup the "transformation
chain"
on the fly as the response reaches back to the uWSGI instance, but
it is
poorly documented, I just don't know how to do it. Any idea?

Thank you.

Pablo.



Thank you for your quick answer.

There is still no way to check response headers (honestly i still
need to
find a proper solution). Currently you can only check the HTTP
status,
using the error-route chain (it is a routing chain run after the
response
generation but before transformations)

Is it documented? I did not see it.

Anyway, that would be too expensive for this use case.

This limit is general, so even running custom code in routing handler
does
not solve the issue.

Not as the most elegant and final solution, but maybe a very simple
transformation plugin that just checks for a variable or header, and
interrupts the transformation chain if matched...

Thanks again for your help.

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


Error router work in the same way as the others, the only difference is in
"when" they run:


https://github.com/unbit/uwsgi-docs/blob/master/Changelog-1.9.11.rst#error-routes


I have just got an idea (sleeping sometime helps ;):

response-header-collect = Content-Type MY_CONTENT_TYPE
response-header-collect = Server THE_SERVER

this will place the "tracked" headers in a request var as soon as they are
received

So you can do something like:

error-route-if = equal:${MY_CONTENT_TYPE};text/html
toxslt:stylesheet=/whatever/template.xslt,content_type=text/html

implementing it would be super-easy and there will be no need to add more
features to internal routing syntax

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



Just pushed it:


https://github.com/unbit/uwsgi-docs/blob/master/InternalRouting.rst#collecting-response-headers

JFYI: It works as expected in my use case (XSLT transformation applied to [only] http-proxied text/html responses)

Thank you for your support and for this great piece of software.

Best regards,

Pablo.



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

Reply via email to