Python aiohttp.DummyCookieJar() Examples

The following are 4 code examples of aiohttp.DummyCookieJar(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module aiohttp , or try the search function .
Example #1
Source File: test_aiohttp.py    From gql with MIT License 5 votes vote down vote up
def test_aiohttp_extra_args(event_loop, aiohttp_server):
    async def handler(request):
        return web.Response(text=query1_server_answer, content_type="application/json")

    app = web.Application()
    app.router.add_route("POST", "/", handler)
    server = await aiohttp_server(app)

    url = server.make_url("/")

    # passing extra arguments to aiohttp.ClientSession
    jar = DummyCookieJar()
    sample_transport = AIOHTTPTransport(
        url=url, timeout=10, client_session_args={"version": "1.1", "cookie_jar": jar}
    )

    async with Client(transport=sample_transport,) as session:

        query = gql(query1_str)

        # Passing extra arguments to the post method of aiohttp
        result = await session.execute(query, extra_args={"allow_redirects": False})

        continents = result["continents"]

        africa = continents[0]

        assert africa["code"] == "AF" 
Example #2
Source File: ws.py    From aries-cloudagent-python with Apache License 2.0 5 votes vote down vote up
def start(self):
        """Start the outbound transport."""
        self.client_session = ClientSession(cookie_jar=DummyCookieJar())
        return self 
Example #3
Source File: http.py    From aries-cloudagent-python with Apache License 2.0 5 votes vote down vote up
def start(self):
        """Start the transport."""
        session_args = {}
        self.connector = TCPConnector(limit=200, limit_per_host=50)
        if self.collector:
            session_args["trace_configs"] = [
                StatsTracer(self.collector, "outbound-http:")
            ]
        session_args["cookie_jar"] = DummyCookieJar()
        session_args["connector"] = self.connector
        self.client_session = ClientSession(**session_args)
        return self 
Example #4
Source File: session.py    From openrasp-iast with Apache License 2.0 5 votes vote down vote up
def async_init(self):
        """
        初始化
        """
        cookie_jar = aiohttp.DummyCookieJar()
        conn = aiohttp.TCPConnector(limit=0)
        timeout = aiohttp.ClientTimeout(
            total=Config().get_config("scanner.request_timeout"))
        self.session = aiohttp.ClientSession(
            cookie_jar=cookie_jar,
            connector=conn,
            timeout=timeout
        )