action0-req 0.1.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.
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: action0-req
3
+ Version: 0.1.0
4
+ Summary: Library for representing, creating and manipulating HTTP requests and responses
5
+ Project-URL: Homepage, https://github.com/LaughInJar/action0-req
6
+ Project-URL: Documentation, https://laughinjar.github.io/action0-req/
7
+ Project-URL: Source, https://github.com/LaughInJar/action0-req
8
+ Project-URL: Issues, https://github.com/LaughInJar/action0-req/issues
9
+ Author: Simon Lachinger
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: headers,http,manipulation,request,response,status
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Topic :: Internet :: WWW/HTTP
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: action0-url>=0.1.0
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Action0-Req
30
+
31
+ [![CI](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml/badge.svg)](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml)
32
+ [![PyPI](https://img.shields.io/pypi/v/action0-req)](https://pypi.org/project/action0-req/)
33
+
34
+ Typed Python representations of HTTP requests and responses with
35
+ convenient creation, duplication and manipulation. The companion of
36
+ [action0-url](https://github.com/LaughInJar/action0-url), which provides
37
+ the URL representation.
38
+
39
+ Requires Python 3.11 or newer.
40
+
41
+ Full documentation including the API reference:
42
+ <https://laughinjar.github.io/action0-req/>
43
+
44
+ **Status:** the core API is complete — the header name, status code and
45
+ method constants, the `Headers` mapping, `Request` and `Response`, and
46
+ sync/async body streaming via `BodyProducer` (`BytesBody`, `FileBody`,
47
+ `IterableBody`, `AsyncIterableBody`).
48
+
49
+ ## Usage
50
+
51
+ `Header`, `Status` and `Method` are `StrEnum`/`IntEnum` constants for the
52
+ IANA-registered header field names, status codes and request methods —
53
+ every member *is* its string or integer value:
54
+
55
+ ```python
56
+ from action0.req import Header, Method, Status
57
+
58
+ print(Header.CONTENT_TYPE) # Content-Type
59
+ print(Method.POST) # POST
60
+ print(Status.NOT_FOUND) # 404
61
+ print(Status.NOT_FOUND.phrase) # Not Found
62
+ print(Status.NOT_FOUND.is_client_error) # True
63
+ ```
64
+
65
+ `Headers` is an ordered, case-insensitive, multi-value aware mapping of
66
+ header fields that preserves the representation (order and casing)
67
+ exactly:
68
+
69
+ ```python
70
+ from action0.req import Headers
71
+
72
+ headers = Headers({"Content-Type": "text/html"})
73
+ headers.add("Set-Cookie", "a=1")
74
+ headers.add("set-cookie", "b=2")
75
+ print(headers["CONTENT-TYPE"]) # text/html
76
+ print(headers.get_all("Set-Cookie")) # ['a=1', 'b=2']
77
+ print(headers.as_str(separator="\n")) # "\r\n" by default
78
+ # Content-Type: text/html
79
+ # Set-Cookie: a=1
80
+ # set-cookie: b=2
81
+
82
+ # repr()/str() redact secrets, only as_str() renders them
83
+ print(Headers({"Authorization": "Bearer tok"})) # Headers(Authorization: ***)
84
+ ```
85
+
86
+ `Request` combines a method, a `Url` (from action0-url), `Headers`, a
87
+ `meta` dict for application metadata (never on the wire) and a body (`bytes`, `str` or a streaming `BodyProducer` — retrievable in any
88
+ of the three forms):
89
+
90
+ ```python
91
+ from action0.req import Request
92
+
93
+ req = Request("https://api.example.com/items", query={"page": 2})
94
+ req.headers["Accept"] = "application/json"
95
+ print(req.as_str(separator="\n")) # "\r\n" by default
96
+ # GET /items?page=2 HTTP/1.1
97
+ # Host: api.example.com
98
+ # Accept: application/json
99
+
100
+ post = req.copy(method="POST", body='{"a": 1}')
101
+ print(post.body_bytes()) # b'{"a": 1}'
102
+ print(post) # Request(POST https://api.example.com/items?page=2)
103
+ ```
104
+
105
+ `Response` mirrors it for the server side — status (with reason phrase
106
+ fallback and category properties), headers, body:
107
+
108
+ ```python
109
+ from action0.req import Response, Status
110
+
111
+ resp = Response(Status.NOT_FOUND, headers={"Content-Type": "text/plain"}, body="not here")
112
+ print(resp.phrase, resp.is_client_error) # Not Found True
113
+ print(resp.as_str(separator="\n")) # "\r\n" by default
114
+ # HTTP/1.1 404 Not Found
115
+ # Content-Type: text/plain
116
+ ```
117
+
118
+ ## Installation
119
+
120
+ Not published to PyPI yet; install straight from GitHub:
121
+
122
+ ```shell
123
+ uv add "action0-req @ git+https://github.com/LaughInJar/action0-req"
124
+ ```
125
+
126
+ ## Development
127
+
128
+ The project is managed with [uv](https://docs.astral.sh/uv/); `uv run`
129
+ creates and syncs the virtual environment automatically:
130
+
131
+ ```shell
132
+ uv run pytest # run the tests (incl. the docstring examples as doctests)
133
+ uv run ruff check # lint
134
+ uv run ruff format # format
135
+ uv run mypy # type-check (also: uv run pyright, uv run ty check)
136
+
137
+ # build the docs (Sphinx; deployed to GitHub Pages on push to main)
138
+ uv run --group docs sphinx-build -W docs docs/_build/html
139
+ ```
140
+
141
+ ### Releasing
142
+
143
+ The version lives only in `src/action0/req/__init__.py` (`__version__`).
144
+ To release: bump it, merge to `main`, then tag the release commit and push
145
+ the tag — the release workflow re-runs all checks, verifies the tag
146
+ matches `__version__`, builds sdist + wheel and publishes to PyPI via
147
+ trusted publishing:
148
+
149
+ ```shell
150
+ git tag v0.1.0
151
+ git push origin v0.1.0
152
+ ```
153
+
154
+ ## AI-assisted development
155
+
156
+ In the spirit of transparency: most of this project's code, tests and
157
+ documentation are written by [Claude Code](https://claude.com/claude-code),
158
+ Anthropic's coding agent — under human direction and review. The designs
159
+ are specified, discussed and iterated by a human, and every change is
160
+ reviewed before it lands in `main` or in a release. AI-authored commits
161
+ carry a `Co-Authored-By: Claude ...` trailer.
162
+
163
+ ## About action0
164
+
165
+ This is just the namespace I like to use for my personal projects.
166
+ I quite like namespaces.
@@ -0,0 +1,11 @@
1
+ action0/req/__init__.py,sha256=Oqq8KJo8_iKhf7IyHP34kn8bZLg_okOXyk6E0oTqjgs,554
2
+ action0/req/body.py,sha256=_4M9ul2ni_VQYlCzAPuHe8ioYHcTIHC2j5bETr9SycI,12646
3
+ action0/req/headers.py,sha256=gIZibBXp274I_Gv1qqN7CHdupkFEaHHKpyo_O0ccENA,27278
4
+ action0/req/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ action0/req/request.py,sha256=odmnXxnljR70PJ1Cc7DBPOLNfl36UmmOdLu-3m0lbIs,10366
6
+ action0/req/response.py,sha256=Ci5wU0PHfcxArIp5zulUU8PBqJJbjZJKCD-GT_yEvLk,9797
7
+ action0/req/status.py,sha256=-LYBUk9LsFkQZg8ASN3mVyPPflwg9UTU49IUcasI0I8,5484
8
+ action0_req-0.1.0.dist-info/METADATA,sha256=UX--nJRch6Ti4938kHKjJGl7J67VYPCEOeQxyPBCPQY,5902
9
+ action0_req-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
10
+ action0_req-0.1.0.dist-info/licenses/LICENSE,sha256=R9vymGGVHqWd97MhLl4WhKAYyXFeQy1HS0VbKWj40Lg,1067
11
+ action0_req-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LaughInJar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.