예제 #1
0
파일: tools.py 프로젝트: japaks/pulsar
 def test_quote_unreserved(self):
     '''Test a string of unreserved characters'''
     s = 'a~b_(c-d).'
     qs = urlquote(s)
     self.assertTrue('%' in qs)
     uqs = unquote_unreserved(qs)
     self.assertEqual(uqs, s)
     self.assertEqual(requote_uri(s), s)
     self.assertEqual(requote_uri(qs), s)
예제 #2
0
 def test_quote_unreserved(self):
     '''Test a string of unreserved characters'''
     s = 'a~b_(c-d).'
     qs = urlquote(s)
     self.assertTrue('%' in qs)
     uqs = unquote_unreserved(qs)
     self.assertEqual(uqs, s)
     self.assertEqual(requote_uri(s), s)
     self.assertEqual(requote_uri(qs), s)
예제 #3
0
파일: tools.py 프로젝트: huobao36/pulsar
 def test_quote_unreserved(self):
     """Test a string of unreserved characters"""
     s = "a~b_(c-d)."
     qs = urlquote(s)
     self.assertTrue("%" in qs)
     uqs = unquote_unreserved(qs)
     self.assertEqual(uqs, s)
     self.assertEqual(requote_uri(s), s)
     self.assertEqual(requote_uri(qs), s)
예제 #4
0
파일: plugins.py 프로젝트: LJS109/pulsar
def _do_redirect(response, exc=None):
    request = response.request
    # done with current response
    url = response.headers.get('location')
    # Handle redirection without scheme (see: RFC 1808 Section 4)
    if url.startswith('//'):
        parsed_rurl = urlparse(request.full_url)
        url = '%s:%s' % (parsed_rurl.scheme, url)
    # Facilitate non-RFC2616-compliant 'location' headers
    # (e.g. '/path/to/resource' instead of
    # 'http://domain.tld/path/to/resource')
    if not urlparse(url).netloc:
        url = urljoin(
            request.full_url,
            # Compliant with RFC3986, we percent
            # encode the url.
            requote_uri(url))
    history = request.history
    if history and len(history) >= request.max_redirects:
        response.request_again = TooManyRedirects(response)
    else:
        params = request.inp_params.copy()
        params['history'] = copy(history) if history else []
        params['history'].append(response)
        if response.status_code == 303:
            method = 'GET'
            params.pop('data', None)
            params.pop('files', None)
        else:
            method = request.method
        response.request_again = request_again(method, url, params)
예제 #5
0
파일: plugins.py 프로젝트: arhik/pulsar
    def _do_redirect(self, response):
        request = response.request
        # done with current response
        url = response.headers.get('location')
        # Handle redirection without scheme (see: RFC 1808 Section 4)
        if url.startswith('//'):
            parsed_rurl = urlparse(request.full_url)
            url = '%s:%s' % (parsed_rurl.scheme, url)
        # Facilitate non-RFC2616-compliant 'location' headers
        # (e.g. '/path/to/resource' instead of
        # 'http://domain.tld/path/to/resource')
        if not urlparse(url).netloc:
            url = urljoin(request.full_url,
                          # Compliant with RFC3986, we percent
                          # encode the url.
                          requote_uri(url))
        history = request.history
        if history and len(history) >= request.max_redirects:
            raise TooManyRedirects(response)

        params = request.inp_params.copy()
        params['history'] = copy(history) if history else []
        params['history'].append(response)
        if response.status_code == 303:
            method = 'GET'
            params.pop('data', None)
            params.pop('files', None)
        else:
            method = request.method
        response.request_again = request_again(method, url, params)
        return response
예제 #6
0
def _do_redirect(response, exc=None):
    request = response.request
    # done with current response
    url = response.headers.get("location")
    # Handle redirection without scheme (see: RFC 1808 Section 4)
    if url.startswith("//"):
        parsed_rurl = urlparse(request.full_url)
        url = "%s:%s" % (parsed_rurl.scheme, url)
    # Facilitate non-RFC2616-compliant 'location' headers
    # (e.g. '/path/to/resource' instead of
    # 'http://domain.tld/path/to/resource')
    if not urlparse(url).netloc:
        url = urljoin(
            request.full_url,
            # Compliant with RFC3986, we percent
            # encode the url.
            requote_uri(url),
        )
    history = request.history
    if history and len(history) >= request.max_redirects:
        response.request_again = TooManyRedirects(response)
    else:
        params = request.inp_params.copy()
        params["history"] = copy(history) if history else []
        params["history"].append(response)
        if response.status_code == 303:
            method = "GET"
            params.pop("data", None)
            params.pop("files", None)
        else:
            method = request.method
        response.request_again = request_again(method, url, params)
예제 #7
0
def full_url(url, params, method=None):
    p = urlparse(url)
    if not p.netloc and method == 'CONNECT':
        p = urlparse('http://%s' % url)

    params = mapping_iterator(params)
    query = parse_qsl(p.query, True)
    query.extend(split_url_params(params))
    query = urlencode(query)
    return requote_uri(
        urlunparse((p.scheme, p.netloc, p.path, p.params, query, p.fragment)))
예제 #8
0
파일: client.py 프로젝트: quantmind/pulsar
def full_url(url, params, method=None):
    p = urlparse(url)
    if not p.netloc and method == 'CONNECT':
        p = urlparse('http://%s' % url)

    params = mapping_iterator(params)
    query = parse_qsl(p.query, True)
    query.extend(split_url_params(params))
    query = urlencode(query)
    return requote_uri(
        urlunparse((p.scheme, p.netloc, p.path, p.params, query, p.fragment))
    )
예제 #9
0
 def _quote_unreserved(self, s, qs):
     '''Test a string of unreserved characters'''
     uqs = unquote_unreserved(qs)
     self.assertEqual(uqs, s)
     self.assertEqual(requote_uri(s), s)
     self.assertEqual(requote_uri(qs), s)