1422
by Canonical.com Patch Queue Manager
Respond to HEAD requests properly (i.e. without content) when errors (e.g. 404s and 500s) occur. |
1 |
HEAD requests should never have a body in their response, even if there are |
2 |
errors (such as 404s). |
|
3 |
||
4 |
>>> response = http(r""" |
|
5 |
... HEAD / HTTP/1.1 |
|
1435
by Canonical.com Patch Queue Manager
Repair fallout from enforcing all-templates-must-fill-title-slot rule |
6 |
... """) |
7 |
>>> print str(response).split('\n')[0] |
|
8 |
HTTP/1.1 200 Ok |
|
9 |
>>> print response.getHeader('Content-Length') |
|
10 |
0 |
|
11 |
>>> print response.getBody() |
|
12 |
<BLANKLINE> |
|
13 |
||
14 |
>>> response = http(r""" |
|
15 |
... HEAD /badurl HTTP/1.1 |
|
1422
by Canonical.com Patch Queue Manager
Respond to HEAD requests properly (i.e. without content) when errors (e.g. 404s and 500s) occur. |
16 |
... """) |
17 |
>>> print str(response).split('\n')[0] |
|
18 |
HTTP/1.1 404 Not Found |
|
19 |
>>> print response.getHeader('Content-Length') |
|
20 |
0 |
|
21 |
>>> print response.getBody() |
|
22 |
<BLANKLINE> |
|
23 |
||
24 |
Register a test page that generates HTTP 500 errors. |
|
25 |
||
26 |
>>> from zope.app.testing import ztapi |
|
6061.8.2
by Maris Fogels
Fixed all defunct references to zope.app.tests. |
27 |
>>> class ErrorView(object): |
1422
by Canonical.com Patch Queue Manager
Respond to HEAD requests properly (i.e. without content) when errors (e.g. 404s and 500s) occur. |
28 |
... """A broken view""" |
1435
by Canonical.com Patch Queue Manager
Repair fallout from enforcing all-templates-must-fill-title-slot rule |
29 |
... def __init__(self, *args): |
30 |
... oops |
|
31 |
... |
|
32 |
>>> ztapi.browserView(None, "error-test", ErrorView) |
|
1422
by Canonical.com Patch Queue Manager
Respond to HEAD requests properly (i.e. without content) when errors (e.g. 404s and 500s) occur. |
33 |
|
34 |
Do a HEAD request on the error test page, and check that its response also has |
|
35 |
no body. |
|
36 |
||
37 |
>>> response = http(r""" |
|
38 |
... HEAD /error-test HTTP/1.1 |
|
39 |
... """) |
|
40 |
>>> print str(response).split('\n')[0] |
|
41 |
HTTP/1.1 500 Internal Server Error |
|
42 |
>>> print response.getHeader('Content-Length') |
|
43 |
0 |
|
44 |
>>> print response.getBody() |
|
45 |
<BLANKLINE> |
|
46 |
||
47 |
||
1435
by Canonical.com Patch Queue Manager
Repair fallout from enforcing all-templates-must-fill-title-slot rule |
48 |