aio-libs / aio-libs/aiohttp

How to override HTTP CONNECT

Đang mở
#4,571 9 bình luận 0 reaction 1 người được giao Được @asvetlov nhận Xem trên GitHub
bug enhancement
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

🐞 **Describe the bug**
I implement HTTP/HTTPS Proxy based on aiohttp and I need override HTTP connect method in subclass of aiohttp.web.View such as this guide

https://aiohttp.readthedocs.io/en/latest/web_reference.html

Overridable coroutine methods: connect(), delete(), get(), head(), options(), patch(), post(), put(), trace().

In this sample code, HTTP connect handler never called

💡 **To Reproduce**
```python
import asyncio

from aiohttp import web, hdrs
from aiohttp.log import logging as logger

class HttpProxyView(web.View):

async def get(self):
logger.debug('Handle {}'.format(self.request.path))
name = self.request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)

async def connect(self):
logger.debug('Start CONNECT to %s', self.request.path)

async def run_app(app, host, port):
runner = web.AppRunner(app)
await runner.setup()

site = web.TCPSite(runner, host, port)
await site.start()

while True:
await asyncio.sleep(3600)

if __name__ == '__main__':
logger.basicConfig(level=logger.DEBUG)

app = web.Application()
app.add_routes([
web.view('/', HttpProxyView),
web.view('/{name:.*}', HttpProxyView)])

loop = asyncio.get_event_loop()
try:
loop.run_until_complete(run_app(app, host='0.0.0.0', port=8080))
except KeyboardInterrupt:
pass
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.