mrok 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

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.
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env python3
2
- """mrok agent devtools CLI entrypoint.
3
-
4
- Provides a small CLI that accepts an optional subscriber port and
5
- invokes the `run` function with that port.
6
- """
7
-
8
- import argparse
9
- from typing import Any
10
-
11
-
12
- def run(port: int) -> None:
13
- """Run the devtools agent using the given subscriber port.
14
-
15
- This is a stub for the runtime function. Implementation goes here.
16
- """
17
- pass
18
-
19
-
20
- def main(argv: Any = None) -> None:
21
- parser = argparse.ArgumentParser(description="mrok devtools agent")
22
- parser.add_argument(
23
- "-p",
24
- "--subscriber-port",
25
- type=int,
26
- default=50001,
27
- help="Port for subscriber (default: 50001)",
28
- )
29
- args = parser.parse_args(argv)
30
- run(args.subscriber_port)
31
-
32
-
33
- if __name__ == "__main__":
34
- main()
@@ -1,5 +0,0 @@
1
- import multiprocessing
2
-
3
-
4
- def number_of_workers() -> int:
5
- return (multiprocessing.cpu_count() * 2) + 1
mrok/proxy/constants.py DELETED
@@ -1,22 +0,0 @@
1
- MAX_REQUEST_BODY_BYTES = 2 * 1024 * 1024
2
- MAX_RESPONSE_BODY_BYTES = 5 * 1024 * 1024
3
-
4
- BINARY_CONTENT_TYPES = {
5
- "application/octet-stream",
6
- "application/pdf",
7
- }
8
-
9
- BINARY_PREFIXES = (
10
- "image/",
11
- "video/",
12
- "audio/",
13
- )
14
-
15
- TEXTUAL_CONTENT_TYPES = {
16
- "application/json",
17
- "application/xml",
18
- "application/javascript",
19
- "application/x-www-form-urlencoded",
20
- }
21
-
22
- TEXTUAL_PREFIXES = ("text/",)
mrok/proxy/utils.py DELETED
@@ -1,90 +0,0 @@
1
- from collections.abc import Mapping
2
-
3
- from mrok.proxy.constants import (
4
- BINARY_CONTENT_TYPES,
5
- BINARY_PREFIXES,
6
- MAX_REQUEST_BODY_BYTES,
7
- MAX_RESPONSE_BODY_BYTES,
8
- TEXTUAL_CONTENT_TYPES,
9
- TEXTUAL_PREFIXES,
10
- )
11
-
12
-
13
- def is_binary(content_type: str) -> bool:
14
- ct = content_type.lower()
15
- if ct in BINARY_CONTENT_TYPES:
16
- return True
17
- if any(ct.startswith(p) for p in BINARY_PREFIXES):
18
- return True
19
- return False
20
-
21
-
22
- def is_textual(content_type: str) -> bool:
23
- ct = content_type.lower()
24
- if ct in TEXTUAL_CONTENT_TYPES:
25
- return True
26
- if any(ct.startswith(p) for p in TEXTUAL_PREFIXES):
27
- return True
28
- return False
29
-
30
-
31
- def must_capture_request(
32
- method: str,
33
- headers: Mapping,
34
- ) -> bool:
35
- method = method.upper()
36
-
37
- # No body expected
38
- if method in ("GET", "HEAD", "OPTIONS", "TRACE"):
39
- return False
40
-
41
- content_type = headers.get("content-type", "").lower()
42
-
43
- content_length = None
44
- if "content-length" in headers:
45
- content_length = int(headers["content-length"])
46
-
47
- if is_binary(content_type):
48
- return False
49
-
50
- if content_type.startswith("multipart/form-data"):
51
- return False
52
-
53
- if content_length is not None and content_length > MAX_REQUEST_BODY_BYTES:
54
- return False
55
-
56
- if is_textual(content_type):
57
- return True
58
-
59
- if content_length is None:
60
- return True
61
-
62
- return content_length <= MAX_REQUEST_BODY_BYTES
63
-
64
-
65
- def must_capture_response(
66
- headers: Mapping,
67
- ) -> bool:
68
- content_type = headers.get("content-type", "").lower()
69
- disposition = headers.get("content-disposition", "").lower()
70
-
71
- content_length = None
72
- if "content-length" in headers:
73
- content_length = int(headers["content-length"])
74
-
75
- if "attachment" in disposition:
76
- return False
77
-
78
- if is_binary(content_type):
79
- return False
80
-
81
- if content_length is not None and content_length > MAX_RESPONSE_BODY_BYTES:
82
- return False
83
-
84
- if is_textual(content_type):
85
- return True
86
-
87
- if content_length is None:
88
- return True
89
-
90
- return content_length <= MAX_RESPONSE_BODY_BYTES
File without changes