def valid_status(status):
    """Return legal HTTP status Code, Reason-phrase and Message.

    The status arg must be an int, or a str that begins with an int.

    If status is an int, or a str and no reason-phrase is supplied,
    a default reason-phrase will be provided.
    """

    if not status:
        status = 200

    status = str(status)
    parts = status.split(" ", 1)
    if len(parts) == 1:
        # No reason supplied.
        code, = parts
        reason = None
    else:
        code, reason = parts
        reason = reason.strip()

    try:
        code = int(code)
    except __HOLE__:
        raise ValueError("Illegal response status from server "
                         "(%s is non-numeric)." % repr(code))

    if code < 100 or code > 599:
        raise ValueError("Illegal response status from server "
                         "(%s is out of range)." % repr(code))

    if code not in response_codes:
        # code is unknown but not illegal
        default_reason, message = "", ""
    else:
        default_reason, message = response_codes[code]

    if reason is None:
        reason = default_reason

    return code, reason, message


# NOTE: the parse_qs functions that follow are modified version of those
# in the python3.0 source - we need to pass through an encoding to the unquote
# method, but the default parse_qs function doesn't allow us to.  These do.
dataset/ETHPy150Open clips/pattern/pattern/server/cherrypy/cherrypy/lib/httputil.py/valid_status