Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpunixsocketconnection-1.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpunixsocketconnection-1.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file httpunixsocketconnection-1.0.1.tar.gz.

File metadata

  • Download URL: httpunixsocketconnection-1.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.14.0-1027-oem

File hashes

Hashes for httpunixsocketconnection-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6523c806593c2f8586343c06f372d8b21a913cfe1def9e94b24c5b22cc00e7c7
MD5 9c529d4dbe63cf4d916bacd99e2a6963
BLAKE2b-256 81baf1d84343445ba123483f61153baa00cbe8fbe4881807c6c70d1a3e1e7dff

See more details on using hashes here.

File details

Details for the file httpunixsocketconnection-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for httpunixsocketconnection-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e8ea3063296951f6c7767552b69837f6be22bb19ba29a7c4ede911e2ff00b7c
MD5 c6a1506f52610ff6af64db60d489700b
BLAKE2b-256 1ff000b795e8c42502de45a30809154877fe594b500bb711584944366003cb45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page