wsgiheaders 0.2

Adding and replacing response headers

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update
LICENSE TYPE:
MIT/X Consortium License 
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
Atsushi Odagiri
HOMEPAGE:
www.bitbucket.org
CATEGORY:
ROOT \ Internet \ HTTP (WWW)
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

requirements

#add response headers #replace response headers #Python library #wsgi #response #headers #Python

Add your review!

SUBMIT