Interceptor
public protocol Interceptor
Modifies URLRequests
going out and the corresponding URLResponse
coming back in.
Usage e.g. for manipulating header field of an existing request.
-
Intercept the chain (e.g. modify it’s request)
Note
A call tochain.proceed(request:)
is critical when implementing this protocol function.Declaration
Swift
@available(*, deprecated, message: "Use async version instead") func interceptPublisher(chain: Chain) -> AnyPublisher<HTTPResponse, HTTPClientError>
Parameters
chain
request chain to be intercepted
Return Value
AnyPublisher
that emits the response asHTTPClient.Response
-
interceptAsync(chain:
Asynchronous) Intercept the chain (e.g. modify it’s request)
Note
A call tochain.proceed(request:)
is critical when implementing this protocol function.Note
OnlyHTTPClientError
are supposed to be thrown.Declaration
Swift
func interceptAsync(chain: Chain) async throws -> HTTPResponse
Parameters
chain
request chain to be intercepted
Return Value
Response emitted as
HTTPClient.Response
-
intercept(chain:
Extension method) Intercept the chain (e.g. modify it’s request)
Note
A call tochain.proceed(request:)
is critical when implementing this protocol function.Declaration
Swift
@available(*, deprecated, renamed: "interceptPublisher(chain:﹚", message: "Use async version instead") public func intercept(chain: Chain) -> AnyPublisher<HTTPResponse, HTTPClientError>
Parameters
chain
request chain to be intercepted
Return Value
AnyPublisher
that emits the response asHTTPClient.Response