aiohttp-hijacks-0.0.1
توضیحات
Re-route aiohttp session requests. Usefull for testing.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | aiohttp-hijacks-0.0.1 |
| نام | aiohttp-hijacks |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | cdlr75 |
| ایمیل نویسنده | cdlr75@gmail.com |
| آدرس صفحه اصلی | https://gitlab.com/cdlr75/aiohttp-hijacks |
| آدرس اینترنتی | https://pypi.org/project/aiohttp-hijacks/ |
| مجوز | - |
aiohttp-hijacks
===
Hijack aiohttp session to re-route the requests.
```py
from aiohttp_hijacks import FakeServer, FakeSession, route
class Server(FakeServer):
""" Application that will respond to the client. """
@route('/')
async def get_abc(self, request):
self.calls += 1
return self.json_response({"status": "ok"})
# Reroute google.com → 127.0.0.1
async with Server() as server: # instantiate Server handling '127.0.0.1:{server.port}/abc'
async with FakeSession(reroute={'google.com': server.port}) as session:
# redirecting calls to http(s)://google.com to 127.0.0.1:{server.port}
resp = await session.get("https://google.com")
data = await resp.json()
assert data == {"status": "ok"}
```
نیازمندی
| مقدار | نام |
|---|---|
| - | aiohttp |
| ==0.13.0 | asynctest |
| ==6.2.2 | pytest |
| ==2.11.1 | pytest-cov |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3 | Python |
نحوه نصب
نصب پکیج whl aiohttp-hijacks-0.0.1:
pip install aiohttp-hijacks-0.0.1.whl
نصب پکیج tar.gz aiohttp-hijacks-0.0.1:
pip install aiohttp-hijacks-0.0.1.tar.gz