swarmauri_transport_httpx 0.1.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.
- swarmauri_transport_httpx-0.1.0/LICENSE +13 -0
- swarmauri_transport_httpx-0.1.0/NOTICE +7 -0
- swarmauri_transport_httpx-0.1.0/PKG-INFO +330 -0
- swarmauri_transport_httpx-0.1.0/README.md +307 -0
- swarmauri_transport_httpx-0.1.0/pyproject.toml +87 -0
- swarmauri_transport_httpx-0.1.0/swarmauri_transport_httpx/AsyncHttpxStreamResponse.py +42 -0
- swarmauri_transport_httpx-0.1.0/swarmauri_transport_httpx/HttpxClient.py +171 -0
- swarmauri_transport_httpx-0.1.0/swarmauri_transport_httpx/HttpxResponse.py +32 -0
- swarmauri_transport_httpx-0.1.0/swarmauri_transport_httpx/HttpxStreamResponse.py +41 -0
- swarmauri_transport_httpx-0.1.0/swarmauri_transport_httpx/__init__.py +11 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Jacob Stewart
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_transport_httpx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: swarmauri,httpx,http,streaming,async
|
|
9
|
+
Author: Jacob Stewart
|
|
10
|
+
Author-email: jacob@swarmauri.com
|
|
11
|
+
Requires-Python: >=3.10,<3.15
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Requires-Dist: httpx (>=0.27)
|
|
19
|
+
Requires-Dist: swarmauri_base
|
|
20
|
+
Requires-Dist: swarmauri_core
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# swarmauri_transport_httpx
|
|
24
|
+
|
|
25
|
+
<!-- readme-standards:begin branding -->
|
|
26
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
27
|
+
<p align="center"><strong>swarmauri_transport_httpx</strong></p>
|
|
28
|
+
<p align="center">Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri.</p>
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="https://pypi.org/project/swarmauri_transport_httpx/"><img alt="pypi: swarmauri_transport_httpx" src="https://img.shields.io/pypi/v/swarmauri_transport_httpx?labelColor=1E293B&color=1D4ED8"></a>
|
|
31
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=1E293B&color=4338CA"></a>
|
|
32
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
33
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
34
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
35
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
36
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
37
|
+
</p>
|
|
38
|
+
<p align="center">
|
|
39
|
+
<a href="https://pypi.org/project/swarmauri_transport_httpx/"><img alt="Monthly PyPI downloads: swarmauri_transport_httpx" src="https://img.shields.io/pypi/dm/swarmauri_transport_httpx?labelColor=1E293B&color=0E7490"></a>
|
|
40
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md"><img alt="README hits: swarmauri_transport_httpx" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_transport_httpx/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
41
|
+
</p>
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
44
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
45
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
46
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
47
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
48
|
+
</p>
|
|
49
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
50
|
+
<!-- readme-standards:end branding -->
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Overview
|
|
55
|
+
|
|
56
|
+
### Summary
|
|
57
|
+
|
|
58
|
+
[](https://pypi.org/project/swarmauri_transport_httpx/) [](https://pypi.org/project/swarmauri_transport_httpx/) [](LICENSE) [](https://pepy.tech/project/swarmauri_transport_httpx) [](https://hits.sh/github.com/swarmauri/swarmauri-sdk/)
|
|
59
|
+
|
|
60
|
+
### Why This Package
|
|
61
|
+
|
|
62
|
+
`swarmauri_transport_httpx` isolates this responsibility: Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) exposes `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
63
|
+
|
|
64
|
+
### When to Use
|
|
65
|
+
|
|
66
|
+
Choose `swarmauri_transport_httpx` when your integration needs synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
67
|
+
|
|
68
|
+
### Features
|
|
69
|
+
|
|
70
|
+
- Synchronous and asynchronous buffered requests.
|
|
71
|
+
- Genuine synchronous and asynchronous streaming contexts.
|
|
72
|
+
- Persistent connection pooling with explicit ownership and cleanup.
|
|
73
|
+
- Caller-supplied HTTPX clients for testing and custom network stacks.
|
|
74
|
+
- Provider-neutral Swarmauri HTTP interfaces.
|
|
75
|
+
|
|
76
|
+
### Non-Goals
|
|
77
|
+
|
|
78
|
+
`swarmauri_transport_httpx` owns synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Getting Started
|
|
83
|
+
|
|
84
|
+
### Prerequisites
|
|
85
|
+
|
|
86
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) declares runtime dependencies including `httpx`, `swarmauri-core`, `swarmauri-base`. Read the example’s inputs and service requirements before execution.
|
|
87
|
+
|
|
88
|
+
### Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
uv add swarmauri_transport_httpx
|
|
92
|
+
pip install swarmauri_transport_httpx
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### uv
|
|
96
|
+
|
|
97
|
+
<!-- readme-standards:begin installation.uv -->
|
|
98
|
+
```bash
|
|
99
|
+
uv add swarmauri_transport_httpx
|
|
100
|
+
```
|
|
101
|
+
<!-- readme-standards:end installation.uv -->
|
|
102
|
+
|
|
103
|
+
#### pip
|
|
104
|
+
|
|
105
|
+
<!-- readme-standards:begin installation.pip -->
|
|
106
|
+
```bash
|
|
107
|
+
python -m pip install swarmauri_transport_httpx
|
|
108
|
+
```
|
|
109
|
+
<!-- readme-standards:end installation.pip -->
|
|
110
|
+
|
|
111
|
+
#### Poetry
|
|
112
|
+
|
|
113
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
114
|
+
```bash
|
|
115
|
+
poetry add swarmauri_transport_httpx
|
|
116
|
+
```
|
|
117
|
+
<!-- readme-standards:end installation.poetry -->
|
|
118
|
+
|
|
119
|
+
### Quick Start
|
|
120
|
+
|
|
121
|
+
#### Example
|
|
122
|
+
|
|
123
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
124
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/docs/readme/quick_start.py).
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from swarmauri_transport_httpx import HttpxClient
|
|
128
|
+
|
|
129
|
+
with HttpxClient(base_url="https://api.example.com") as client:
|
|
130
|
+
response = client.request("GET", "/models")
|
|
131
|
+
response.raise_for_status()
|
|
132
|
+
```
|
|
133
|
+
<!-- readme-standards:end example.quick-start -->
|
|
134
|
+
|
|
135
|
+
#### Expected Result
|
|
136
|
+
|
|
137
|
+
The example demonstrates the documented `swarmauri_transport_httpx` source boundary or workflow. Complete its required configuration first. README CI checks the maintained source’s syntax and declarations; it does not claim that external services or the application workflow were exercised.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Usage
|
|
142
|
+
|
|
143
|
+
### Common Workflows
|
|
144
|
+
|
|
145
|
+
<!-- readme-standards:begin example.usage -->
|
|
146
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/docs/readme/usage.py).
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from swarmauri_transport_httpx import HttpxClient
|
|
150
|
+
|
|
151
|
+
with HttpxClient(base_url="https://api.example.com") as client:
|
|
152
|
+
response = client.request("GET", "/models")
|
|
153
|
+
response.raise_for_status()
|
|
154
|
+
```
|
|
155
|
+
<!-- readme-standards:end example.usage -->
|
|
156
|
+
|
|
157
|
+
Use `HttpxClient.request`/`arequest` for buffered responses and `stream`/`astream` for incremental response processing.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
Injected `httpx.Client` and `httpx.AsyncClient` instances remain caller-owned and are never closed by the adapter.
|
|
161
|
+
|
|
162
|
+
### Configuration
|
|
163
|
+
|
|
164
|
+
Configure `swarmauri_transport_httpx` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
165
|
+
|
|
166
|
+
### Error Handling
|
|
167
|
+
|
|
168
|
+
The inspected `swarmauri_transport_httpx` source raises `HttpRequestError`, `HttpStatusError`, `ValueError`. Handle these at the calling boundary and consult the implementation for the triggering conditions.
|
|
169
|
+
|
|
170
|
+
### Best Practices
|
|
171
|
+
|
|
172
|
+
Use the explicit `swarmauri_transport_httpx` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`; an import or successful installation alone does not establish its runtime guarantees.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Package Boundary
|
|
177
|
+
|
|
178
|
+
### What It Owns
|
|
179
|
+
|
|
180
|
+
`swarmauri_transport_httpx` is located in `standards` and owns synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Source-declared APIs include `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) records its direct dependency boundary.
|
|
181
|
+
|
|
182
|
+
### Public API and Import Surfaces
|
|
183
|
+
|
|
184
|
+
Import namespace: `swarmauri_transport_httpx`.
|
|
185
|
+
|
|
186
|
+
Source-declared exports or types: `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`.
|
|
187
|
+
|
|
188
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
189
|
+
|
|
190
|
+
### Entry Points
|
|
191
|
+
|
|
192
|
+
<!-- readme-standards:begin entry-points -->
|
|
193
|
+
- `swarmauri.transports` → `HttpxClient` → `swarmauri_transport_httpx:HttpxClient`
|
|
194
|
+
<!-- readme-standards:end entry-points -->
|
|
195
|
+
|
|
196
|
+
### Injected Dependencies
|
|
197
|
+
|
|
198
|
+
The direct installation dependencies of `swarmauri_transport_httpx` are `httpx`, `swarmauri-core`, `swarmauri-base`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py).
|
|
199
|
+
|
|
200
|
+
### Protocol Consumers
|
|
201
|
+
|
|
202
|
+
Direct consumers in this checkout’s package manifests include `swarmauri_llm_azureopenai`, `swarmauri_llm_cloudflare`, `swarmauri_llm_nvidia_nim`, `swarmauri_llm_openrouter`, `swarmauri_llm_xai`, `swarmauri_workflow_documentassistant`. These edges describe declared dependencies, not protocol-conformance evidence.
|
|
203
|
+
|
|
204
|
+
### Extensions
|
|
205
|
+
|
|
206
|
+
For `swarmauri_transport_httpx`, use the source-declared public interfaces (`AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Operations and Readiness
|
|
211
|
+
|
|
212
|
+
### Operational Requirements
|
|
213
|
+
|
|
214
|
+
Operate `swarmauri_transport_httpx` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
215
|
+
|
|
216
|
+
### Health and Observability
|
|
217
|
+
|
|
218
|
+
This README does not establish a standalone health endpoint for `swarmauri_transport_httpx`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
219
|
+
|
|
220
|
+
### Security and Resource Limits
|
|
221
|
+
|
|
222
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py). The `swarmauri_transport_httpx` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
223
|
+
|
|
224
|
+
### Compatibility
|
|
225
|
+
|
|
226
|
+
This source version of `swarmauri_transport_httpx` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Verification
|
|
231
|
+
|
|
232
|
+
### Tests
|
|
233
|
+
|
|
234
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_transport_httpx` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
235
|
+
|
|
236
|
+
- [tests/unit/test_httpx_client.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/tests/unit/test_httpx_client.py)
|
|
237
|
+
|
|
238
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
239
|
+
|
|
240
|
+
### Certification Status
|
|
241
|
+
|
|
242
|
+
No external certification is asserted for `swarmauri_transport_httpx` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
243
|
+
|
|
244
|
+
### Evidence
|
|
245
|
+
|
|
246
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## FAQ
|
|
251
|
+
|
|
252
|
+
### Why
|
|
253
|
+
|
|
254
|
+
**Why select this package?** `swarmauri_transport_httpx` provides synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
255
|
+
|
|
256
|
+
### How
|
|
257
|
+
|
|
258
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_transport_httpx`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) for the exact types and signatures involved.
|
|
259
|
+
|
|
260
|
+
### When
|
|
261
|
+
|
|
262
|
+
**When should I validate an upgrade?** Recheck `swarmauri_transport_httpx` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Documentation and Related Packages
|
|
267
|
+
|
|
268
|
+
### More Documentation
|
|
269
|
+
|
|
270
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) provide the supporting context for `swarmauri_transport_httpx`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
271
|
+
|
|
272
|
+
### Related Packages
|
|
273
|
+
|
|
274
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
275
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
276
|
+
|
|
277
|
+
### Project Links
|
|
278
|
+
|
|
279
|
+
<!-- readme-standards:begin project-links -->
|
|
280
|
+
- [pypi: swarmauri_transport_httpx](https://pypi.org/project/swarmauri_transport_httpx/)
|
|
281
|
+
<!-- readme-standards:end project-links -->
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Contributing
|
|
286
|
+
|
|
287
|
+
### How to Contribute
|
|
288
|
+
|
|
289
|
+
Follow the [contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md) and include a focused example or regression for changes to `swarmauri_transport_httpx`. Keep package behavior, its documented boundary, and its tests aligned.
|
|
290
|
+
|
|
291
|
+
### Development Setup
|
|
292
|
+
|
|
293
|
+
Work from the `pkgs/40-standards/swarmauri_transport_httpx` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
294
|
+
|
|
295
|
+
### Notes for Maintainers
|
|
296
|
+
|
|
297
|
+
Edit authored prose directly in this `swarmauri_transport_httpx` README. Update source examples in `docs/readme/`, then run `readme-standards render --root . --write` from the package directory and review the diff. Required headings and generated blocks come from package-guide-v1.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Governance
|
|
302
|
+
|
|
303
|
+
### Ownership and Decision Making
|
|
304
|
+
|
|
305
|
+
Changes to `swarmauri_transport_httpx` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
306
|
+
|
|
307
|
+
### Standards and Policies
|
|
308
|
+
|
|
309
|
+
`swarmauri_transport_httpx` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
310
|
+
|
|
311
|
+
### Lifecycle and Migration
|
|
312
|
+
|
|
313
|
+
The `swarmauri_transport_httpx` source version is `0.1.0`.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## License and Attribution
|
|
318
|
+
|
|
319
|
+
### License
|
|
320
|
+
|
|
321
|
+
<!-- readme-standards:begin license -->
|
|
322
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/LICENSE).
|
|
323
|
+
<!-- readme-standards:end license -->
|
|
324
|
+
|
|
325
|
+
### Notices
|
|
326
|
+
|
|
327
|
+
<!-- readme-standards:begin notices -->
|
|
328
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/NOTICE) for attribution.
|
|
329
|
+
<!-- readme-standards:end notices -->
|
|
330
|
+
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# swarmauri_transport_httpx
|
|
2
|
+
|
|
3
|
+
<!-- readme-standards:begin branding -->
|
|
4
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
5
|
+
<p align="center"><strong>swarmauri_transport_httpx</strong></p>
|
|
6
|
+
<p align="center">Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri.</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_transport_httpx/"><img alt="pypi: swarmauri_transport_httpx" src="https://img.shields.io/pypi/v/swarmauri_transport_httpx?labelColor=1E293B&color=1D4ED8"></a>
|
|
9
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=1E293B&color=4338CA"></a>
|
|
10
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
11
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
12
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
13
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
14
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
15
|
+
</p>
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://pypi.org/project/swarmauri_transport_httpx/"><img alt="Monthly PyPI downloads: swarmauri_transport_httpx" src="https://img.shields.io/pypi/dm/swarmauri_transport_httpx?labelColor=1E293B&color=0E7490"></a>
|
|
18
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md"><img alt="README hits: swarmauri_transport_httpx" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_transport_httpx/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
22
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
23
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
24
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
25
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
26
|
+
</p>
|
|
27
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
28
|
+
<!-- readme-standards:end branding -->
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
### Summary
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/swarmauri_transport_httpx/) [](https://pypi.org/project/swarmauri_transport_httpx/) [](LICENSE) [](https://pepy.tech/project/swarmauri_transport_httpx) [](https://hits.sh/github.com/swarmauri/swarmauri-sdk/)
|
|
37
|
+
|
|
38
|
+
### Why This Package
|
|
39
|
+
|
|
40
|
+
`swarmauri_transport_httpx` isolates this responsibility: Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) exposes `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
41
|
+
|
|
42
|
+
### When to Use
|
|
43
|
+
|
|
44
|
+
Choose `swarmauri_transport_httpx` when your integration needs synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- Synchronous and asynchronous buffered requests.
|
|
49
|
+
- Genuine synchronous and asynchronous streaming contexts.
|
|
50
|
+
- Persistent connection pooling with explicit ownership and cleanup.
|
|
51
|
+
- Caller-supplied HTTPX clients for testing and custom network stacks.
|
|
52
|
+
- Provider-neutral Swarmauri HTTP interfaces.
|
|
53
|
+
|
|
54
|
+
### Non-Goals
|
|
55
|
+
|
|
56
|
+
`swarmauri_transport_httpx` owns synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Getting Started
|
|
61
|
+
|
|
62
|
+
### Prerequisites
|
|
63
|
+
|
|
64
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) declares runtime dependencies including `httpx`, `swarmauri-core`, `swarmauri-base`. Read the example’s inputs and service requirements before execution.
|
|
65
|
+
|
|
66
|
+
### Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv add swarmauri_transport_httpx
|
|
70
|
+
pip install swarmauri_transport_httpx
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### uv
|
|
74
|
+
|
|
75
|
+
<!-- readme-standards:begin installation.uv -->
|
|
76
|
+
```bash
|
|
77
|
+
uv add swarmauri_transport_httpx
|
|
78
|
+
```
|
|
79
|
+
<!-- readme-standards:end installation.uv -->
|
|
80
|
+
|
|
81
|
+
#### pip
|
|
82
|
+
|
|
83
|
+
<!-- readme-standards:begin installation.pip -->
|
|
84
|
+
```bash
|
|
85
|
+
python -m pip install swarmauri_transport_httpx
|
|
86
|
+
```
|
|
87
|
+
<!-- readme-standards:end installation.pip -->
|
|
88
|
+
|
|
89
|
+
#### Poetry
|
|
90
|
+
|
|
91
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
92
|
+
```bash
|
|
93
|
+
poetry add swarmauri_transport_httpx
|
|
94
|
+
```
|
|
95
|
+
<!-- readme-standards:end installation.poetry -->
|
|
96
|
+
|
|
97
|
+
### Quick Start
|
|
98
|
+
|
|
99
|
+
#### Example
|
|
100
|
+
|
|
101
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
102
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/docs/readme/quick_start.py).
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from swarmauri_transport_httpx import HttpxClient
|
|
106
|
+
|
|
107
|
+
with HttpxClient(base_url="https://api.example.com") as client:
|
|
108
|
+
response = client.request("GET", "/models")
|
|
109
|
+
response.raise_for_status()
|
|
110
|
+
```
|
|
111
|
+
<!-- readme-standards:end example.quick-start -->
|
|
112
|
+
|
|
113
|
+
#### Expected Result
|
|
114
|
+
|
|
115
|
+
The example demonstrates the documented `swarmauri_transport_httpx` source boundary or workflow. Complete its required configuration first. README CI checks the maintained source’s syntax and declarations; it does not claim that external services or the application workflow were exercised.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Usage
|
|
120
|
+
|
|
121
|
+
### Common Workflows
|
|
122
|
+
|
|
123
|
+
<!-- readme-standards:begin example.usage -->
|
|
124
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/docs/readme/usage.py).
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from swarmauri_transport_httpx import HttpxClient
|
|
128
|
+
|
|
129
|
+
with HttpxClient(base_url="https://api.example.com") as client:
|
|
130
|
+
response = client.request("GET", "/models")
|
|
131
|
+
response.raise_for_status()
|
|
132
|
+
```
|
|
133
|
+
<!-- readme-standards:end example.usage -->
|
|
134
|
+
|
|
135
|
+
Use `HttpxClient.request`/`arequest` for buffered responses and `stream`/`astream` for incremental response processing.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
Injected `httpx.Client` and `httpx.AsyncClient` instances remain caller-owned and are never closed by the adapter.
|
|
139
|
+
|
|
140
|
+
### Configuration
|
|
141
|
+
|
|
142
|
+
Configure `swarmauri_transport_httpx` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
143
|
+
|
|
144
|
+
### Error Handling
|
|
145
|
+
|
|
146
|
+
The inspected `swarmauri_transport_httpx` source raises `HttpRequestError`, `HttpStatusError`, `ValueError`. Handle these at the calling boundary and consult the implementation for the triggering conditions.
|
|
147
|
+
|
|
148
|
+
### Best Practices
|
|
149
|
+
|
|
150
|
+
Use the explicit `swarmauri_transport_httpx` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`; an import or successful installation alone does not establish its runtime guarantees.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Package Boundary
|
|
155
|
+
|
|
156
|
+
### What It Owns
|
|
157
|
+
|
|
158
|
+
`swarmauri_transport_httpx` is located in `standards` and owns synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri. Source-declared APIs include `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) records its direct dependency boundary.
|
|
159
|
+
|
|
160
|
+
### Public API and Import Surfaces
|
|
161
|
+
|
|
162
|
+
Import namespace: `swarmauri_transport_httpx`.
|
|
163
|
+
|
|
164
|
+
Source-declared exports or types: `AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`.
|
|
165
|
+
|
|
166
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
167
|
+
|
|
168
|
+
### Entry Points
|
|
169
|
+
|
|
170
|
+
<!-- readme-standards:begin entry-points -->
|
|
171
|
+
- `swarmauri.transports` → `HttpxClient` → `swarmauri_transport_httpx:HttpxClient`
|
|
172
|
+
<!-- readme-standards:end entry-points -->
|
|
173
|
+
|
|
174
|
+
### Injected Dependencies
|
|
175
|
+
|
|
176
|
+
The direct installation dependencies of `swarmauri_transport_httpx` are `httpx`, `swarmauri-core`, `swarmauri-base`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py).
|
|
177
|
+
|
|
178
|
+
### Protocol Consumers
|
|
179
|
+
|
|
180
|
+
Direct consumers in this checkout’s package manifests include `swarmauri_llm_azureopenai`, `swarmauri_llm_cloudflare`, `swarmauri_llm_nvidia_nim`, `swarmauri_llm_openrouter`, `swarmauri_llm_xai`, `swarmauri_workflow_documentassistant`. These edges describe declared dependencies, not protocol-conformance evidence.
|
|
181
|
+
|
|
182
|
+
### Extensions
|
|
183
|
+
|
|
184
|
+
For `swarmauri_transport_httpx`, use the source-declared public interfaces (`AsyncHttpxStreamResponse`, `HttpxClient`, `HttpxResponse`, `HttpxStreamResponse`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Operations and Readiness
|
|
189
|
+
|
|
190
|
+
### Operational Requirements
|
|
191
|
+
|
|
192
|
+
Operate `swarmauri_transport_httpx` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
193
|
+
|
|
194
|
+
### Health and Observability
|
|
195
|
+
|
|
196
|
+
This README does not establish a standalone health endpoint for `swarmauri_transport_httpx`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
197
|
+
|
|
198
|
+
### Security and Resource Limits
|
|
199
|
+
|
|
200
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py). The `swarmauri_transport_httpx` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
201
|
+
|
|
202
|
+
### Compatibility
|
|
203
|
+
|
|
204
|
+
This source version of `swarmauri_transport_httpx` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Verification
|
|
209
|
+
|
|
210
|
+
### Tests
|
|
211
|
+
|
|
212
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_transport_httpx` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
213
|
+
|
|
214
|
+
- [tests/unit/test_httpx_client.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/tests/unit/test_httpx_client.py)
|
|
215
|
+
|
|
216
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
217
|
+
|
|
218
|
+
### Certification Status
|
|
219
|
+
|
|
220
|
+
No external certification is asserted for `swarmauri_transport_httpx` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
221
|
+
|
|
222
|
+
### Evidence
|
|
223
|
+
|
|
224
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## FAQ
|
|
229
|
+
|
|
230
|
+
### Why
|
|
231
|
+
|
|
232
|
+
**Why select this package?** `swarmauri_transport_httpx` provides synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
233
|
+
|
|
234
|
+
### How
|
|
235
|
+
|
|
236
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_transport_httpx`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py) for the exact types and signatures involved.
|
|
237
|
+
|
|
238
|
+
### When
|
|
239
|
+
|
|
240
|
+
**When should I validate an upgrade?** Recheck `swarmauri_transport_httpx` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Documentation and Related Packages
|
|
245
|
+
|
|
246
|
+
### More Documentation
|
|
247
|
+
|
|
248
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/swarmauri_transport_httpx/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml) provide the supporting context for `swarmauri_transport_httpx`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
249
|
+
|
|
250
|
+
### Related Packages
|
|
251
|
+
|
|
252
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
253
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
254
|
+
|
|
255
|
+
### Project Links
|
|
256
|
+
|
|
257
|
+
<!-- readme-standards:begin project-links -->
|
|
258
|
+
- [pypi: swarmauri_transport_httpx](https://pypi.org/project/swarmauri_transport_httpx/)
|
|
259
|
+
<!-- readme-standards:end project-links -->
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Contributing
|
|
264
|
+
|
|
265
|
+
### How to Contribute
|
|
266
|
+
|
|
267
|
+
Follow the [contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md) and include a focused example or regression for changes to `swarmauri_transport_httpx`. Keep package behavior, its documented boundary, and its tests aligned.
|
|
268
|
+
|
|
269
|
+
### Development Setup
|
|
270
|
+
|
|
271
|
+
Work from the `pkgs/40-standards/swarmauri_transport_httpx` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
272
|
+
|
|
273
|
+
### Notes for Maintainers
|
|
274
|
+
|
|
275
|
+
Edit authored prose directly in this `swarmauri_transport_httpx` README. Update source examples in `docs/readme/`, then run `readme-standards render --root . --write` from the package directory and review the diff. Required headings and generated blocks come from package-guide-v1.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Governance
|
|
280
|
+
|
|
281
|
+
### Ownership and Decision Making
|
|
282
|
+
|
|
283
|
+
Changes to `swarmauri_transport_httpx` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
284
|
+
|
|
285
|
+
### Standards and Policies
|
|
286
|
+
|
|
287
|
+
`swarmauri_transport_httpx` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
288
|
+
|
|
289
|
+
### Lifecycle and Migration
|
|
290
|
+
|
|
291
|
+
The `swarmauri_transport_httpx` source version is `0.1.0`.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## License and Attribution
|
|
296
|
+
|
|
297
|
+
### License
|
|
298
|
+
|
|
299
|
+
<!-- readme-standards:begin license -->
|
|
300
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/LICENSE).
|
|
301
|
+
<!-- readme-standards:end license -->
|
|
302
|
+
|
|
303
|
+
### Notices
|
|
304
|
+
|
|
305
|
+
<!-- readme-standards:begin notices -->
|
|
306
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/NOTICE) for attribution.
|
|
307
|
+
<!-- readme-standards:end notices -->
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "swarmauri_transport_httpx"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Synchronous, asynchronous, buffered, and streaming HTTPX transport for Swarmauri."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
8
|
+
license = "Apache-2.0"
|
|
9
|
+
dependencies = ["httpx>=0.27", "swarmauri_core", "swarmauri_base"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 1 - Planning",
|
|
12
|
+
"Programming Language :: Python :: 3.10",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
]
|
|
18
|
+
keywords = ["swarmauri", "httpx", "http", "streaming", "async"]
|
|
19
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
20
|
+
|
|
21
|
+
[tool.uv.sources]
|
|
22
|
+
swarmauri_core = { workspace = true }
|
|
23
|
+
swarmauri_base = { workspace = true }
|
|
24
|
+
|
|
25
|
+
[tool.readme_standards]
|
|
26
|
+
policy = "package-guide-v1"
|
|
27
|
+
readme = "README.md"
|
|
28
|
+
brand = "swarmauri"
|
|
29
|
+
brand_catalog = "../../../tools/readme/brands.toml"
|
|
30
|
+
repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
31
|
+
ref = "master"
|
|
32
|
+
package_path = "pkgs/40-standards/swarmauri_transport_httpx"
|
|
33
|
+
layer = "standards"
|
|
34
|
+
lifecycle = "active"
|
|
35
|
+
license_file = "LICENSE"
|
|
36
|
+
notice_file = "NOTICE"
|
|
37
|
+
|
|
38
|
+
[tool.readme_standards.distributions.pypi]
|
|
39
|
+
name = "swarmauri_transport_httpx"
|
|
40
|
+
published = true
|
|
41
|
+
|
|
42
|
+
[tool.readme_standards.examples.quick_start]
|
|
43
|
+
source = "docs/readme/quick_start.py"
|
|
44
|
+
test = "tests/unit/test_readme_sources.py"
|
|
45
|
+
language = "python"
|
|
46
|
+
expected_exit_code = 0
|
|
47
|
+
|
|
48
|
+
[tool.readme_standards.examples.usage]
|
|
49
|
+
source = "docs/readme/usage.py"
|
|
50
|
+
test = "tests/unit/test_readme_sources.py"
|
|
51
|
+
language = "python"
|
|
52
|
+
expected_exit_code = 0
|
|
53
|
+
|
|
54
|
+
[tool.readme_standards.statuses.readme]
|
|
55
|
+
label = "CI gate"
|
|
56
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
57
|
+
|
|
58
|
+
[tool.readme_standards.statuses.tests]
|
|
59
|
+
label = "example source"
|
|
60
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/tests/unit/test_readme_sources.py"
|
|
61
|
+
|
|
62
|
+
[tool.readme_standards.statuses.certification]
|
|
63
|
+
label = "not certified"
|
|
64
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_transport_httpx/README.md#certification-status"
|
|
65
|
+
|
|
66
|
+
[tool.readme_standards.statuses.governance]
|
|
67
|
+
label = "repository policy"
|
|
68
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"
|
|
69
|
+
|
|
70
|
+
[tool.readme_standards.statuses.evidence]
|
|
71
|
+
label = "source and CI"
|
|
72
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
73
|
+
[project.entry-points."swarmauri.transports"]
|
|
74
|
+
HttpxClient = "swarmauri_transport_httpx:HttpxClient"
|
|
75
|
+
|
|
76
|
+
[build-system]
|
|
77
|
+
requires = ["poetry-core>=1.8.0"]
|
|
78
|
+
build-backend = "poetry.core.masonry.api"
|
|
79
|
+
|
|
80
|
+
[dependency-groups]
|
|
81
|
+
dev = ["pytest>=8.0", "pytest-asyncio>=0.24", "ruff>=0.9.9", "readme-standards==0.1.3; python_version >= \"3.11\""]
|
|
82
|
+
|
|
83
|
+
[tool.ruff]
|
|
84
|
+
extend = "../../pyproject.toml"
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint]
|
|
87
|
+
ignore = ["N999", "SIM117"]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from collections.abc import AsyncIterator
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from pydantic import PrivateAttr
|
|
6
|
+
from swarmauri_base.transports.http.AsyncHttpStreamResponseBase import (
|
|
7
|
+
AsyncHttpStreamResponseBase,
|
|
8
|
+
)
|
|
9
|
+
from swarmauri_core.transports.http_errors import HttpStatusError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AsyncHttpxStreamResponse(AsyncHttpStreamResponseBase):
|
|
13
|
+
_response: Any = PrivateAttr(default=None)
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def from_response(cls, response: Any) -> "AsyncHttpxStreamResponse":
|
|
17
|
+
result = cls(
|
|
18
|
+
status_code=response.status_code,
|
|
19
|
+
headers=dict(response.headers),
|
|
20
|
+
)
|
|
21
|
+
result._response = response
|
|
22
|
+
return result
|
|
23
|
+
|
|
24
|
+
async def aiter_bytes(self) -> AsyncIterator[bytes]:
|
|
25
|
+
async for chunk in self._response.aiter_bytes():
|
|
26
|
+
yield chunk
|
|
27
|
+
|
|
28
|
+
async def aread(self) -> bytes:
|
|
29
|
+
return await self._response.aread()
|
|
30
|
+
|
|
31
|
+
def json(self) -> Any:
|
|
32
|
+
return self._response.json()
|
|
33
|
+
|
|
34
|
+
def raise_for_status(self) -> None:
|
|
35
|
+
try:
|
|
36
|
+
self._response.raise_for_status()
|
|
37
|
+
except httpx.HTTPStatusError as error:
|
|
38
|
+
raise HttpStatusError(
|
|
39
|
+
str(error),
|
|
40
|
+
status_code=self.status_code,
|
|
41
|
+
response=self,
|
|
42
|
+
) from error
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
from collections.abc import AsyncIterator, Iterator, Mapping
|
|
2
|
+
from contextlib import asynccontextmanager, contextmanager
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
from pydantic import Field, PrivateAttr
|
|
7
|
+
from swarmauri_base.transports.http.HttpClientBase import HttpClientBase
|
|
8
|
+
from swarmauri_core.transports.http_errors import HttpRequestError
|
|
9
|
+
from swarmauri_core.transports.i_managed_http_client import IManagedHttpClient
|
|
10
|
+
|
|
11
|
+
from .AsyncHttpxStreamResponse import AsyncHttpxStreamResponse
|
|
12
|
+
from .HttpxResponse import HttpxResponse
|
|
13
|
+
from .HttpxStreamResponse import HttpxStreamResponse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HttpxClient(HttpClientBase, IManagedHttpClient):
|
|
17
|
+
"""Persistent HTTPX adapter for the Swarmauri HTTP client contracts."""
|
|
18
|
+
|
|
19
|
+
client_options: dict[str, Any] = Field(default_factory=dict)
|
|
20
|
+
_sync_client: httpx.Client | None = PrivateAttr(default=None)
|
|
21
|
+
_async_client: httpx.AsyncClient | None = PrivateAttr(default=None)
|
|
22
|
+
_owns_sync_client: bool = PrivateAttr(default=False)
|
|
23
|
+
_owns_async_client: bool = PrivateAttr(default=False)
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
*,
|
|
28
|
+
client: httpx.Client | None = None,
|
|
29
|
+
async_client: httpx.AsyncClient | None = None,
|
|
30
|
+
**data: Any,
|
|
31
|
+
) -> None:
|
|
32
|
+
super().__init__(**data)
|
|
33
|
+
self._sync_client = client
|
|
34
|
+
self._async_client = async_client
|
|
35
|
+
|
|
36
|
+
def _sync(self) -> httpx.Client:
|
|
37
|
+
if self._sync_client is None:
|
|
38
|
+
options = dict(self.client_options)
|
|
39
|
+
options.setdefault("timeout", self.timeout)
|
|
40
|
+
self._sync_client = httpx.Client(**options)
|
|
41
|
+
self._owns_sync_client = True
|
|
42
|
+
return self._sync_client
|
|
43
|
+
|
|
44
|
+
def _async(self) -> httpx.AsyncClient:
|
|
45
|
+
if self._async_client is None:
|
|
46
|
+
options = dict(self.client_options)
|
|
47
|
+
options.setdefault("timeout", self.timeout)
|
|
48
|
+
self._async_client = httpx.AsyncClient(**options)
|
|
49
|
+
self._owns_async_client = True
|
|
50
|
+
return self._async_client
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def _request_kwargs(body: bytes, kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
54
|
+
request_kwargs = dict(kwargs)
|
|
55
|
+
if body:
|
|
56
|
+
if any(
|
|
57
|
+
key in request_kwargs
|
|
58
|
+
for key in ("content", "data", "files", "json")
|
|
59
|
+
):
|
|
60
|
+
raise ValueError(
|
|
61
|
+
"body cannot be combined with content, data, files, "
|
|
62
|
+
"or json"
|
|
63
|
+
)
|
|
64
|
+
request_kwargs["content"] = body
|
|
65
|
+
return request_kwargs
|
|
66
|
+
|
|
67
|
+
def request(
|
|
68
|
+
self,
|
|
69
|
+
method: str,
|
|
70
|
+
path: str,
|
|
71
|
+
*,
|
|
72
|
+
headers: Mapping[str, str] | None = None,
|
|
73
|
+
body: bytes = b"",
|
|
74
|
+
**kwargs: Any,
|
|
75
|
+
) -> HttpxResponse:
|
|
76
|
+
try:
|
|
77
|
+
response = self._sync().request(
|
|
78
|
+
method,
|
|
79
|
+
self.resolve_url(path),
|
|
80
|
+
headers=self.merge_headers(dict(headers or {})),
|
|
81
|
+
**self._request_kwargs(body, kwargs),
|
|
82
|
+
)
|
|
83
|
+
return HttpxResponse.from_response(response)
|
|
84
|
+
except httpx.RequestError as error:
|
|
85
|
+
raise HttpRequestError(str(error)) from error
|
|
86
|
+
|
|
87
|
+
async def arequest(
|
|
88
|
+
self,
|
|
89
|
+
method: str,
|
|
90
|
+
path: str,
|
|
91
|
+
*,
|
|
92
|
+
headers: Mapping[str, str] | None = None,
|
|
93
|
+
body: bytes = b"",
|
|
94
|
+
**kwargs: Any,
|
|
95
|
+
) -> HttpxResponse:
|
|
96
|
+
try:
|
|
97
|
+
response = await self._async().request(
|
|
98
|
+
method,
|
|
99
|
+
self.resolve_url(path),
|
|
100
|
+
headers=self.merge_headers(dict(headers or {})),
|
|
101
|
+
**self._request_kwargs(body, kwargs),
|
|
102
|
+
)
|
|
103
|
+
return HttpxResponse.from_response(response)
|
|
104
|
+
except httpx.RequestError as error:
|
|
105
|
+
raise HttpRequestError(str(error)) from error
|
|
106
|
+
|
|
107
|
+
@contextmanager
|
|
108
|
+
def stream(
|
|
109
|
+
self,
|
|
110
|
+
method: str,
|
|
111
|
+
path: str,
|
|
112
|
+
*,
|
|
113
|
+
headers: Mapping[str, str] | None = None,
|
|
114
|
+
body: bytes = b"",
|
|
115
|
+
**kwargs: Any,
|
|
116
|
+
) -> Iterator[HttpxStreamResponse]:
|
|
117
|
+
try:
|
|
118
|
+
with self._sync().stream(
|
|
119
|
+
method,
|
|
120
|
+
self.resolve_url(path),
|
|
121
|
+
headers=self.merge_headers(dict(headers or {})),
|
|
122
|
+
**self._request_kwargs(body, kwargs),
|
|
123
|
+
) as response:
|
|
124
|
+
yield HttpxStreamResponse.from_response(response)
|
|
125
|
+
except httpx.RequestError as error:
|
|
126
|
+
raise HttpRequestError(str(error)) from error
|
|
127
|
+
|
|
128
|
+
@asynccontextmanager
|
|
129
|
+
async def astream(
|
|
130
|
+
self,
|
|
131
|
+
method: str,
|
|
132
|
+
path: str,
|
|
133
|
+
*,
|
|
134
|
+
headers: Mapping[str, str] | None = None,
|
|
135
|
+
body: bytes = b"",
|
|
136
|
+
**kwargs: Any,
|
|
137
|
+
) -> AsyncIterator[AsyncHttpxStreamResponse]:
|
|
138
|
+
try:
|
|
139
|
+
async with self._async().stream(
|
|
140
|
+
method,
|
|
141
|
+
self.resolve_url(path),
|
|
142
|
+
headers=self.merge_headers(dict(headers or {})),
|
|
143
|
+
**self._request_kwargs(body, kwargs),
|
|
144
|
+
) as response:
|
|
145
|
+
yield AsyncHttpxStreamResponse.from_response(response)
|
|
146
|
+
except httpx.RequestError as error:
|
|
147
|
+
raise HttpRequestError(str(error)) from error
|
|
148
|
+
|
|
149
|
+
def close(self) -> None:
|
|
150
|
+
if self._sync_client is not None and self._owns_sync_client:
|
|
151
|
+
self._sync_client.close()
|
|
152
|
+
self._sync_client = None
|
|
153
|
+
self._owns_sync_client = False
|
|
154
|
+
|
|
155
|
+
async def aclose(self) -> None:
|
|
156
|
+
if self._async_client is not None and self._owns_async_client:
|
|
157
|
+
await self._async_client.aclose()
|
|
158
|
+
self._async_client = None
|
|
159
|
+
self._owns_async_client = False
|
|
160
|
+
|
|
161
|
+
def __enter__(self) -> "HttpxClient":
|
|
162
|
+
return self
|
|
163
|
+
|
|
164
|
+
def __exit__(self, *args: Any) -> None:
|
|
165
|
+
self.close()
|
|
166
|
+
|
|
167
|
+
async def __aenter__(self) -> "HttpxClient":
|
|
168
|
+
return self
|
|
169
|
+
|
|
170
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
171
|
+
await self.aclose()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
from pydantic import PrivateAttr
|
|
7
|
+
from swarmauri_base.transports.http.HttpResponseBase import HttpResponseBase
|
|
8
|
+
from swarmauri_core.transports.http_errors import HttpStatusError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class HttpxResponse(HttpResponseBase):
|
|
12
|
+
_response: Any = PrivateAttr(default=None)
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def from_response(cls, response: Any) -> HttpxResponse:
|
|
16
|
+
result = cls(
|
|
17
|
+
status_code=response.status_code,
|
|
18
|
+
headers=dict(response.headers),
|
|
19
|
+
)
|
|
20
|
+
result._response = response
|
|
21
|
+
result.set_content(response.content)
|
|
22
|
+
return result
|
|
23
|
+
|
|
24
|
+
def raise_for_status(self) -> None:
|
|
25
|
+
try:
|
|
26
|
+
self._response.raise_for_status()
|
|
27
|
+
except httpx.HTTPStatusError as error:
|
|
28
|
+
raise HttpStatusError(
|
|
29
|
+
str(error),
|
|
30
|
+
status_code=self.status_code,
|
|
31
|
+
response=self,
|
|
32
|
+
) from error
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from collections.abc import Iterator
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from pydantic import PrivateAttr
|
|
6
|
+
from swarmauri_base.transports.http.HttpStreamResponseBase import (
|
|
7
|
+
HttpStreamResponseBase,
|
|
8
|
+
)
|
|
9
|
+
from swarmauri_core.transports.http_errors import HttpStatusError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpxStreamResponse(HttpStreamResponseBase):
|
|
13
|
+
_response: Any = PrivateAttr(default=None)
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def from_response(cls, response: Any) -> "HttpxStreamResponse":
|
|
17
|
+
result = cls(
|
|
18
|
+
status_code=response.status_code,
|
|
19
|
+
headers=dict(response.headers),
|
|
20
|
+
)
|
|
21
|
+
result._response = response
|
|
22
|
+
return result
|
|
23
|
+
|
|
24
|
+
def iter_bytes(self) -> Iterator[bytes]:
|
|
25
|
+
yield from self._response.iter_bytes()
|
|
26
|
+
|
|
27
|
+
def read(self) -> bytes:
|
|
28
|
+
return self._response.read()
|
|
29
|
+
|
|
30
|
+
def json(self) -> Any:
|
|
31
|
+
return self._response.json()
|
|
32
|
+
|
|
33
|
+
def raise_for_status(self) -> None:
|
|
34
|
+
try:
|
|
35
|
+
self._response.raise_for_status()
|
|
36
|
+
except httpx.HTTPStatusError as error:
|
|
37
|
+
raise HttpStatusError(
|
|
38
|
+
str(error),
|
|
39
|
+
status_code=self.status_code,
|
|
40
|
+
response=self,
|
|
41
|
+
) from error
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .AsyncHttpxStreamResponse import AsyncHttpxStreamResponse
|
|
2
|
+
from .HttpxClient import HttpxClient
|
|
3
|
+
from .HttpxResponse import HttpxResponse
|
|
4
|
+
from .HttpxStreamResponse import HttpxStreamResponse
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"AsyncHttpxStreamResponse",
|
|
8
|
+
"HttpxClient",
|
|
9
|
+
"HttpxResponse",
|
|
10
|
+
"HttpxStreamResponse",
|
|
11
|
+
]
|