def dump_response(r, line_break=b'\r\n', encoding='UTF-8'):
    """    Return a byte-string representation of the given response, as for a HTTP
    response.
    """
    output = []
    output.append(r.status.encode('ascii'))
    output.append(line_break)
    for k, v in sorted(r.headers):
        output.append(k.encode('ascii'))
        output.append(b': ')
        output.append(v.encode('ascii'))
        output.append(line_break)
    output.append(line_break)
    output.extend(r.content_iterator)
    s = b''.join(output)
    if encoding:
        return s.decode(encoding)
    return s
