httpdbg 0.29.1__tar.gz → 0.29.2__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.
Files changed (76) hide show
  1. {httpdbg-0.29.1 → httpdbg-0.29.2}/PKG-INFO +1 -1
  2. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/__init__.py +1 -1
  3. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/__main__.py +1 -1
  4. httpdbg-0.29.2/httpdbg/mode_console.py +81 -0
  5. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/PKG-INFO +1 -1
  6. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_mode_console.py +29 -1
  7. httpdbg-0.29.1/httpdbg/mode_console.py +0 -37
  8. {httpdbg-0.29.1 → httpdbg-0.29.2}/LICENSE +0 -0
  9. {httpdbg-0.29.1 → httpdbg-0.29.2}/README.md +0 -0
  10. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/args.py +0 -0
  11. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/env.py +0 -0
  12. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/exception.py +0 -0
  13. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/__init__.py +0 -0
  14. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/aiohttp.py +0 -0
  15. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/all.py +0 -0
  16. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/external.py +0 -0
  17. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/generic.py +0 -0
  18. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/httpx.py +0 -0
  19. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/pytest.py +0 -0
  20. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/requests.py +0 -0
  21. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/socket.py +0 -0
  22. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/urllib3.py +0 -0
  23. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/hooks/utils.py +0 -0
  24. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/initiator.py +0 -0
  25. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/log.py +0 -0
  26. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/mode_module.py +0 -0
  27. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/mode_script.py +0 -0
  28. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/preview.py +0 -0
  29. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/records.py +0 -0
  30. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/server.py +0 -0
  31. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/utils.py +0 -0
  32. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/__init__.py +0 -0
  33. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/api.py +0 -0
  34. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/app.py +0 -0
  35. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/api.js +0 -0
  36. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/column.css +0 -0
  37. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/configuration.js +0 -0
  38. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/detail.css +0 -0
  39. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/favicon.ico +0 -0
  40. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/filter.js +0 -0
  41. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/chevron-direction-top-outline-icon.svg +0 -0
  42. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/download-install-line-icon.svg +0 -0
  43. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/engine-gears-icon.svg +0 -0
  44. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/files-papers-outline-icon.svg +0 -0
  45. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/filter-outline-icon.svg +0 -0
  46. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/information-mark-circle-outline-icon.svg +0 -0
  47. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/math-multiplication-icon.svg +0 -0
  48. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/push-pin-green-icon.svg +0 -0
  49. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/question-mark-round-line-icon.svg +0 -0
  50. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/recycle-bin-line-icon.svg +0 -0
  51. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/icons/wait-sandclock-icon.svg +0 -0
  52. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/index.htm +0 -0
  53. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/main.js +0 -0
  54. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/mustache.min.js +0 -0
  55. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/render.js +0 -0
  56. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/style.css +0 -0
  57. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg/webapp/static/table.css +0 -0
  58. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/SOURCES.txt +0 -0
  59. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/dependency_links.txt +0 -0
  60. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/entry_points.txt +0 -0
  61. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/requires.txt +0 -0
  62. {httpdbg-0.29.1 → httpdbg-0.29.2}/httpdbg.egg-info/top_level.txt +0 -0
  63. {httpdbg-0.29.1 → httpdbg-0.29.2}/pyproject.toml +0 -0
  64. {httpdbg-0.29.1 → httpdbg-0.29.2}/setup.cfg +0 -0
  65. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_api.py +0 -0
  66. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_cli.py +0 -0
  67. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_context_manager.py +0 -0
  68. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_hook_aiohttp.py +0 -0
  69. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_hook_httpx.py +0 -0
  70. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_hook_requests.py +0 -0
  71. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_hook_urllib3.py +0 -0
  72. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_initiator.py +0 -0
  73. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_mode_module_pytest.py +0 -0
  74. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_mode_script.py +0 -0
  75. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_preview.py +0 -0
  76. {httpdbg-0.29.1 → httpdbg-0.29.2}/tests/test_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: httpdbg
3
- Version: 0.29.1
3
+ Version: 0.29.2
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
@@ -3,6 +3,6 @@ from httpdbg.hooks.all import httprecord
3
3
  from httpdbg.records import HTTPRecords
4
4
 
5
5
 
6
- __version__ = "0.29.1"
6
+ __version__ = "0.29.2"
7
7
 
8
8
  __all__ = ["httprecord", "HTTPRecords"]
@@ -35,7 +35,7 @@ def pyhttpdbg(params, subparams, test_mode=False):
35
35
  elif params.script:
36
36
  run_script(subparams)
37
37
  else:
38
- run_console(test_mode)
38
+ run_console(records, test_mode)
39
39
 
40
40
  if not (params.force_quit or test_mode):
41
41
  print_msg(f" httpdbg - HTTP(S) requests available at {url}")
