Konnect Curl Core (konnect.curl)ο
Konnectο
Konnect is a project to make the power of the libcurl multi feature available through a Pythonic interface. It consists of this core package (konnect.curl) through which any protocol provided by libcurl can be accessed and some additional packages (e.g. konnect.http) which provide enhanced interfaces for specific protocols.
Basic Usageο
Users must first create a class that implements the RequestProtocol
interface; the methods of this protocol are essentially hooks that are called at certain
points in a transfer. The transfer commences when an instance of the request class is
passed to Multi.process() and the returned awaitable is awaited:
configure_handleis called prior to connection with a singleConfigHandleobject as an argument. This object can be used to configure the request in a manner familiar to users of libcurl, by calling theConfigHandle.setopt()method of the object. In particular users should configure libcurl callbacks to handle various additional events specific to the desired protocol.has_update&get_updateare called continuously throughout the transfer. The latter, if it returns anything, interrupts the transfer and returns the value fromMulti.process(). The user would normally then continue the transfer by callingMulti.process()again with the same multi and request objects. It is up to the user to recognise when the return is an interim response or a final response, normally by checking the type of the response. If the implementation has nothing to return during the transferhas_updatecan simply returnFalseevery time it is called.completedis called after the transfer is finished, with aGetInfoHandleobject that may be used to examine information about the transfer in a way familiar to libcurl users, with itβsGetInfoHandle.getinfo()andGetInfoHandle.getinfo_raw()methods.
Instances of Multi are shareable within a thread and although it is possible
to use multiple instances it is recommended for performance and resource usage reasons to
use only one.