Really small Python class that extends native http.client.HTTPConnection allowing sending HTTP requests to Unix Sockets
Project description
HTTPUnixSocketConnection
Really small Python class that extends native http.client.HTTPConnection allowing sending HTTP requests to Unix Sockets
Installation
Poetry
poetry add httpunixsocketconnection
pip
pip install httpunixsocketconnection
Usage
Because the class base is http.client.HTTPConnection
, the API is almost the same.
Only the constructor and connect
method is different.
With the rest please follow the official docs.
from httpunixsocketconnection import HTTPUnixSocketConnection
# Create a connection
conn = HTTPUnixSocketConnection(
unix_socket="/var/run/some.unix.socket"
# timeout=Like in HTTPConnection
# blocksize=Like in HTTPConnection
)
Example: Getting list of Docker Containers
from httpunixsocketconnection import HTTPUnixSocketConnection
conn = HTTPUnixSocketConnection("/var/run/docker.sock")
conn.request("GET", "/containers/json")
res = conn.getresponse()
print(res.status, res.reason)
content = res.read().decode("utf-8")
print(content)
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 Distribution
Built Distribution
Close
Hashes for httpunixsocketconnection-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6523c806593c2f8586343c06f372d8b21a913cfe1def9e94b24c5b22cc00e7c7 |
|
MD5 | 9c529d4dbe63cf4d916bacd99e2a6963 |
|
BLAKE2b-256 | 81baf1d84343445ba123483f61153baa00cbe8fbe4881807c6c70d1a3e1e7dff |
Close
Hashes for httpunixsocketconnection-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e8ea3063296951f6c7767552b69837f6be22bb19ba29a7c4ede911e2ff00b7c |
|
MD5 | c6a1506f52610ff6af64db60d489700b |
|
BLAKE2b-256 | 1ff000b795e8c42502de45a30809154877fe594b500bb711584944366003cb45 |