def redirect(url: str, perm: bool = True) -> bytes:
    """Send a 3x (redirect) response.

    :param url: The URL to redirect to.
    :param perm: Whether this is a permanent redirect.
    :return: Bytes to be sent to the client.

    """
    code = 31 if perm else 30
    return f'{code} {url}\r\n'.encode()