Metadata-Version: 2.4
Name: http_to_wsgi
Version: 1.0.0
Summary: A WSGI handler that takes HTTP/1.x on binary streams and calls a WSGI app
Author: http_to_wsgi contributors
License: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: httptools>=0.6.1

# http_to_wsgi

A WSGI handler that takes HTTP/1.x on binary streams and calls a WSGI app.

Supports PEP 3333 plus the `wsgi.input_terminated` proposal for chunked requests:

- https://gist.github.com/mitsuhiko/5721547

# Install

```bash
python -m pip install -e .
```

# CLI

```bash
http_to_wsgi --app mypkg.wsgi:app --input 0 --output 1
```

# Library

```python
from http_to_wsgi import serve

serve(app, input=0, output=1)
```

`input` and `output` may be integer file descriptors or blocking binary IO objects. Input streams must implement
`read(size) -> bytes`. Output streams must implement `write(bytes)` and may implement `flush()`.

# Notes

- Supports multiple requests on the same stream when the client uses HTTP/1.x keep-alive.
- Request bodies are exposed as a streaming `wsgi.input` with:
  - `wsgi.input_terminated = True`
  - `wsgi.input` reading incrementally until the body terminates

# Build and upload to GDS

The pipeline builds this repository and tests the installed wheel. Run the manual
`upload-to-gds` job on `se/gds-upload`, the default branch, or a tag to upload that wheel, wait for
GDS scanning, publish it, and promote it globally with restricted access.
The build job caches `dist/` under the pipeline ID; the upload job pulls that
same cache. Dependencies are not uploaded.

Set `GDS_PRODUCT_ID`, the MIT `GDS_LICENSE_ID`, and a valid masked, protected
`NEW_GDS_TOKEN` in CI/CD variables. The branch/tag must be protected to access
protected variables. The token needs create, upload, publish, and global-promotion
permissions. Confirm license approval and dependency vulnerability requirements
before uploading; GDS scanning does not replace those checks.

Set `GDS_UPLOAD_ENABLED=false` to disable uploads, or override `GDS_API_URL`
and the matching credentials/product/license IDs to use another environment.
Existing artifacts are never overwritten. For a new release, bump the version in
`pyproject.toml`; after a partial failure, inspect the logged artifact ID in GDS
before retrying.

To finish publication/promotion of an existing uploaded wheel, run a new pipeline
with the same package version and set `GDS_ARTIFACT_ID` on the manual upload job.
This skips creation and byte upload, verifies the artifact's product, filename,
license and restricted access, then publishes/promotes it if needed. Omit this
variable for a new upload.
