diff --git a/AFWebDAVManager/AFWebDAVManager.h b/AFWebDAVManager/AFWebDAVManager.h index 780d909..9d562dc 100644 --- a/AFWebDAVManager/AFWebDAVManager.h +++ b/AFWebDAVManager/AFWebDAVManager.h @@ -66,7 +66,7 @@ typedef NS_ENUM(NSUInteger, AFWebDAVLockScope) { */ - (void)contentsOfDirectoryAtURLString:(NSString *)URLString recursive:(BOOL)recursive - completionHandler:(void (^)(NSArray *items, NSError *error))completionHandler; + completionHandler:(void (^)(NSArray *items, AFHTTPRequestOperation *operation, NSError *error))completionHandler; /** Creates a directory at the path represented by the specified URL string. diff --git a/AFWebDAVManager/AFWebDAVManager.m b/AFWebDAVManager/AFWebDAVManager.m index 060ea96..6ad009c 100644 --- a/AFWebDAVManager/AFWebDAVManager.m +++ b/AFWebDAVManager/AFWebDAVManager.m @@ -85,15 +85,15 @@ - (instancetype)initWithBaseURL:(NSURL *)url { - (void)contentsOfDirectoryAtURLString:(NSString *)URLString recursive:(BOOL)recursive - completionHandler:(void (^)(NSArray *items, NSError *error))completionHandler + completionHandler:(void (^)(NSArray *items, AFHTTPRequestOperation *operation, NSError *error))completionHandler { [self PROPFIND:URLString propertyNames:nil depth:(recursive ? AFWebDAVInfinityDepth : AFWebDAVOneDepth) success:^(__unused AFHTTPRequestOperation *operation, id responseObject) { if (completionHandler) { - completionHandler(responseObject, nil); + completionHandler(responseObject, operation, nil); } } failure:^(__unused AFHTTPRequestOperation *operation, NSError *error) { if (completionHandler) { - completionHandler(nil, error); + completionHandler(nil, operation, error); } }]; } @@ -217,7 +217,7 @@ - (void)copyItemAtURLString:(NSString *)originURLString - (void)contentsOfFileAtURLString:(NSString *)URLString completionHandler:(void (^)(NSData *contents, NSError *error))completionHandler { - [self GET:URLString parameters:nil success:^(AFHTTPRequestOperation *operation, __unused id responseObject) { + AFHTTPRequestOperation *operation = [self GET:URLString parameters:nil success:^(AFHTTPRequestOperation *operation, __unused id responseObject) { if (completionHandler) { completionHandler(operation.responseData, nil); } @@ -226,6 +226,9 @@ - (void)contentsOfFileAtURLString:(NSString *)URLString completionHandler(nil, error); } }]; + [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { + NSLog(@"%lu ----- %lld ------ %lld", (unsigned long)bytesRead, totalBytesRead, totalBytesExpectedToRead); + }]; } #pragma mark - @@ -290,7 +293,7 @@ - (AFHTTPRequestOperation *)PROPFIND:(NSString *)URLString NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PROPFIND" URLString:[[self.baseURL URLByAppendingPathComponent:URLString] absoluteString] parameters:nil error:nil]; [request setValue:AFWebDAVStringForDepth(depth) forHTTPHeaderField:@"Depth"]; - [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type:"]; + [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:[mutableXMLString dataUsingEncoding:NSUTF8StringEncoding]]; AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; @@ -532,8 +535,8 @@ @implementation AFWebDAVMultiStatusResponse - (instancetype)initWithResponseElement:(ONOXMLElement *)element { NSParameterAssert(element); - NSString *href = [[element firstChildWithTag:@"href" inNamespace:@"D"] stringValue]; - NSInteger status = [[[element firstChildWithTag:@"status" inNamespace:@"D"] numberValue] integerValue]; + NSString *href = [[element firstChildWithTag:@"href"] stringValue]; + NSInteger status = [[[element firstChildWithTag:@"status"] numberValue] integerValue]; self = [self initWithURL:[NSURL URLWithString:href] statusCode:status HTTPVersion:@"HTTP/1.1" headerFields:nil]; if (!self) { @@ -548,9 +551,9 @@ - (instancetype)initWithResponseElement:(ONOXMLElement *)element { } } - self.contentLength = [[[propElement firstChildWithTag:@"getcontentlength" inNamespace:@"D"] numberValue] unsignedIntegerValue]; - self.creationDate = [[propElement firstChildWithTag:@"creationdate" inNamespace:@"D"] dateValue]; - self.lastModifiedDate = [[propElement firstChildWithTag:@"getlastmodified" inNamespace:@"D"] dateValue]; + self.contentLength = [[[propElement firstChildWithTag:@"getcontentlength"] numberValue] unsignedIntegerValue]; + self.creationDate = [[propElement firstChildWithTag:@"creationdate"] dateValue]; + self.lastModifiedDate = [[propElement firstChildWithTag:@"getlastmodified"] dateValue]; return self; } diff --git a/AFWebDAVManager.podspec b/BPWebDAVManager.podspec similarity index 78% rename from AFWebDAVManager.podspec rename to BPWebDAVManager.podspec index f177f66..5d9a0a4 100644 --- a/AFWebDAVManager.podspec +++ b/BPWebDAVManager.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| - s.name = "AFWebDAVManager" + s.name = "BPWebDAVManager" s.version = "0.0.1" s.summary = "AFNetworking extension for WebDAV" s.homepage = "https://github.com/AFNetworking/AFWebDAVManager" s.social_media_url = "https://twitter.com/AFNetworking" s.license = 'MIT' s.author = { "Mattt Thompson" => "m@mattt.me" } - s.source = { :git => "https://github.com/AFNetworking/AFWebDAVManager.git", :tag => "0.0.1" } + s.source = { :git => "https://github.com/BitSuites/AFWebDAVManager.git", :tag => "0.0.1" } s.source_files = 'AFWebDAVManager' s.requires_arc = true @@ -16,4 +16,4 @@ Pod::Spec.new do |s| s.dependency 'AFNetworking', '~> 2.4' s.dependency 'Ono', '~> 1.1' -end +end \ No newline at end of file