-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post processing of raw response in delegate, like client(,willSendRequest:) #73
Comments
Something like this? What use case do you have in mind? func client(_ client: APIClient, didReceiveResponse response: inout URLResponse, data: Data, task: URLSessionTask) throws |
Yes. Looks what I need. My use case is setting cookies manually. See the code below. func postProcess(_ response: HTTPURLResponse) {
if
let url = response.url,
let fields = response.allHeaderFields as? [String: String]
{
let cookies = HTTPCookie.cookies(
withResponseHeaderFields: fields,
for: url
)
let cookieStorage =
client.session.configuration.httpCookieStorage ?? .shared
for cookie in cookies {
cookieStorage.setCookie(cookie)
}
}
} |
Got it, thanks. Yes, I was thinking about adding a more comprehensive way of monitoring the session. The existing delegate is designed more for customizing the client behavior. By the way, you can use the existing |
Thanks! For the moment I already use validateResponse |
Could you please add method to
APIClientDelegate
for post processing raw response?The text was updated successfully, but these errors were encountered: