httpdbg 0.32.0__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {httpdbg-0.32.0 → httpdbg-1.0.0}/PKG-INFO +24 -19
- {httpdbg-0.32.0 → httpdbg-1.0.0}/README.md +23 -16
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/__init__.py +1 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/__main__.py +2 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/args.py +6 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/all.py +8 -3
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/external.py +21 -3
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/socket.py +166 -98
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/template_sitecustomize.py +6 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/utils.py +1 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/records.py +57 -23
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/server.py +3 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/api.py +2 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/index.htm +2 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/style.css +1 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/table.css +4 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg.egg-info/PKG-INFO +24 -19
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg.egg-info/SOURCES.txt +1 -1
- {httpdbg-0.32.0 → httpdbg-1.0.0}/pyproject.toml +0 -3
- httpdbg-0.32.0/tests/test_server.py → httpdbg-1.0.0/tests/test_pyhttpdbg_server.py +7 -6
- httpdbg-1.0.0/tests/test_server.py +51 -0
- httpdbg-0.32.0/httpdbg.egg-info/requires.txt +0 -3
- {httpdbg-0.32.0 → httpdbg-1.0.0}/LICENSE +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/env.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/exception.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/__init__.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/aiohttp.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/generic.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/httpx.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/pytest.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/requests.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/unittest.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/hooks/urllib3.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/initiator.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/log.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/mode_console.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/mode_module.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/mode_script.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/preview.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/utils.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/__init__.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/app.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/api.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/column.css +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/configuration.css +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/configuration.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/detail.css +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/favicon.ico +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/filter.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/chevron-direction-top-outline-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/download-install-line-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/engine-gears-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/eye-blind-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/eye-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/files-papers-outline-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/filter-outline-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/information-mark-circle-outline-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/lock-line-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/lock-open-line-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/math-multiplication-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/push-pin-green-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/question-mark-round-line-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/recycle-bin-line-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/icons/wait-sandclock-icon.svg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/main.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/mustache.min.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg/webapp/static/render.js +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg.egg-info/dependency_links.txt +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg.egg-info/entry_points.txt +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/httpdbg.egg-info/top_level.txt +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/setup.cfg +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_api.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_cli.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_context_manager.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_aiohttp.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_httpx.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_pytest.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_requests.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_unittest.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_hook_urllib3.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_initiator.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_mode_console.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_mode_module_pytest.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_mode_script.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_multiprocess.py +0 -0
- {httpdbg-0.32.0 → httpdbg-1.0.0}/tests/test_preview.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: httpdbg
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: A very simple tool to debug HTTP(S) client requests
|
|
5
5
|
Author-email: cle-b <cle@tictac.pm>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -23,12 +23,10 @@ Classifier: Topic :: Utilities
|
|
|
23
23
|
Requires-Python: >=3.9
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
|
-
Provides-Extra: pytest
|
|
27
|
-
Requires-Dist: pytest-httpdbg>=0.6.0; extra == "pytest"
|
|
28
26
|
|
|
29
27
|
# httpdbg
|
|
30
28
|
|
|
31
|
-
`httpdbg` is a tool for Python developers to easily debug the HTTP(S) client requests in a Python program.
|
|
29
|
+
`httpdbg` is a tool for Python developers to easily debug the HTTP(S) client and server requests in a Python program.
|
|
32
30
|
|
|
33
31
|
To use it, execute your program using the `pyhttpdbg` command instead of `python` and that's it. Open a browser to `http://localhost:4909` to view the requests:
|
|
34
32
|
|
|
@@ -44,6 +42,8 @@ pip install httpdbg
|
|
|
44
42
|
|
|
45
43
|
## usage
|
|
46
44
|
|
|
45
|
+
By default, both client and server requests are recorded. To record only client requests, use the `--only-client` command line argument.
|
|
46
|
+
|
|
47
47
|
### interactive console
|
|
48
48
|
|
|
49
49
|
Open an interactive console using the command `pyhttpdbg`.
|
|
@@ -71,30 +71,26 @@ You can trace all the HTTP requests performed by a script
|
|
|
71
71
|
pyhttpdbg --script filename.py [arg1 --arg2 ...]
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
###
|
|
75
|
-
|
|
76
|
-
You can trace all the HTTP requests performed during your tests
|
|
74
|
+
### module
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
pyhttpdbg -m pytest [arg1 --arg2 ...]
|
|
80
|
-
```
|
|
76
|
+
You can trace all the HTTP requests performed by a library module run as a script using the `-m` command line argument.
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
For example, you can view which HTTP requests are performed by `pip` when you install a package.
|
|
83
79
|
|
|
84
80
|
```console
|
|
85
|
-
pip install
|
|
81
|
+
pyhttpdbg -m pip install hookdns --upgrade
|
|
86
82
|
```
|
|
87
83
|
|
|
88
|
-
###
|
|
84
|
+
### test frameworks
|
|
89
85
|
|
|
90
|
-
You can trace all
|
|
91
|
-
|
|
92
|
-
For example, you can view which HTTP requests are performed by `pip` when you install a package.
|
|
86
|
+
You can trace all HTTP requests made during your tests (pytest, unittest).
|
|
93
87
|
|
|
94
88
|
```console
|
|
95
|
-
pyhttpdbg -m
|
|
89
|
+
pyhttpdbg -m pytest [arg1 --arg2 ...]
|
|
96
90
|
```
|
|
97
91
|
|
|
92
|
+
In that case, the requests will be grouped by test, and any requests made within a fixture or the setup/teardown methods will be identified by a tag.
|
|
93
|
+
|
|
98
94
|
## Initiators
|
|
99
95
|
|
|
100
96
|
An initiator is the function/method that is at the origin of the HTTP requests. By default, we already support some packages but you can add your own initiators.
|
|
@@ -107,7 +103,7 @@ pyhttpdbg -i api_client_pck --script my_script.py
|
|
|
107
103
|
|
|
108
104
|
You can use any package as an initiator, this is not limited to HTTP requests.
|
|
109
105
|
|
|
110
|
-
### Already supported packages
|
|
106
|
+
### Already supported packages for HTTP client
|
|
111
107
|
|
|
112
108
|
| packages | status |
|
|
113
109
|
|----------------|-------------------------------------|
|
|
@@ -126,7 +122,9 @@ No configuration is necessary to start but some few settings are available for p
|
|
|
126
122
|
### command line
|
|
127
123
|
|
|
128
124
|
```console
|
|
129
|
-
usage: pyhttpdbg [-h] [--host HOST] [--port PORT] [--version]
|
|
125
|
+
usage: pyhttpdbg [-h] [--host HOST] [--port PORT] [--version]
|
|
126
|
+
[--initiator INITIATOR] [--only-client]
|
|
127
|
+
[--keep-up | --force-quit]
|
|
130
128
|
[--console | --module MODULE | --script SCRIPT]
|
|
131
129
|
|
|
132
130
|
httdbg - a very simple tool to debug HTTP(S) client requests
|
|
@@ -138,6 +136,7 @@ options:
|
|
|
138
136
|
--version, -v print the httpdbg version
|
|
139
137
|
--initiator INITIATOR, -i INITIATOR
|
|
140
138
|
add a new initiator (package)
|
|
139
|
+
--only-client record only HTTP client requests
|
|
141
140
|
--keep-up, -k keep the server up even if the requests have been read
|
|
142
141
|
--force-quit, -q stop the server even if the requests have not been read
|
|
143
142
|
--console run a python console (default)
|
|
@@ -173,6 +172,12 @@ The requests:
|
|
|
173
172
|
* are still available in the web page even if the python process stopped (except if you force quit before the requests have been loaded by the web page).
|
|
174
173
|
* are automatically cleaned if a new execution is detected.
|
|
175
174
|
|
|
175
|
+
## limitations
|
|
176
|
+
|
|
177
|
+
Theoretically, if your HTTP client or server uses a standard Python socket, the HTTP requests will be recorded.
|
|
178
|
+
|
|
179
|
+
Support for recording requests on the server side is new in `httpdbg 1.0.0` and is currently limited. For example, it doesn't work with `FastAPI`, which uses `uvloop`, but it does work with `Uvicorn` if the loop is `asyncio`. Work is in progress to improve this.
|
|
180
|
+
|
|
176
181
|
## documentation
|
|
177
182
|
|
|
178
183
|
https://httpdbg.readthedocs.io
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# httpdbg
|
|
2
2
|
|
|
3
|
-
`httpdbg` is a tool for Python developers to easily debug the HTTP(S) client requests in a Python program.
|
|
3
|
+
`httpdbg` is a tool for Python developers to easily debug the HTTP(S) client and server requests in a Python program.
|
|
4
4
|
|
|
5
5
|
To use it, execute your program using the `pyhttpdbg` command instead of `python` and that's it. Open a browser to `http://localhost:4909` to view the requests:
|
|
6
6
|
|
|
@@ -16,6 +16,8 @@ pip install httpdbg
|
|
|
16
16
|
|
|
17
17
|
## usage
|
|
18
18
|
|
|
19
|
+
By default, both client and server requests are recorded. To record only client requests, use the `--only-client` command line argument.
|
|
20
|
+
|
|
19
21
|
### interactive console
|
|
20
22
|
|
|
21
23
|
Open an interactive console using the command `pyhttpdbg`.
|
|
@@ -43,30 +45,26 @@ You can trace all the HTTP requests performed by a script
|
|
|
43
45
|
pyhttpdbg --script filename.py [arg1 --arg2 ...]
|
|
44
46
|
```
|
|
45
47
|
|
|
46
|
-
###
|
|
47
|
-
|
|
48
|
-
You can trace all the HTTP requests performed during your tests
|
|
48
|
+
### module
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
pyhttpdbg -m pytest [arg1 --arg2 ...]
|
|
52
|
-
```
|
|
50
|
+
You can trace all the HTTP requests performed by a library module run as a script using the `-m` command line argument.
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
For example, you can view which HTTP requests are performed by `pip` when you install a package.
|
|
55
53
|
|
|
56
54
|
```console
|
|
57
|
-
pip install
|
|
55
|
+
pyhttpdbg -m pip install hookdns --upgrade
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
###
|
|
58
|
+
### test frameworks
|
|
61
59
|
|
|
62
|
-
You can trace all
|
|
63
|
-
|
|
64
|
-
For example, you can view which HTTP requests are performed by `pip` when you install a package.
|
|
60
|
+
You can trace all HTTP requests made during your tests (pytest, unittest).
|
|
65
61
|
|
|
66
62
|
```console
|
|
67
|
-
pyhttpdbg -m
|
|
63
|
+
pyhttpdbg -m pytest [arg1 --arg2 ...]
|
|
68
64
|
```
|
|
69
65
|
|
|
66
|
+
In that case, the requests will be grouped by test, and any requests made within a fixture or the setup/teardown methods will be identified by a tag.
|
|
67
|
+
|
|
70
68
|
## Initiators
|
|
71
69
|
|
|
72
70
|
An initiator is the function/method that is at the origin of the HTTP requests. By default, we already support some packages but you can add your own initiators.
|
|
@@ -79,7 +77,7 @@ pyhttpdbg -i api_client_pck --script my_script.py
|
|
|
79
77
|
|
|
80
78
|
You can use any package as an initiator, this is not limited to HTTP requests.
|
|
81
79
|
|
|
82
|
-
### Already supported packages
|
|
80
|
+
### Already supported packages for HTTP client
|
|
83
81
|
|
|
84
82
|
| packages | status |
|
|
85
83
|
|----------------|-------------------------------------|
|
|
@@ -98,7 +96,9 @@ No configuration is necessary to start but some few settings are available for p
|
|
|
98
96
|
### command line
|
|
99
97
|
|
|
100
98
|
```console
|
|
101
|
-
usage: pyhttpdbg [-h] [--host HOST] [--port PORT] [--version]
|
|
99
|
+
usage: pyhttpdbg [-h] [--host HOST] [--port PORT] [--version]
|
|
100
|
+
[--initiator INITIATOR] [--only-client]
|
|
101
|
+
[--keep-up | --force-quit]
|
|
102
102
|
[--console | --module MODULE | --script SCRIPT]
|
|
103
103
|
|
|
104
104
|
httdbg - a very simple tool to debug HTTP(S) client requests
|
|
@@ -110,6 +110,7 @@ options:
|
|
|
110
110
|
--version, -v print the httpdbg version
|
|
111
111
|
--initiator INITIATOR, -i INITIATOR
|
|
112
112
|
add a new initiator (package)
|
|
113
|
+
--only-client record only HTTP client requests
|
|
113
114
|
--keep-up, -k keep the server up even if the requests have been read
|
|
114
115
|
--force-quit, -q stop the server even if the requests have not been read
|
|
115
116
|
--console run a python console (default)
|
|
@@ -145,6 +146,12 @@ The requests:
|
|
|
145
146
|
* are still available in the web page even if the python process stopped (except if you force quit before the requests have been loaded by the web page).
|
|
146
147
|
* are automatically cleaned if a new execution is detected.
|
|
147
148
|
|
|
149
|
+
## limitations
|
|
150
|
+
|
|
151
|
+
Theoretically, if your HTTP client or server uses a standard Python socket, the HTTP requests will be recorded.
|
|
152
|
+
|
|
153
|
+
Support for recording requests on the server side is new in `httpdbg 1.0.0` and is currently limited. For example, it doesn't work with `FastAPI`, which uses `uvloop`, but it does work with `Uvicorn` if the loop is `asyncio`. Work is in progress to improve this.
|
|
154
|
+
|
|
148
155
|
## documentation
|
|
149
156
|
|
|
150
157
|
https://httpdbg.readthedocs.io
|
|
@@ -29,7 +29,8 @@ def pyhttpdbg(params, subparams, test_mode=False):
|
|
|
29
29
|
sys.path.insert(0, "") # to mimic the default python command behavior
|
|
30
30
|
|
|
31
31
|
with httpdbg_srv(params.host, params.port) as records:
|
|
32
|
-
|
|
32
|
+
records.server = not params.only_client
|
|
33
|
+
with httprecord(records, params.initiator, server=records.server):
|
|
33
34
|
if params.module:
|
|
34
35
|
run_module(subparams)
|
|
35
36
|
elif params.script:
|
|
@@ -36,6 +36,12 @@ def read_args(args: List[str]) -> Tuple[argparse.Namespace, List[str]]:
|
|
|
36
36
|
"--initiator", "-i", action="append", help="add a new initiator (package)"
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"--only-client",
|
|
41
|
+
action="store_true",
|
|
42
|
+
help="record only HTTP client requests",
|
|
43
|
+
)
|
|
44
|
+
|
|
39
45
|
server_state = parser.add_mutually_exclusive_group()
|
|
40
46
|
|
|
41
47
|
server_state.add_argument(
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from contextlib import contextmanager
|
|
3
3
|
from typing import Generator
|
|
4
4
|
from typing import List
|
|
5
|
+
from typing import Tuple
|
|
5
6
|
from typing import Union
|
|
6
7
|
|
|
7
8
|
from httpdbg.hooks.aiohttp import hook_aiohttp
|
|
@@ -18,12 +19,16 @@ from httpdbg.records import HTTPRecords
|
|
|
18
19
|
|
|
19
20
|
@contextmanager
|
|
20
21
|
def httprecord(
|
|
21
|
-
records: HTTPRecords = None,
|
|
22
|
+
records: HTTPRecords = None,
|
|
23
|
+
initiators: Union[List[str], None] = None,
|
|
24
|
+
client: bool = True,
|
|
25
|
+
server: bool = False,
|
|
26
|
+
ignore: Union[List[Tuple[str, int]], None] = None,
|
|
22
27
|
) -> Generator[HTTPRecords, None, None]:
|
|
23
28
|
if records is None:
|
|
24
|
-
records = HTTPRecords()
|
|
29
|
+
records = HTTPRecords(client=client, server=server, ignore=ignore)
|
|
25
30
|
|
|
26
|
-
with watcher_external(records):
|
|
31
|
+
with watcher_external(records, initiators, server):
|
|
27
32
|
with hook_socket(records):
|
|
28
33
|
with hook_httpx(records):
|
|
29
34
|
with hook_requests(records):
|
|
@@ -4,10 +4,11 @@ from typing import Generator
|
|
|
4
4
|
import glob
|
|
5
5
|
import os
|
|
6
6
|
import pickle
|
|
7
|
-
import shutil
|
|
8
7
|
import tempfile
|
|
9
8
|
import time
|
|
10
9
|
import threading
|
|
10
|
+
from typing import List
|
|
11
|
+
from typing import Union
|
|
11
12
|
|
|
12
13
|
from httpdbg.env import HTTPDBG_MULTIPROCESS_DIR
|
|
13
14
|
from httpdbg.log import logger
|
|
@@ -15,7 +16,11 @@ from httpdbg.records import HTTPRecords
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
@contextmanager
|
|
18
|
-
def watcher_external(
|
|
19
|
+
def watcher_external(
|
|
20
|
+
records: HTTPRecords,
|
|
21
|
+
initiators: Union[List[str], None] = None,
|
|
22
|
+
server: bool = False,
|
|
23
|
+
) -> Generator[HTTPRecords, None, None]:
|
|
19
24
|
if HTTPDBG_MULTIPROCESS_DIR not in os.environ:
|
|
20
25
|
with tempfile.TemporaryDirectory(prefix="httpdbg_") as httpdbg_multiprocess_dir:
|
|
21
26
|
|
|
@@ -31,7 +36,20 @@ def watcher_external(records: HTTPRecords) -> Generator[HTTPRecords, None, None]
|
|
|
31
36
|
)
|
|
32
37
|
sitecustomize = os.path.join(httpdbg_multiprocess_dir, "sitecustomize.py")
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
with open(template) as f:
|
|
40
|
+
template_content = f.read()
|
|
41
|
+
|
|
42
|
+
if initiators:
|
|
43
|
+
template_content = template_content.replace(
|
|
44
|
+
"HTTPDBG_INITIATORS = []", f"HTTPDBG_INITIATORS = {initiators}", 1
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
template_content = template_content.replace(
|
|
48
|
+
"HTTPDBG_RECORD_SERVER = False", f"HTTPDBG_RECORD_SERVER = {server}", 1
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
with open(sitecustomize, "w") as f:
|
|
52
|
+
f.write(template_content)
|
|
35
53
|
|
|
36
54
|
if "PYTHONPATH" in os.environ:
|
|
37
55
|
os.environ["PYTHONPATH"] = (
|