Repository navigation
The first release of pathapi-requests: RequestsTransport, the HTTP
transport that sends through a requests.Session, as a distribution of its own.
It needs Python 3.9 or newer, pathapi>=0.1.0,<0.2 and
requests>=2.22.0,<3; its one extra, socks, adds requests[socks] for SOCKS
proxies. Under Changed, the migration from the RequestsTransport of
pathlib-next comes in this order: the table of names, then every change of
behaviour with what to do about it.
It is built on pathapi, which was published as pathlib-next up to 0.10.0 (import
name pathlib_next); the old names below are the ones before the move.
Added
pathapi_requests.RequestsTransportandpathapi_requests.__version__.- The distribution declares the
requestsentry of the
pathapi.http_transportsgroup. Installing it is all that
pathapi.httpneeds to send through it:
HTTPClient(RequestsTransport(session))and
PATHAPI_HTTP_TRANSPORT=requestsuse it,
pathapi.http.get_transport("requests")loads it, and
pathapi.http.transport_names()lists it. RequestsTransport(proxies=provider): an object indexed with the request URL
that answers a proxy (a URL, or an object with aurl),Nonefor no proxy,
or an iterable of them, of which the first is used.KeyErrorleaves the
decision torequests.- A session the transport made is closed when the transport is collected, and a
response that is still open keeps its transport alive, so a dropped transport
leaves no sockets to the garbage collector on anyurllib3. - A
socks4:,socks5:orsocks5h:proxy without PySocks raises
OSError(EPROTONOSUPPORT)namingpathapi-requests[socks]. - The tests
pathapiruns over its own transport run over this one
(python -m pathapi.http.testing --http-transports requests) as part of
the test suite.
Changed
-
Migration from
pathlib-next:Was Is pathlib_next.uri.schemes.http.RequestsTransportpathapi_requests.RequestsTransportRequestsTransport(session=None, **requests_args)RequestsTransport(session=None, *, proxies=None, **requests_args)the extra pathlib-next[http]pip install pathapi-requestsPATHLIB_NEXT_HTTP_TRANSPORT=requeststhe same, read by pathapi.http; this distribution must be installed -
proxiesis a provider and no longer an argument thatrequestsreceives as
it is. Adictkeeps itsrequestsmeaning for the keys"http","https",
"all"and"scheme://host"(aNonevalue is still no proxy); a
"no_proxy"entry of the dict is not read. What to do: putNO_PROXYin the
environment, or answerNonefor those URLs. -
A
requeststhat cannot be imported raises anImportErrorthat names this
distribution, where it named thehttpextra ofpathlib-next. What to do:
reinstallpathapi-requests. -
A
sessionthat is not an object with arequest()method raises
TypeErrorwhere the transport is built. What to do: pass a
requests.Session.
Full Changelog: https://github.com/jose-pr/pathapi-requests/commits/v0.1.0