Skip to content

Cookies on response from POST #4

Open

Description

@andrewjtodd

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

Activity

  1. jzdhuang commented on May 17, 2016

    @jzdhuang
    Collaborator
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions