The next generation HTTP client.
Project description
HTTPX - A next-generation HTTP client for Python.
Note: This project should be considered as an "alpha" release. It is substantially API complete, but there are still some areas that need more work.
Let's get started...
>>> import httpx
>>> r = httpx.get('https://www.example.org/')
>>> r
<Response [200 OK]>
>>> r.status_code
200
>>> r.http_version
'HTTP/1.1'
>>> r.headers['content-type']
'text/html; charset=UTF-8'
>>> r.text
'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>...'
Features
HTTPX builds on the well-established usability of requests, and gives you:
- A requests-compatible API.
- HTTP/2 and HTTP/1.1 support.
- Support for issuing HTTP requests in parallel. (Coming soon)
- Standard synchronous interface, but with
async/awaitsupport if you need it. - Ability to make requests directly to WSGI or ASGI applications.
- Strict timeouts everywhere.
- Fully type annotated.
- 100% test coverage.
Plus all the standard features of requests...
- International Domains and URLs
- Keep-Alive & Connection Pooling
- Sessions with Cookie Persistence
- Browser-style SSL Verification
- Basic/Digest Authentication
- Elegant Key/Value Cookies
- Automatic Decompression
- Automatic Content Decoding
- Unicode Response Bodies
- Multipart File Uploads
- HTTP(S) Proxy Support (TODO)
- Connection Timeouts
- Streaming Downloads
- .netrc Support
- Chunked Requests
Installation
Install with pip:
$ pip install httpx
httpx requires Python 3.6+
Documentation
Project documentation is available at www.encode.io/httpx/.
For a run-through of all the basics, head over to the QuickStart.
For more advanced topics, see the Advanced Usage section, or the specific topics on making Parallel Requests or using the Async Client.
The Developer Interface provides a comprehensive API reference.
Contribute
If you want to contribute with HTTPX check out the Contributing Guide to learn how to start.
Dependencies
The httpx project relies on these excellent libraries:
h2- HTTP/2 support.h11- HTTP/1.1 support.certifi- SSL certificates.chardet- Fallback auto-detection for response encoding.hstspreload- determines whether IDNA-encoded host should be only accessed via HTTPS.idna- Internationalized domain name support.rfc3986- URL parsing & normalization.brotlipy- Decoding for "brotli" compressed responses. (Optional)
A huge amount of credit is due to requests for the API layout that
much of this work follows, as well as to urllib3 for plenty of design
inspiration around the lower-level networking details.
— ⭐️ —
HTTPX is BSD licensed code. Designed & built in Brighton, England.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
0.7.7 (November 15, 2019)
Fixed
- Resolve an issue with cookies behavior on redirect requests. (Pull #529)
Added
- Add request/response DEBUG logs. (Pull #502)
- Use TRACE log level for low level info. (Pull #500)
0.7.6 (November 2, 2019)
Removed
- Drop
proxiesparameter from the high-level API. (Pull #485)
Fixed
- Tweak multipart files: omit null filenames, add support for
strfile contents. (Pull #482) - Cache NETRC authentication per-client. (Pull #400)
- Rely on
getproxiesfor all proxy environment variables. (Pull #470) - Wait for the
asynciostream to close when closing a connection. (Pull #494)
0.7.5 (October 10, 2019)
Added
- Allow lists of values to be passed to
params. (Pull #386) ASGIDispatch,WSGIDispatchare now available in thehttpx.dispatchnamespace. (Pull #407)HTTPErroris now available in thehttpxnamespace. (Pull #421)- Add support for
start_tls()to the Trio concurrency backend. (Pull #467)
Fixed
- Username and password are no longer included in the
Hostheader when basic authentication credentials are supplied via the URL. (Pull #417)
Removed
- The
.delete()function no longer hasjson,data, orfilesparameters to match the expected semantics of theDELETEmethod. (Pull #408) - Removed the
trioextra. Trio support is detected automatically. (Pull #390)
0.7.4 (September 25, 2019)
Added
- Add Trio concurrency backend. (Pull #276)
- Add
paramsparameter toClientfor setting default query parameters. (Pull #372) - Add support for
SSL_CERT_FILEandSSL_CERT_DIRenvironment variables. (Pull #307) - Add debug logging to calls into ASGI apps. (Pull #371)
- Add debug logging to SSL configuration. (Pull #378)
Fixed
- Fix a bug when using
Clientwithout timeouts in Python 3.6. (Pull #383) - Propagate
Clientconfiguration to HTTP proxies. (Pull #377)
0.7.3 (September 20, 2019)
Added
- HTTP Proxy support. (Pulls #259, #353)
- Add Digest authentication. (Pull #332)
- Add
.build_request()method toClientandAsyncClient. (Pull #319) - Add
.elapsedproperty on responses. (Pull #351) - Add support for
SSLKEYLOGFILEin Python 3.8b4+. (Pull #301)
Removed
- Drop NPN support for HTTP version negotiation. (Pull #314)
Fixed
- Fix distribution of type annotations for mypy (Pull #361).
- Set
Hostheader when redirecting cross-origin. (Pull #321) - Drop
Content-Lengthheaders onGETredirects. (Pull #310) - Raise
KeyErrorif header isn't found inHeaders. (Pull #324) - Raise
NotRedirectResponseinresponse.next()if there is no redirection to perform. (Pull #297) - Fix bug in calculating the HTTP/2 maximum frame size. (Pull #153)
0.7.2 (August 28, 2019)
- Enforce using
httpx.AsyncioBackendfor the synchronous client. (Pull #232) httpx.ConnectionPoolwill properly release a dropped connection. (Pull #230)- Remove the
raise_app_exceptionsargument fromClient. (Pull #238) DecodeErrorwill no longer be raised for an empty body encoded with Brotli. (Pull #237)- Added
http_versionsparameter toClient. (Pull #250) - Only use HTTP/1.1 on short-lived connections like
httpx.get(). (Pull #284) - Convert
Client.cookiesandClient.headerswhen set as a property. (Pull #274) - Setting
HTTPX_DEBUG=1enables debug logging on all requests. (Pull #277)
0.7.1 (August 18, 2019)
- Include files with source distribution to be installable. (Pull #233)
0.7.0 (August 17, 2019)
- Add the
trust_envproperty toBaseClient. (Pull #187) - Add the
linksproperty toBaseResponse. (Pull #211) - Accept
ssl.SSLContextinstances intoSSLConfig(verify=...). (Pull #215) - Add
Response.stream_text()with incremental encoding detection. (Pull #183) - Properly updated the
Hostheader when a redirect changes the origin. (Pull #199) - Ignore invalid
Content-Encodingheaders. (Pull #196) - Use
~/.netrcand~/_netrcfiles by default whentrust_env=True. (Pull #189) - Create exception base class
HTTPErrorwithrequestandresponseproperties. (Pull #162) - Add HSTS preload list checking within
BaseClientto upgrade HTTP URLs to HTTPS. (Pull #184) - Switch IDNA encoding from IDNA 2003 to IDNA 2008. (Pull #161)
- Expose base classes for alternate concurrency backends. (Pull #178)
- Improve Multipart parameter encoding. (Pull #167)
- Add the
headersproeprty toBaseClient. (Pull #159) - Add support for Google's
brotlilibrary. (Pull #156) - Remove deprecated TLS versions (TLSv1 and TLSv1.1) from default
SSLConfig. (Pull #155) - Fix
URL.join(...)to work similarly to RFC 3986 URL joining. (Pull #144)
0.6.8 (July 25, 2019)
- Check for disconnections when searching for an available
connection in
ConnectionPool.keepalive_connections(Pull #145) - Allow string comparison for
URLobjects (Pull #139) - Add HTTP status codes 418 and 451 (Pull #135)
- Add support for client certificate passwords (Pull #118)
- Enable post-handshake client cert authentication for TLSv1.3 (Pull #118)
- Disable using
commonNamefor hostname checking for OpenSSL 1.1.0+ (Pull #118) - Detect encoding for
Response.json()(Pull #116)
0.6.7 (July 8, 2019)
- Check for connection aliveness on re-acquiry (Pull #111)
0.6.6 (July 3, 2019)
- Improve
USER_AGENT(Pull #110) - Add
Connection: keep-aliveby default to HTTP/1.1 connections. (Pull #110)
0.6.5 (June 27, 2019)
- Include
Hostheader by default. (Pull #109) - Improve HTTP protocol detection. (Pull #107)
0.6.4 (June 25, 2019)
- Implement read and write timeouts (Pull #104)
0.6.3 (June 24, 2019)
- Handle early connection closes (Pull #103)
0.6.2 (June 23, 2019)
- Use urllib3's
DEFAULT_CIPHERSfor theSSLConfigobject. (Pull #100)
0.6.1 (June 21, 2019)
- Add support for setting a
base_urlon theClient.
0.6.0 (June 21, 2019)
- Honor
local_flow_control_windowfor HTTP/2 connections (Pull #98)
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
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 httpx-0.7.7.tar.gz.
File metadata
- Download URL: httpx-0.7.7.tar.gz
- Upload date:
- Size: 60.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97646a1ce129ce0b5b53934615a6f6236f08d43666b450c3974433d0e717ecfb
|
|
| MD5 |
769d75aafec2946ae88fd360824b7e88
|
|
| BLAKE2b-256 |
79dcf657c02118b360358453784810a08c957b4e92c31871b0b11ab3db365aca
|
File details
Details for the file httpx-0.7.7-py2.py3-none-any.whl.
File metadata
- Download URL: httpx-0.7.7-py2.py3-none-any.whl
- Upload date:
- Size: 69.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26ed044a022df971fe599a256036eaf621353e3135fffa1d9e72338d9bd60e08
|
|
| MD5 |
8ee8bda973b59cc10c6c30c500b53383
|
|
| BLAKE2b-256 |
44e386ad094d8d0de731e0a63bdec3f2176eb38c7af78c4a4bd24e7b1abc1a97
|