Usage
The entrypoint to pyqwest is Client for asyncio applications
and SyncClient for synchronous applications.
Clients are lightweight - while we generally expect you'll initialize them once for your application,
it should generally be fine to even create them per-operation. There is no close type of method on
a client because they share an application-scoped default transport, which is the actual connection
pool. This should feel familiar to those coming from Go's net/http.
With a client, you can use methods corresponding to the HTTP methods, or execute, to issue a request
and get back a full response.
Transport
The default transport is setup to behave closely to a web browser, using standard root certificates
and having timeouts, TCP keepalive, etc configured in a reasonable way, borrowing from the defaults
of the Go net/http package. You may need a custom transport though to configure TLS settings or
timeouts, in which case you create an HTTPTransport or SyncHTTPTransport. Unlike clients, transports
are heavy, with connection pools. Generally you should only create one per application and ensure it
is closed.
TLS
The default transport will use standard root certificates that can access sites served via
https in the same way as a browser would. For internal use cases, you may use certificates
issued by a custom certificate authority. You can initialize an HTTPTransport
or SyncHTTPTransport with a CA certificate for this case.
If using mTLS with client certificates, just add tls_cert and tls_key similarly.
Timeouts
The transport can be configured with timeouts for overall operations, connect, and reads.
The overall operation timeout can also be configured per-call to override the transport's setting. Connect and read timeout cannot be configured per-call.