echo-method.py (634B)
1 # This handler is designed to verify that UAs correctly discard the body of 2 # responses to HTTP HEAD requests. If the response body is written to a 3 # separate TCP packet, then this behavior cannot be verified. This handler uses 4 # the response writer to ensure that the body is transmitted in the same packet 5 # as the headers. In this way, non-conforming UAs will consistently fail the 6 # associated test. 7 8 def main(request, response): 9 content = request.method 10 11 response.add_required_headers = False 12 response.writer.write(u'''HTTP/1.1 200 OK 13 Content-type: text/plain 14 Content-Length: {} 15 16 {}'''.format(len(content), content))