diff --git a/Classes/ASIDownloadCache.m b/Classes/ASIDownloadCache.m index b0c99909..8cb1e04a 100644 --- a/Classes/ASIDownloadCache.m +++ b/Classes/ASIDownloadCache.m @@ -435,15 +435,19 @@ + (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request return YES; } - -// Borrowed from: http://stackoverflow.com/questions/652300/using-md5-hash-on-a-string-in-cocoa + (NSString *)keyForURL:(NSURL *)url { NSString *urlString = [url absoluteString]; + if ([urlString length] == 0) { + return nil; + } + // Strip trailing slashes so http://allseeing-i.com/ASIHTTPRequest/ is cached the same as http://allseeing-i.com/ASIHTTPRequest if ([[urlString substringFromIndex:[urlString length]-1] isEqualToString:@"/"]) { urlString = [urlString substringToIndex:[urlString length]-1]; } + + // Borrowed from: http://stackoverflow.com/questions/652300/using-md5-hash-on-a-string-in-cocoa const char *cStr = [urlString UTF8String]; unsigned char result[16]; CC_MD5(cStr, (CC_LONG)strlen(cStr), result); diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index 369d4b11..34fa93e8 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-2 2011-06-04"; +NSString *ASIHTTPRequestVersion = @"v1.8.1-4 2011-06-04"; static NSString *defaultUserAgent = nil;