Adding and replacing response headers
Project description
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' >>> @addheader([('.*', [('X-XRDS', 'http://localhost/services.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/services.xrds'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wsgiheaders-0.0.1.zip
(5.1 kB
view hashes)
Built Distributions
wsgiheaders-0.0.1.win32.exe
(70.8 kB
view hashes)
wsgiheaders-0.0.1-py2.6.egg
(4.7 kB
view hashes)