k3http
We find that 'httplib' must work in blocking mode and it can not have a timeout when recving response.
k3http is a component of pykit3 project: a python3 toolkit set.
HTTP/1.1 client
Use this module, we can set timeout, if timeout raise a 'socket.timeout'.
Install
pip install k3http
Synopsis
import urllib.parse
import k3http
headers = {
"Host": "127.0.0.1",
"Accept-Language": "en, mi",
}
try:
h = k3http.Client("127.0.0.1", 80)
# send http reqeust without body
# read response status line
# read response headers
h.request("/test.txt", method="GET", headers=headers)
status = h.status
# response code return from http server, type is int
# 200
# 302
# 404
# ...
res_headers = h.headers
# response headers except status line
# res_headers = {
# 'Content-Type': 'text/html;charset=utf-8',
# 'Content-Length': 1024,
# ...
# }
# get response body
print(h.read_body(None))
except (OSError, k3http.HttpError) as e:
print(repr(e))
content = urllib.parse.urlencode({"f": "foo", "b": "bar"})
headers = {
"Host": "www.example.com",
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
"Content-Length": len(content),
}
try:
h = k3http.Client("127.0.0.1", 80)
# send http reqeust
h.send_request("http://www.example.com", method="POST", headers=headers)
# send http request body
h.send_body(content)
# read response status line and headers
status, headers = h.read_response()
# read response body
print(h.read_body(None))
except (OSError, k3http.HttpError) as e:
print(repr(e))
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3http 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| k3http-0.1.10.tar.gz | 15.2 kB | Without provenance | Details for k3http-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| k3http-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for k3http-0.1.10-py3-none-any.whl |
Total release size: 25.2 kB
Release files / k3http-0.1.10.tar.gz
| Download URL | k3http-0.1.10.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a48dc9e74bb66dde573befd922b16e1a13f62e7ad96e119d50559a56c9852a9
|
|
BLAKE2b-256 checksum How to use checksums |
8f3e1015fce5f639c2e6f87c79f4cffdd7d924d57700c7e2130befee4a828529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / k3http-0.1.10-py3-none-any.whl
| Download URL | k3http-0.1.10-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e59a41a98f217cc550f8d8d5243ec832ad4d7fdf37cada47517946cafb4445d2
|
|
BLAKE2b-256 checksum How to use checksums |
7adece7984626d8c9fec48d9ee8043475faa06ccb9b86d9c867743af1dfaa2f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for k3http 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.