Пример #1
0
def parse_url(url, scheme="http", path="/"):
    _scheme, netloc, _path, params, query, fragment = tupleify_urlparse(urlparse.urlparse(url))
    if not netloc:
        # No scheme - trying to patch it up ourselves?
        url = scheme + "://" + url
        _scheme, netloc, _path, params, query, fragment = tupleify_urlparse(urlparse.urlparse(url))

    if not netloc:
        # XXX
        raise Exception()

    (host, port) = urllib.splitport(netloc)

    if not _path:
        _path = path

    return (_scheme, (host, port), _path, params, query, fragment)
Пример #2
0
def parse_url(url, scheme="http", path='/'):
    _scheme, netloc, _path, params, query, fragment = tupleify_urlparse(
        urlparse.urlparse(url))
    if not netloc:
        # No scheme - trying to patch it up ourselves?
        url = scheme + "://" + url
        _scheme, netloc, _path, params, query, fragment = tupleify_urlparse(
            urlparse.urlparse(url))

    if not netloc:
        # XXX
        raise Exception()

    (host, port) = urllib.splitport(netloc)

    if not _path:
        _path = path

    return (_scheme, (host, port), _path, params, query, fragment)
Пример #3
0
    def setURL(self):
        server = idn_ascii_to_pune(self.options.server)
        if server is None:
            self.die(1, "Required parameter --server not supplied")
        scheme, netloc, path, params, query, fragment = tupleify_urlparse(
                urlparse.urlparse(server))
        if not netloc:
            # No schema - trying to patch it up ourselves?
            server = "http://" + server
            scheme, netloc, path, params, query, fragment = tupleify_urlparse(
                    urlparse.urlparse(server))

        if not netloc:
            self.die(2, "Invalid URL %s" % server)
        if path == '':
            path = '/APP'
        if scheme.lower() not in ('http', 'https'):
            self.die(3, "Unknown URL scheme %s" % scheme)
        self.url = urlparse.urlunparse((scheme, netloc, path, params, query,
            fragment))
        self.url_v2 = urlparse.urlunparse((scheme, netloc, "/PACKAGE-PUSH",
            params, query, fragment))