forked from aio-libs/aiohttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http2.txt
56 lines (34 loc) · 1.3 KB
/
http2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from aiohttp import web, web2, web_reqrep2
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
# push promise
# add Link header in case of HTTP 1.1
# start sending response after push request
await request.push_promise('/path', headers)
return web.Response(body=text.encode('utf-8'))
async def handle2(request):
return web.Response(body=b'afwefwefwe')
app = web.Application(params={})
app.router.add_route('GET', '/{name}', handle)
app.router.add_route('GET', '/path', handle2)
web.run_app(app)
request.set_priority(3)
async def t1(session):
async with session.get(url, pri=234) as response:
txt = await response.text()
for push in response.pushes():
data = await push.text()
async with aiohttp.ClientSession() as session:
await session.set_pri(stream_id=14, 1234123) # doesnt work, should have (schema, host, port) info
loop.create_task(t1(url))
ping/pong sending
HTTP proxy?
connector API
What protocol use by `session.get(url, pri=234)`, how to switch back to http1
def handler(request):
resp = web.StreamResponse()
resp.enable_compression(ContentCoding.gzip, compression=False)
yield from resp.prepare(request)
resp.write(gzip.compress(b'data'))
return resp