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

NSURLConnection cookies #10

Closed
wolverian opened this issue Dec 31, 2012 · 4 comments
Closed

NSURLConnection cookies #10

wolverian opened this issue Dec 31, 2012 · 4 comments

Comments

@wolverian
Copy link

On iOS, NSURLConnection can (and does) save cookies sent in an HTTP response into storage automatically.

However, using OHHTTPStubs, this does not happen.

I'm setting the cookie with:

[OHHTTPStubs addRequestHandler:^OHHTTPStubsResponse *(NSURLRequest *request, BOOL onlyCheck) {
    return [OHHTTPStubsResponse responseWithData:[NSData dataWithBytes:[@"{}" UTF8String] length:2]
                                      statusCode:200
                                    responseTime:0
                                         headers:@{@"Set-Cookie" : @"JSESSIONID=42C1E2873DD8B2716EEE80DF69221A72"}];
}];

The NSURLConnection object is constructed simply with

[NSURLConnection connectionWithRequest:request delegate:self];

The NSURLConnectionDataDelegate methods are called similarly to what happens with a real connection, so I'm not sure what the cause is.

If there is an architectural reason (that is, the iOS APIs just don't allow OHHTTPStubs to do this), feel free to close this issue.

Thanks for the (otherwise 😄) great library!

@AliSoftware
Copy link
Owner

Thanks for posting this issue! I will look into it ASAP

I recently added Unit Tests to OHHTTPStubs in order to check that it works with various cases, but I didn't add Unit Test Cases about headers and cookies, and I obviously do need to test this special feature!

By the way, feel free to send me a pull request with some Unit Test for your case with cookies if you can, this would be a great addition to extend test coverage and would allow me to directly use it to check if your specific case is solved by my future solution :)

@AliSoftware
Copy link
Owner

My last commit should have fixed the issue regarding cookies, but don't hesitate to try it and check that it fixed your use case correctly and keep me posted about it. Thx!

@wolverian
Copy link
Author

Thank you! That fixed my tests. Thanks for the great support.

@AliSoftware
Copy link
Owner

You're welcome, and thanks for the feedback ;)

(Just commited again a small fix for my previous commit, don't forget to pull it)

AliSoftware added a commit that referenced this issue Nov 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants