Skip to main content

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'
>>> 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'

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.1.zip (5.3 kB view details)

Uploaded Source

Built Distributions

wsgiheaders-0.1.win32.exe (71.0 kB view details)

Uploaded Source

wsgiheaders-0.1-py2.6.egg (4.9 kB view details)

Uploaded Source

File details

Details for the file wsgiheaders-0.1.zip.

File metadata

  • Download URL: wsgiheaders-0.1.zip
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wsgiheaders-0.1.zip
Algorithm Hash digest
SHA256 88da023098d6165c2c0b6624b38e477062fcf6d186f024eb4c71537ca7368d3a
MD5 0d583c5904c895069a54283200347931
BLAKE2b-256 6c756a0bf2315bb40a11950d2738f3099e11cb94a98eab107cd08a8ff9bd2730

See more details on using hashes here.

File details

Details for the file wsgiheaders-0.1.win32.exe.

File metadata

File hashes

Hashes for wsgiheaders-0.1.win32.exe
Algorithm Hash digest
SHA256 b289538255b4226f6e66ceff03a444e0c7c238378952a520bf472475e4024b5c
MD5 beba8a765f3339fc6643e955f961ee03
BLAKE2b-256 b6dfaaa0ccb7cecf1752b997abe3fad4fe23c4ed3bc14a3e92b46ef8fb27b3ef

See more details on using hashes here.

File details

Details for the file wsgiheaders-0.1-py2.6.egg.

File metadata

File hashes

Hashes for wsgiheaders-0.1-py2.6.egg
Algorithm Hash digest
SHA256 9da1c108aa425160609dc1e4a2747175b580efe10fd839578f07b3d92f708f7a
MD5 4f948c665f5a9f9c009e62ed59a77bc6
BLAKE2b-256 949fa45e3402c395dd11d7129d8d2507673b37b9c55969857dc21bcb9452bc15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page