コード例 #1
0
ファイル: test_oauth2.py プロジェクト: Erez-IL/lark
        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
コード例 #2
0
ファイル: test_provider.py プロジェクト: Theer108/invenio
        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
コード例 #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
コード例 #4
0
ファイル: b2access_client.py プロジェクト: akrause2014/eudat
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
コード例 #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