'HTTP headers as a bytestring.'

def serialize_headers(self):

    def to_bytes(val, encoding):
        return (val if isinstance(val, bytes) else val.encode(encoding))
    headers = [((to_bytes(key, 'ascii') + ':    ') + to_bytes(value, 'latin-1')) for (key, value) in self._headers.values()]
    return '\r\n'.join(headers)
