wsgiheaders 0.2

Adding and replacing response headers
wsgiheaders is a Python module for adding and replacing response headers.
>>> @replaceheader([(r'.*.html', [('Content-type', 'text/html')])])
... def app(environ, start_response):
... start_response('200 OK',
... [('Content-type', 'text/plain')])
... return ['Hello, world!']
>>> import webtest
>>> app = webtest.TestApp(app)
>>> res = app.get('/a.txt')
>>> res.content_type
'text/plain'
>>> res = app.get('/a.html')
>>> res.content_type
'text/html'
>>> def xrds(environ):
... return [('X-XRDS', environ['wsgi.url_scheme'] + '://' +
environ['SERVER_NAME'] + '/svc.xrds')]
...
>>> @addheader([('http://.*', xrds)])
... def app(environ, start_response):
... start_response('200 OK',
... [('Content-type', 'text/plain')])
... return ['Hello, world!']
>>> app = webtest.TestApp(app)
>>> res = app.get('/')
>>> res.headers['X-XRDS']
'http://localhost/svc.xrds'

last updated on:
January 12th, 2009, 7:51 GMT
price:
FREE!
developed by:
Atsushi Odagiri
homepage:
www.bitbucket.org
license type:
MIT/X Consortium License 
category:
ROOT \ Internet \ HTTP (WWW)

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT