~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
HEAD requests should never have a body in their response, even if there are
errors (such as 404s).

  >>> response = http(r"""
  ... HEAD / HTTP/1.1
  ... """)
  >>> print str(response).split('\n')[0]
  HTTP/1.1 200 Ok
  >>> print response.getHeader('Content-Length')
  0
  >>> print response.getBody()
  <BLANKLINE>

  >>> response = http(r"""
  ... HEAD /badurl HTTP/1.1
  ... """)
  >>> print str(response).split('\n')[0]
  HTTP/1.1 404 Not Found
  >>> print response.getHeader('Content-Length')
  0
  >>> print response.getBody()
  <BLANKLINE>

Register a test page that generates HTTP 500 errors.

  >>> from zope.app.testing import ztapi
  >>> class ErrorView(object):
  ...     """A broken view"""
  ...     def __init__(self, *args):
  ...         oops
  ...
  >>> ztapi.browserView(None, "error-test", ErrorView)

Do a HEAD request on the error test page, and check that its response also has
no body.

  >>> response = http(r"""
  ... HEAD /error-test HTTP/1.1
  ... """)
  >>> print str(response).split('\n')[0]
  HTTP/1.1 500 Internal Server Error
  >>> print response.getHeader('Content-Length')
  0
  >>> print response.getBody()
  <BLANKLINE>