Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:pokeb/asi-http-request

Conflicts:
	Classes/ASIHTTPRequest.m
  • Loading branch information...
commit 1a57f92b8bd2f8a58629f856834baeb661f16843 2 parents 762c38c + 1a7ae81
@pokeb pokeb authored
View
6 Classes/ASIInputStream.m
@@ -58,9 +58,11 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len
}
[request performThrottling];
}
- [ASIHTTPRequest incrementBandwidthUsedInLastSecond:toRead];
[readLock unlock];
- return [stream read:buffer maxLength:toRead];
+ NSInteger rv = [stream read:buffer maxLength:toRead];
+ if (rv > 0)
+ [ASIHTTPRequest incrementBandwidthUsedInLastSecond:rv];
+ return rv;
}
/*
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];
Please sign in to comment.
Something went wrong with that request. Please try again.