本文整理匯總了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
)