Skip to content

Commit 9b64906

Browse files
committed
Add support for intercepting Python aiohttp
1 parent ba708cb commit 9b64906

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

overrides/pythonpath/aiohttp.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from httptoolkit_intercept import preload_real_module
2+
preload_real_module('aiohttp')
3+
4+
import functools, aiohttp
5+
6+
# Re-export all public fields, and a few notable private fields for max compatibility:
7+
from aiohttp import *
8+
from aiohttp import __path__, __file__, __doc__
9+
10+
# Forcibly enable environment trust for all sessions:
11+
_session_init = aiohttp.ClientSession.__init__
12+
@functools.wraps(_session_init)
13+
def _new_client_session_init(self, *k, **kw):
14+
_session_init(self,*k, **dict(kw, trust_env=True))
15+
aiohttp.ClientSession.__init__ = _new_client_session_init

0 commit comments

Comments
 (0)