diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index ac60806d..07f84199 100644 --- a/Classes/ASIHTTPRequest.m +++ b/Classes/ASIHTTPRequest.m @@ -24,7 +24,7 @@ #import "ASIDataCompressor.h" // Automatically set on build -NSString *ASIHTTPRequestVersion = @"v1.8.1-23 2011-08-06"; +NSString *ASIHTTPRequestVersion = @"v1.8.1-26 2011-08-06"; static NSString *defaultUserAgent = nil; diff --git a/Classes/Tests/ASIDownloadCacheTests.m b/Classes/Tests/ASIDownloadCacheTests.m index 926ff091..6d10e0f9 100644 --- a/Classes/Tests/ASIDownloadCacheTests.m +++ b/Classes/Tests/ASIDownloadCacheTests.m @@ -506,4 +506,33 @@ - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL [request redirectToURL:newURL]; } +- (void)testCachedFileOverwritten +{ + // Test for https://github.com/pokeb/asi-http-request/pull/211 + // This test ensures that items in the cache are correctly overwritten when a downloadDestinationPath is set, + // and they need to be copied to the cache at the end of the request + + // This url returns different content every time + NSURL *url = [NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/random-content"]; + ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; + [request setDownloadCache:[ASIDownloadCache sharedCache]]; + [request setSecondsToCache:0.5f]; + [request startSynchronous]; + + NSString *path = [[ASIDownloadCache sharedCache] pathToCachedResponseDataForURL:url]; + NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; + + sleep(1); + + request = [ASIHTTPRequest requestWithURL:url]; + [request setDownloadCache:[ASIDownloadCache sharedCache]]; + [request setDownloadDestinationPath:[[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:@"test.html"]]; + [request startSynchronous]; + + NSString *content2 = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; + + BOOL success = ![content isEqualToString:content2]; + GHAssertTrue(success, @"Failed to overwrite response in cache"); +} + @end diff --git a/Mac.xcodeproj/project.pbxproj b/Mac.xcodeproj/project.pbxproj index f611caba..6ef6fb53 100644 --- a/Mac.xcodeproj/project.pbxproj +++ b/Mac.xcodeproj/project.pbxproj @@ -443,7 +443,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0410; + LastUpgradeCheck = 0420; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Mac" */; compatibilityVersion = "Xcode 3.2";