The following protocols are available globally.
HTTPClientResponseDelegateallows an implementation to receive notifications about request processing and to control how response parts are processed. You can implement this protocol if you need fine-grained control over an HTTP request/response, for example, if you want to inspect the response headers before deciding whether to accept a response body, or if you want to stream your request body. Pass an instance of your conforming class to the
HTTPClient.execute()method and this package will call each delegate method appropriately as the request takes place.
NoteThis delegate is strongly held by the
HTTPTaskHandlerfor the duration of the
Requestprocessing and will be released together with the
HTTPTaskHandlerwhen channel is closed. Users of the library are not required to keep a reference to the object that implements this protocol, but may do so if needed.
public protocol HTTPClientResponseDelegate : AnyObject