6.2 The response

The Web server replies the client by sending an HTTP response. It looks like this:

    HTTP/1.1 200 OK
    Date: Fri, 22 Jun 2007 13:03:00 GMT
    Server: Apache
    Last-Modified: Fri, 22 Jun 2007 13:02:32 GMT
    ETag: "15c188-6-46b4ea00"
    Accept-Ranges: bytes
    Content-Length: 6
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Content-Type: text/plain

    Hello

Like the request, the response is split in three sections:

To work with the HTTP responses we have a handler too:

    >>> from itools.http import Response
    >>>
    >>> response = Response('response.txt')
    >>> print response.status
    200
    >>> print response.get_content_length()
    6
    >>> print response.body
    Hello

And the programming interface: