Skip to content
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

Cookies on response from POST #4

Open
andrewjtodd opened this issue May 16, 2016 · 1 comment
Open

Cookies on response from POST #4

andrewjtodd opened this issue May 16, 2016 · 1 comment

Comments

@andrewjtodd
Copy link

Hi,
Is is possible with your library to actually get cookies from a response? See here for an example of the problem I'm trying to solve.
Alamofire/Alamofire#946
Thanks

@rawrjustin
Copy link
Collaborator

rawrjustin commented May 17, 2016

class CookieInterceptor: NSObject, ResponseInterceptor {

    func process<ReturnType>(endpoint: Endpoint<ReturnType>, response: NSHTTPURLResponse?, responseObject: ResponseObject) -> ProcessResults {
        print(response)

        for cookie in NSHTTPCookieStorage.sharedHTTPCookieStorage().cookiesForURL(response!.URL!)! {
            print(cookie)
        }
        return ProcessResults(true, nil)
    }
}

An interceptor like this should print the cookies, you would need to be pointing your build against the dev branch however. You also need to make sure to set your acceptsCookies param on your endpoint to true

This is tested against https://httpbin.org/cookies/set?k2=v2&k1=v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants