Returns a routing header string for the given request parameters.

    Args:
        params (Mapping[str, Any]): A dictionary containing the request
            parameters used for routing.

    Returns:
        str: The routing header string.

def to_routing_header(params):
    """Returns a routing header string for the given request parameters.

    Args:
        params (Mapping[str, Any]): A dictionary containing the request
            parameters used for routing.

    Returns:
        str: The routing header string.
    """
    if sys.version_info[0] < 3:
        # Python 2 does not have the "safe" parameter for urlencode.
        return urlencode(params).replace("%2F", "/")
    return urlencode(
        params,
        # Per Google API policy (go/api-url-encoding), / is not encoded.
        safe="/",
    )