本文整理汇总了Python中aiohttp.DummyCookieJar方法的典型用法代码示例。如果您正苦于以下问题:Python aiohttp.DummyCookieJar方法的具体用法?Python aiohttp.DummyCookieJar怎么用?Python aiohttp.DummyCookieJar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiohttp
的用法示例。
在下文中一共展示了aiohttp.DummyCookieJar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_aiohttp_extra_args
# 需要导入模块: import aiohttp [as 别名]
# 或者: from aiohttp import DummyCookieJar [as 别名]
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"
示例2: start
# 需要导入模块: import aiohttp [as 别名]
# 或者: from aiohttp import DummyCookieJar [as 别名]
def start(self):
"""Start the outbound transport."""
self.client_session = ClientSession(cookie_jar=DummyCookieJar())
return self
示例3: start
# 需要导入模块: import aiohttp [as 别名]
# 或者: from aiohttp import DummyCookieJar [as 别名]
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
示例4: async_init
# 需要导入模块: import aiohttp [as 别名]
# 或者: from aiohttp import DummyCookieJar [as 别名]
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
)