smsframework/providers/forward/provider.py
def _parse_authentication(url):
    """ Parse authentication data from the URL and put it in the `headers` dict. With caching behavior
    :param url: URL
    :type url: str
    :return: (URL without authentication info, headers dict)
    :rtype: str, dict
    """
    u = url
    h = {}  # New headers

    # Cache?
    if url in _parse_authentication._memoize:
        u, h = _parse_authentication._memoize[url]
    else:
        # Parse
        p = urlsplit(url, 'http')
        if p.username and p.password:
            # Prepare header
            h['Authorization'] = b'Basic ' + base64.b64encode(p.username.encode() + b':' + p.password.encode())
            # Remove authentication info since urllib2.Request() does not understand it
            u = urlunsplit((p.scheme, p.netloc.split('@', 1)[1], p.path, p.query, p.fragment))
        # Cache
        _parse_authentication._memoize[url] = (u, h)

    # Finish
    return u, h
def _parse_authentication(url):
    """ Parse authentication data from the URL and put it in the `headers` dict. With caching behavior
    :param url: URL
    :type url: str
    :return: (URL without authentication info, headers dict)
    :rtype: str, dict
    """
    u = url
    h = {}  # New headers

    # Cache?
    if url in _parse_authentication._memoize:
        u, h = _parse_authentication._memoize[url]
    else:
        # Parse
        p = urlsplit(url, 'http')
        if p.username and p.password:
            # Prepare header
            h['Authorization'] = b'Basic ' + base64.b64encode(p.username.encode() + b':' + p.password.encode())
            # Remove authentication info since urllib2.Request() does not understand it
            u = urlunsplit((p.scheme, p.netloc.split('@', 1)[1], p.path, p.query, p.fragment))
        # Cache
        _parse_authentication._memoize[url] = (u, h)

    # Finish
    return u, h
Parse authentication data from the URL and put it in the `headers` dict. With caching behavior
    :param url: URL
    :type url: str
    :return: (URL without authentication info, headers dict)
    :rtype: str, dict