Skip to main content

aiohttp-hijacks

Hijack aiohttp session to re-route the requests.

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"}

Metadata

Release files for aiohttp-hijacks 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-hijacks 0.0.1
File Size Uploaded
aiohttp-hijacks-0.0.1.tar.gz 22.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-hijacks 0.0.1
File Interpreter ABI Platform
aiohttp_hijacks-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / aiohttp-hijacks-0.0.1.tar.gz

Download URL aiohttp-hijacks-0.0.1.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
913d717dbe080816cee5a33843cc655176ee3ee9458964b4ae05521dc5c22217
BLAKE2b-256 checksum
How to use checksums
40b1f13155390210bf3a9647d0208a7ff08215f36c8c2efc6c05f8bb25cad867
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12

Release files / aiohttp_hijacks-0.0.1-py3-none-any.whl

Download URL aiohttp_hijacks-0.0.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb39909bbc58273be25ba303567521e91d676686e9cc8a5d86f6d8a02697a77a
BLAKE2b-256 checksum
How to use checksums
f89fe9ec48f8ffd1d11f35c6a77bbdcc93cf1a13c569382702d0c7a4e52b6f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page