You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VCRURLConnection is an iOS and OSX API to record and replay HTTP interactions, inspired by VCR
VCRURLConnection is still in the very early stages of development, all bug reports, feature requests, and general feedback are greatly appreciated!
Recording
[VCR start];
NSString *path = @"https://example.com/example";
NSURL *url = [NSURLURLWithString:path];
NSURLRequest *request = [NSURLRequestrequestWithURL:url];
// use either NSURLSession or NSURLConnectionNSURLSessionDataTask *task = [[NSURLSessionsharedSession] dataTaskWithRequest:request];
[task resume];
// NSURLSession makes a real network request and VCRURLConnection// will record the request/response pair.// once async request is complete or application is ready to exit:
[VCR save:@"/path/to/cassette.json"]; // copy the output file into your project
Replaying
NSURL *cassetteURL = [NSURLfileURLWithPath:@"/path/to/cassette.json"];
[VCR loadCassetteWithContentsOfURL:cassetteURL];
[VCR start];
// request an HTTP interaction that was recorded to cassette.jsonNSString *path = @"https://example.com/example";
NSURL *url = [NSURLURLWithString:path];
NSURLRequest *request = [NSURLRequestrequestWithURL:url];
// use either NSURLSession or NSURLConnectionNSURLSessionDataTask *task = [[NSURLSessionsharedSession] dataTaskWithRequest:request];
[task resume];
// The cassette has a recording for this request, so no network request// is made. Instead NSURLConnectionDelegate methods are called with the// previously recorded response.