The transport
RequestsTransport implements the HTTP transport contract of pathapi.http:
send() makes one request with a requests.Session and returns an
HTTPResponse, and close() closes a session the transport made.
pathapi.http finds it through the requests entry of its
pathapi.http_transports entry-point group, so
PATHAPI_HTTP_TRANSPORT=requests and
pathapi.http.get_transport("requests") name it.
pathapi_requests.RequestsTransport(session=None, *, proxies=None, **requests_args)
Sends requests with a requests.Session.
session is the session to use (the caller's: close() leaves it open),
or None for a new one that close() closes. proxies is a provider
indexed with the request URL, as the built-in transport takes one: the
answer is a proxy (a URL, or an object with a url), an iterable of them
of which only the first is used, or None for no proxy; KeyError means
no opinion, and then requests decides from the session and the
environment, as it does when proxies is None. A plain dict may use
the keys requests does. requests_args (verify, cert, auth, ...)
are passed to every session.request().
The transport sends one request and follows no redirect. What the session
holds for authentication (auth, an Authorization among its headers,
~/.netrc) is used for the server of the first request only; a request to
any other server carries just the Authorization it was given.
Failures are TimeoutError, ConnectionError, ssl.SSLError, or
OSError(EIO); the text of a requests exception, which can quote a proxy
URL with credentials, is never passed on.
Source code in src/pathapi_requests/_transport.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
session = session if session is not None else self._requests.Session()
instance-attribute
close()
Closes the session if this transport made it, and does so when the transport is collected without having been closed. Harmless when called again.
Source code in src/pathapi_requests/_transport.py
263 264 265 266 267 268 269 | |
send(method, url, *, headers, body=None, timeout, stream=False)
One request, one response, as HTTPTransport.send(); requests'
own trust store and authentication apply.
Source code in src/pathapi_requests/_transport.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |