A package that allows for client-side OHTTP-wrapping over HTTP communication
Project description
ohttpy Package
Introduction
This package allows for client-side OHTTP-wrapping over HTTP communication. It acheives this by providing drop-in replacement classes for requests.Session and httpx.BaseTransport classes that abstract the OHTTP layer.
NOTE: This package utilizes a modified Rust library that implements OHTTP and relies on the chunked OHTTP protocol which has not been ratified into a standard at the time of writing.
Optional Parameter Configurability
The ohttpy.Transport and ohttpy.Session class constructors take in the following optional parameters:
- key_config: The OHTTP Key Configuration and its encoding format are defined by OHTTP RFC9458. This configuration contains the OHTTP public key and the set of algorithms for the HPKE context. By default, the classes will fetch the OHTTP Key Configuration dynamically from
{url.scheme}://{url.authority}/discoverwhereurlis the OHTTP Gateway address. This is not the usual flow for OHTTP clients so this parameter allows the user to provide the key configuration.
Requests Session Example
To use OHTTP in a requests.Session setting, simply replace the object construction with ohttpy.Session:
import ohttpy
# Create ohttpy session that inherits from requests.Session.
session = ohttpy.Session()
# Use session like a request.Session including streaming response support.
resp = session.post("http://ohttp-server/path/to/post", data="test data", stream=True)
resp.raise_for_error()
for chunk in resp.iter_content():
if chunk:
print(chunk.decode(), end="", flush=True)
HTTPX Transport Example
To use OHTTP in a httpx.Transport setting, simply replace the object construction with ohttpy.Transport:
import httpx
import ohttpy
# Initialize httpx client with the ohttpy Transport that inherits from httpx.Transport
httpx_client = httpx.Client(transport=ohttpy.Transport())
# Use client as normal including streaming response support.
method = "GET"
url = "http://ohttp-server/path/to/get/"
with httpx_client.stream(method, url) as resp:
resp.raise_for_error()
for chunk in resp.stream:
print(chunk.decode(), end="", flush=True)
This is also applicable to clients that utilize httpx for their HTTP communication, for example openai client:
import httpx
import openai
import ohttpy
# Initialize httpx client with the ohttpy Transport that inherits from httpx.Transport
httpx_client = httpx.Client(transport=ohttpy.Transport())
url = "http://ohttp-server"
api_key = "API_KEY"
# Configure OpenAI client with httpx client
client = openai.OpenAI(
api_key=api_key,
http_client=httpx_client,
base_url=url + "/v1")
# Use OpenAI SDK as normal for example llama chat (including stream capability)
completion = client.chat.completions.create(
model="meta-llama/Llama-3.2-3B-Instruct",
messages=[
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "where does the sun rise from?"},
],
temperature=0.2,
top_p=0.7,
max_tokens=1024,
stream=True,
)
for chunk in completion:
print(chunk.choices[0].delta.content or "", end="", flush=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ohttpy-0.1a13-cp37-abi3-win_amd64.whl.
File metadata
- Download URL: ohttpy-0.1a13-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bdd3ab21050c8baf6cbb8c5398315d732ea282783bd83a99ec7e7f2fd2c5d67
|
|
| MD5 |
f94e757bd86e747be11e30dc51b67a11
|
|
| BLAKE2b-256 |
a535b6c2c83c49cdfd3f4191fb7cb8d0d04602f331aefb679474fef2bdf40bda
|
Provenance
The following attestation bundles were made for ohttpy-0.1a13-cp37-abi3-win_amd64.whl:
Publisher:
CI.yml on lorica-cyber/ohttpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ohttpy-0.1a13-cp37-abi3-win_amd64.whl -
Subject digest:
8bdd3ab21050c8baf6cbb8c5398315d732ea282783bd83a99ec7e7f2fd2c5d67 - Sigstore transparency entry: 194641134
- Sigstore integration time:
-
Permalink:
lorica-cyber/ohttpy@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Branch / Tag:
refs/tags/v0.1a13 - Owner: https://github.com/lorica-cyber
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ohttpy-0.1a13-cp37-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ohttpy-0.1a13-cp37-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.7+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d782fc7ac47f789aa545aa2389145b679b4c89b20f2fbe70cc55fb03f862b69d
|
|
| MD5 |
88450e6f84d3a41e6dd03ec321e85720
|
|
| BLAKE2b-256 |
89c512ac16639bb4c8b746bbfd30347122fd2ed96dcbf2f1aa6e610650b33595
|
Provenance
The following attestation bundles were made for ohttpy-0.1a13-cp37-abi3-manylinux_2_28_aarch64.whl:
Publisher:
CI.yml on lorica-cyber/ohttpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ohttpy-0.1a13-cp37-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
d782fc7ac47f789aa545aa2389145b679b4c89b20f2fbe70cc55fb03f862b69d - Sigstore transparency entry: 194641129
- Sigstore integration time:
-
Permalink:
lorica-cyber/ohttpy@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Branch / Tag:
refs/tags/v0.1a13 - Owner: https://github.com/lorica-cyber
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ohttpy-0.1a13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ohttpy-0.1a13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cde017aebea93f6973e4e5a33b7b634c7ec72eb3e0b8ce8991b76ce684a03a73
|
|
| MD5 |
b09f2f7b3e8f647095c8ef368db3e04c
|
|
| BLAKE2b-256 |
823a7bcd32b25ef44cfcc6b54a213b2557212175f1a21dcdbd0639c110f0d3f8
|
Provenance
The following attestation bundles were made for ohttpy-0.1a13-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
CI.yml on lorica-cyber/ohttpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ohttpy-0.1a13-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
cde017aebea93f6973e4e5a33b7b634c7ec72eb3e0b8ce8991b76ce684a03a73 - Sigstore transparency entry: 194641131
- Sigstore integration time:
-
Permalink:
lorica-cyber/ohttpy@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Branch / Tag:
refs/tags/v0.1a13 - Owner: https://github.com/lorica-cyber
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ohttpy-0.1a13-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ohttpy-0.1a13-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2babdb8162a94a8cf49ed0bb2d37a3f350fd1c845c8332eb7e540d68ddf7770
|
|
| MD5 |
b9952b00085a16a4580f3e9a272e9bba
|
|
| BLAKE2b-256 |
0afaa4b3df41ae71014c4012b219b69ddd6e9e6326f07c6bac9fab1a630e37ae
|
Provenance
The following attestation bundles were made for ohttpy-0.1a13-cp37-abi3-macosx_11_0_arm64.whl:
Publisher:
CI.yml on lorica-cyber/ohttpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ohttpy-0.1a13-cp37-abi3-macosx_11_0_arm64.whl -
Subject digest:
f2babdb8162a94a8cf49ed0bb2d37a3f350fd1c845c8332eb7e540d68ddf7770 - Sigstore transparency entry: 194641133
- Sigstore integration time:
-
Permalink:
lorica-cyber/ohttpy@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Branch / Tag:
refs/tags/v0.1a13 - Owner: https://github.com/lorica-cyber
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ohttpy-0.1a13-cp37-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ohttpy-0.1a13-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
873af8e61e24bda29d59a29e50a4b33d2f5babb6a16459f7048412992814964c
|
|
| MD5 |
b6a9b1837c34852043ee0f383982e5f6
|
|
| BLAKE2b-256 |
108edf517acf8048446330feec8c0643f98368814ac8545cd342029840418027
|
Provenance
The following attestation bundles were made for ohttpy-0.1a13-cp37-abi3-macosx_10_12_x86_64.whl:
Publisher:
CI.yml on lorica-cyber/ohttpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ohttpy-0.1a13-cp37-abi3-macosx_10_12_x86_64.whl -
Subject digest:
873af8e61e24bda29d59a29e50a4b33d2f5babb6a16459f7048412992814964c - Sigstore transparency entry: 194641130
- Sigstore integration time:
-
Permalink:
lorica-cyber/ohttpy@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Branch / Tag:
refs/tags/v0.1a13 - Owner: https://github.com/lorica-cyber
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@b92cec79ea36d20eedfcaf7ebbac46ea784730e2 -
Trigger Event:
push
-
Statement type: