

def openURL(url_base, data=None, method='Get', cookies=None, username=None, password=None, timeout=30, headers=None):
    '\n    Function to open URLs.\n\n    Uses requests library but with additional checks for OGC service exceptions and url formatting.\n    Also handles cookies and simple user password authentication.\n    '
    headers = (headers if (password is not None) else {
        
    })
    rkwargs = {
        
    }
    rkwargs['timeout'] = timeout
    auth = None
    if (username and password):
        auth = (username, password)
    rkwargs['auth'] = auth
    method = method.split('}')[(- 1)]
    if (method.lower() == 'post'):
        try:
            xml = etree.fromstring(data)
            headers['Content-Type'] = 'text/xml'
        except (ParseError, UnicodeEncodeError):
            pass
        rkwargs['data'] = data
    elif (method.lower() == 'get'):
        rkwargs['params'] = data
    else:
        raise ValueError(("Unknown method ('%s'), expected 'get' or 'post'" % method))
    if (cookies is not None):
        rkwargs['cookies'] = cookies
    req = requests.request(method.upper(), url_base, headers=headers, **rkwargs)
    if (req.status_code in [400, 401]):
        raise ServiceException(req.text)
    if (req.status_code in [404]):
        req.raise_for_status()
    if (('Content-Type' in req.headers) and (req.headers['Content-Type'] in ['text/xml', 'application/xml'])):
        se_tree = etree.fromstring(req.content)
        serviceException = se_tree.find('{http://www.opengis.net/ows}Exception')
        if (serviceException is None):
            serviceException = se_tree.find('ServiceException')
        if (serviceException is not None):
            raise ServiceException(str(serviceException.text).strip())
    return ResponseWrapper(req)

dataset/ETHPy150Open geopython/OWSLib/owslib/util.py openURL/VarMisuse@46/117 `headers`->`password`