'Create a URL object we can use to pass to _do_request().'

def _construct_url(self, action, params=None):

    action = urlparse.quote(action)
    path = '/'.join([(self.doc_root or ''), action.lstrip('/')])
    scheme = ('https' if self.use_ssl else 'http')
    if netutils.is_valid_ipv6(self.host):
        netloc = ('[%s]:%d' % (self.host, self.port))
    else:
        netloc = ('%s:%d' % (self.host, self.port))
    if isinstance(params, dict):
        for (key, value) in list(params.items()):
            if (value is None):
                del params[key]
                continue
            if (not isinstance(value, six.string_types)):
                value = str(value)
            params[key] = encodeutils.safe_encode(value)
        query = urlparse.urlencode(params)
    else:
        query = None
    url = urlparse.ParseResult(scheme, netloc, path, '', query, '')
    log_msg = _('Constructed    URL:    %s')
    LOG.debug(log_msg, url.geturl())
    return url
