Modify headers in Pylons using Middleware

Posted by Anders on Stack Overflow See other posts from Stack Overflow or by Anders
Published on 2010-05-05T09:32:43Z Indexed on 2010/05/05 10:08 UTC
Read the original article Hit count: 502

Filed under:
|
|
|

Hi all,

I'm trying to modify a header using Middleware in Pylons to make my application RESTful, basically, if the user request "application/json" via GET that is what he get back.

The question I have is, the variable headers is basically a long list. Looking something like this:

[('Content-Type', 'text/html; charset=utf-8'), ('Pragma', 'no-cache'), ('Cache-Control', 'no-cache'), ('Content-Length','20'), ('Content-Encoding', 'gzip')]

Now, I'm looking to just modify the value based on the request - but are these positions fixed? Will 'Content-Type' always be position headers[0][0]?

Best Regards,

Anders

© Stack Overflow or respective owner

Related posts about pylons

Related posts about middleware