Skip to content
Browse files

fix issues 233 (Cloud Files header issues) and 234 (leak in Cloud Fil…

…es object request
  • Loading branch information...
1 parent be2c003 commit a879b8ec0466bc1e2ec0f2a5ebbd19bcb1d3dab3 @greenisus greenisus committed
View
2 Classes/ASIHTTPRequest.m
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
-NSString *ASIHTTPRequestVersion = @"v1.8.1-27 2011-08-07";
+NSString *ASIHTTPRequestVersion = @"v1.8.1-28 2011-08-07";
static NSString *defaultUserAgent = nil;
View
2 Classes/CloudFiles/ASICloudFilesCDNRequest.h
@@ -24,10 +24,12 @@
// Response:
// X-CDN-Enabled: True
// X-CDN-URI: http://cdn.cloudfiles.mosso.com/c1234
+// X-CDN-SSL-URI: https://cdn.ssl.cloudfiles.mosso.com/c1234
// X-CDN-TTL: 86400
+ (id)containerInfoRequest:(NSString *)containerName;
- (BOOL)cdnEnabled;
- (NSString *)cdnURI;
+- (NSString *)cdnSSLURI;
- (NSUInteger)cdnTTL;
View
28 Classes/CloudFiles/ASICloudFilesCDNRequest.m
@@ -38,15 +38,35 @@ + (id)containerInfoRequest:(NSString *)containerName {
}
- (BOOL)cdnEnabled {
- return [[[self responseHeaders] objectForKey:@"X-Cdn-Enabled"] boolValue];
+ NSNumber *enabled = [[self responseHeaders] objectForKey:@"X-CDN-Enabled"];
+ if (!enabled) {
+ enabled = [[self responseHeaders] objectForKey:@"X-Cdn-Enabled"];
+ }
+ return [enabled boolValue];
}
- (NSString *)cdnURI {
- return [[self responseHeaders] objectForKey:@"X-Cdn-Uri"];
+ NSString *uri = [[self responseHeaders] objectForKey:@"X-CDN-URI"];
+ if (!uri) {
+ uri = [[self responseHeaders] objectForKey:@"X-Cdn-Uri"];
+ }
+ return uri;
+}
+
+- (NSString *)cdnSSLURI {
+ NSString *uri = [[self responseHeaders] objectForKey:@"X-CDN-SSL-URI"];
+ if (!uri) {
+ uri = [[self responseHeaders] objectForKey:@"X-Cdn-Ssl-Uri"];
+ }
+ return uri;
}
- (NSUInteger)cdnTTL {
- return [[[self responseHeaders] objectForKey:@"X-Ttl"] intValue];
+ NSNumber *ttl = [[self responseHeaders] objectForKey:@"X-TTL"];
+ if (!ttl) {
+ ttl = [[self responseHeaders] objectForKey:@"X-Ttl"];
+ }
+ return [ttl intValue];
}
#pragma mark -
@@ -130,7 +150,7 @@ + (id)postRequestWithContainer:(NSString *)containerName cdnEnabled:(BOOL)cdnEna
if (ttl > 0) {
[request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", ttl]];
}
- [request addRequestHeader:@"X-Cdn-Enabled" value:cdnEnabled ? @"True" : @"False"];
+ [request addRequestHeader:@"X-CDN-Enabled" value:cdnEnabled ? @"True" : @"False"];
return request;
}
View
2 Classes/CloudFiles/ASICloudFilesObjectRequest.m
@@ -130,7 +130,7 @@ - (ASICloudFilesObject *)object {
object.bytes = [[[self responseHeaders] objectForKey:@"Content-Length"] intValue];
object.contentType = [[self responseHeaders] objectForKey:@"Content-Type"];
object.lastModified = [[self responseHeaders] objectForKey:@"Last-Modified"];
- object.metadata = [[NSMutableDictionary alloc] init];
+ object.metadata = [NSMutableDictionary dictionary];
for (NSString *key in [[self responseHeaders] keyEnumerator]) {
NSRange metaRange = [key rangeOfString:@"X-Object-Meta-"];
View
8 Classes/CloudFiles/ASICloudFilesRequest.m
@@ -69,7 +69,13 @@ + (NSError *)authenticate
NSDictionary *responseHeaders = [request responseHeaders];
authToken = [responseHeaders objectForKey:@"X-Auth-Token"];
storageURL = [responseHeaders objectForKey:@"X-Storage-Url"];
- cdnManagementURL = [responseHeaders objectForKey:@"X-Cdn-Management-Url"];
+ cdnManagementURL = [responseHeaders objectForKey:@"X-CDN-Management-Url"];
+
+ // there is a bug in the Cloud Files API for some older accounts that causes
+ // the CDN URL to come back in a slightly different header
+ if (!cdnManagementURL) {
+ cdnManagementURL = [responseHeaders objectForKey:@"X-Cdn-Management-Url"];
+ }
}
[accessDetailsLock unlock];
return [request error];

0 comments on commit a879b8e

Please sign in to comment.
Something went wrong with that request. Please try again.