Exemple #1
0
        def make_request(uri, headers=None, data=None, method=None):
            uri, headers, data, method = prepare_request(uri, headers, data, method)

            # test client is a `werkzeug.test.Client`
            parsed = urlparse(uri)
            uri = "%s?%s" % (parsed.path, parsed.query)
            resp = test_client.open(uri, headers=headers, data=data, method=method)
            # for compatible
            resp.code = resp.status_code
            return resp, resp.data
Exemple #2
0
        def make_request(uri, headers=None, data=None, method=None):
            uri, headers, data, method = prepare_request(uri, headers, data, method)
            if not headers and data is not None:
                headers = {"Content-Type": " application/x-www-form-urlencoded"}

            # test client is a `werkzeug.test.Client`
            parsed = urlparse(uri)
            uri = "%s?%s" % (parsed.path, parsed.query)
            resp = test_client.open(uri, headers=headers, data=data, method=method, base_url=cfg["CFG_SITE_SECURE_URL"])
            # for compatible
            resp.code = resp.status_code
            return resp, resp.data
Exemple #3
0
        def make_request(uri, headers=None, data=None, method=None):
            uri, headers, data, method = prepare_request(
                uri, headers, data, method)

            # test client is a `werkzeug.test.Client`
            parsed = urlparse(uri)
            uri = '%s?%s' % (parsed.path, parsed.query)
            resp = test_client.open(uri,
                                    headers=headers,
                                    data=data,
                                    method=method)
            # for compatible
            resp.code = resp.status_code
            return resp, resp.data
Exemple #4
0
def http_request_no_verify_host(uri, headers=None, data=None, method=None):
    uri, headers, data, method = prepare_request(uri, headers, data, method)
    req = http.Request(uri, headers=headers, data=data)
    req.get_method = lambda: method.upper()
    try:
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        resp = http.urlopen(req, context=ctx)
        content = resp.read()
        resp.close()
        return resp, content
    except http.HTTPError as resp:
        content = resp.read()
        resp.close()
        return resp, content
Exemple #5
0
    def make_request(uri, headers=None, data=None, method=None):
        uri, headers, data, method = prepare_request(
            uri, headers, data, method
        )
        if not headers and data is not None:
            headers = {
                'Content-Type': ' application/x-www-form-urlencoded'
            }

        # test client is a `werkzeug.test.Client`
        parsed = urlparse(uri)
        uri = '%s?%s' % (parsed.path, parsed.query)
        resp = test_client.open(
            uri, headers=headers, data=data, method=method,
        )
        # for compatible
        resp.code = resp.status_code
        return resp, resp.data