@@ -0,0 +1,81 @@
1
+ # -*- coding: utf-8 -*-
2
+ import code
3
+ from typing import List
4
+ from typing import Union
5
+
6
+ from httpdbg.records import HTTPRecords
7
+ from httpdbg.initiator import httpdbg_group
8
+
9
+
10
+ def console_exit():
11
+ raise SystemExit
12
+
13
+
14
+ class InteractiveConsoleWithHistory(code.InteractiveConsole):
15
+
16
+ def __init__(self, records: HTTPRecords, locals=None):
17
+ self.records: HTTPRecords = records
18
+ self.history: List[str] = []
19
+ self.incomplete_block: bool = False
20
+ super().__init__(locals)
21
+
22
+ def push(self, line):
23
+ if line: # if the line is empty, we don't add it in the history
24
+ if (
25
+ self.incomplete_block
26
+ ): # if the latest instruction is part of a block, we group it with the previous one
27
+ self.history[-1] += (
28
+ "\n " + line
29
+ ) # to simulate the block indentation
30
+ else:
31
+ self.history.append(line)
32
+
33
+ # if the latest instruction is part of a block, the label is generic
34
+ label = self.history[-1] if not self.incomplete_block else "(block)"
35
+
36
+ # in the full label, we keep the last 5 instructions/blocks
37
+ latest_history = self.history[-5:]
38
+ if not self.incomplete_block:
39
+ # in case of a block, we don't know which line within the block is the initiator.
40
+ # this is why we do not mark it in that case.
41
+ # this information is displayed in the initiator tooltip of the requests (in console, line X,)
42
+ latest_history[-1] += " <===="
43
+
44
+ full_label = ">>> " + "\n>>> ".join(latest_history)
45
+
46
+ with httpdbg_group(self.records, label, full_label):
47
+ self.incomplete_block = super().push(line)
48
+
49
+ return self.incomplete_block
50
+
51
+
52
+ def run_console(
53
+ records: HTTPRecords, test_mode: bool = False
54
+ ) -> Union[InteractiveConsoleWithHistory, None]:
55
+ try:
56
+ vars = globals()
57
+ vars.update(locals())
58
+
59
+ try:
60
+ # adds history and autocompletion capabilities
61
+ import readline
62
+ import rlcompleter
63
+
64
+ readline.set_completer(rlcompleter.Completer(vars).complete)
65
+ readline.parse_and_bind("tab: complete")
66
+ except ImportError: # pragma: no cover
67
+ # readline is not available on Windows
68
+ pass
69
+
70
+ vars.update({"exit": console_exit})
71
+
72
+ new_console = InteractiveConsoleWithHistory(records, vars)
73
+ if not test_mode:
74
+ new_console.interact() # pragma: no cover
75
+ else:
76
+ new_console.push("print('test_mode is on')")
77
+ return new_console
78
+ except SystemExit: # pragma: no cover
79
+ pass
80
+
81
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: httpdbg
3
- Version: 0.29.1
3
+ Version: 0.29.2
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
@@ -36,7 +36,7 @@ def test_run_console_from_pyhttpdbg_entry_point_default(
36
36
  def test_run_console(httpbin, httpdbg_host, httpdbg_port):
37
37
  with httpdbg_srv(httpdbg_host, httpdbg_port) as records:
38
38
  with httprecord(records):
39
- new_console = run_console(test_mode=True)
39
+ new_console = run_console(records, test_mode=True)
40
40
  new_console.push("import requests")
41
41
  new_console.push(f"requests.get('{httpbin.url}/get')")
42
42
  with pytest.raises(SystemExit):
@@ -48,3 +48,31 @@ def test_run_console(httpbin, httpdbg_host, httpdbg_port):
48
48
 
49
49
  assert len(reqs) == 1
50
50
  assert reqs[list(reqs.keys())[0]]["url"] == httpbin.url + "/get"
51
+
52
+
53
+ @pytest.mark.group
54
+ def test_run_console_group(httpbin):
55
+
56
+ with httprecord() as records:
57
+ new_console = run_console(records, test_mode=True)
58
+ new_console.push("import requests")
59
+ new_console.push(f"requests.get('{httpbin.url}/get')")
60
+ new_console.push("if True:")
61
+ new_console.push(f" requests.post('{httpbin.url}/post')")
62
+ new_console.push("")
63
+ with pytest.raises(SystemExit):
64
+ new_console.push("exit()")
65
+
66
+ assert len(records) == 2
67
+ assert (
68
+ records.groups[records[0].group_id].label
69
+ == f"requests.get('{httpbin.url}/get')"
70
+ )
71
+ assert records.groups[records[0].group_id].full_label.endswith(
72
+ f">>> requests.get('{httpbin.url}/get') <===="
73
+ )
74
+
75
+ assert records.groups[records[1].group_id].label == "(block)"
76
+ assert records.groups[records[1].group_id].full_label.endswith(
77
+ f">>> if True:\n requests.post('{httpbin.url}/post')"
78
+ )
@@ -1,37 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import code
3
- from typing import Union
4
-
5
-
6
- def console_exit():
7
- raise SystemExit
8
-
9
-
10
- def run_console(test_mode: bool = False) -> Union[code.InteractiveConsole, None]:
11
- try:
12
- vars = globals()
13
- vars.update(locals())
14
-
15
- try:
16
- # adds history and autocompletion capabilities
17
- import readline
18
- import rlcompleter
19
-
20
- readline.set_completer(rlcompleter.Completer(vars).complete)
21
- readline.parse_and_bind("tab: complete")
22
- except ImportError: # pragma: no cover
23
- # readline is not available on Windows
24
- pass
25
-
26
- vars.update({"exit": console_exit})
27
-
28
- new_console = code.InteractiveConsole(vars)
29
- if not test_mode:
30
- new_console.interact() # pragma: no cover
31
- else:
32
- new_console.push("print('test_mode is on')")
33
- return new_console
34
- except SystemExit: # pragma: no cover
35
- pass
36
-
37
- return None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes