<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Project><name>wsgiheaders</name>
<shortdesc>Adding and replacing response headers</shortdesc>
<description>Adding and replacing response headers

 &gt;&gt;&gt; @replaceheader([(r'.*\.html', [('Content-type', 'text/html')])])
 ... def app(environ, start_response):
 ...     start_response('200 OK',
 ...                    [('Content-type', 'text/plain')])
 ...     return ['Hello, world!']
 &gt;&gt;&gt; import webtest
 &gt;&gt;&gt; app = webtest.TestApp(app)
 &gt;&gt;&gt; res = app.get('/a.txt')
 &gt;&gt;&gt; res.content_type
 'text/plain'
 &gt;&gt;&gt; res = app.get('/a.html')
 &gt;&gt;&gt; res.content_type
 'text/html'
 &gt;&gt;&gt; def xrds(environ):
 ...     return [('X-XRDS', environ['wsgi.url_scheme'] + '://' +  
environ['SERVER_NAME'] + '/svc.xrds')]
 ... 
 &gt;&gt;&gt; def predicate(environ):
 ...     return environ.get('HTTP_ACCEPT', '').find('application/xrds+xml') != -
1
 ... 
 &gt;&gt;&gt; @addheader([(predicate, xrds)])
 ... def app(environ, start_response):
 ...     start_response('200 OK',
 ...                    [('Content-type', 'text/plain')])
 ...     return ['Hello, world!']
 &gt;&gt;&gt; app = webtest.TestApp(app)
 &gt;&gt;&gt; res = app.get('/')
 &gt;&gt;&gt; 'X-XRDS' in res.headers
 False
 &gt;&gt;&gt; res = app.get('/', headers={'Accept':'application/xrds+xml'})
 &gt;&gt;&gt; res.headers['X-XRDS']
 'http://localhost/svc.xrds'</description>
<homepage rdf:resource="http://www.bitbucket.org/aodag/wsgiheaders/" />
<maintainer><foaf:Person><foaf:name>Atsushi Odagiri</foaf:name>
<foaf:mbox_sha1sum>672f68b789a8a7409503061a516d16fb67b22656</foaf:mbox_sha1sum></foaf:Person></maintainer>
<release><Version><revision>0.2</revision></Version></release>
</Project></rdf:RDF>