From c25abdb71e07897212b44212e2d854e744a64048 Mon Sep 17 00:00:00 2001 From: Justin Carstens Date: Thu, 9 Jul 2015 12:15:18 -0700 Subject: [PATCH 1/3] WebDav Response Namespace not always 'D' I removed the inNamespace:@"D" for the AFWebDAVMultiStatusResponse because the response does not always use the "D" Namespace I found that Microsoft servers use the namespace "a". Information on Microsoft webdav https://msdn.microsoft.com/en-us/library/ms879496(v=exchg.65).aspx I testested with an "a" namespace and a "D" namespace server and there were no issues. --- AFWebDAVManager/AFWebDAVManager.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AFWebDAVManager/AFWebDAVManager.m b/AFWebDAVManager/AFWebDAVManager.m index 060ea96..b159e6d 100644 --- a/AFWebDAVManager/AFWebDAVManager.m +++ b/AFWebDAVManager/AFWebDAVManager.m @@ -532,8 +532,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 +548,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; } From 16a5515c5b0ea2cf416d77a88a0675a8d5910a92 Mon Sep 17 00:00:00 2001 From: Justin Carstens Date: Wed, 24 May 2017 10:28:36 -0700 Subject: [PATCH 2/3] Updated podspec --- AFWebDAVManager/AFWebDAVManager.h | 2 +- AFWebDAVManager/AFWebDAVManager.m | 11 +++++++---- AFWebDAVManager.podspec => BPWebDAVManager.podspec | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) rename AFWebDAVManager.podspec => BPWebDAVManager.podspec (78%) 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 b159e6d..765b85f 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 - 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 From 38d1d7703f54314be3efceac021c959b592f206e Mon Sep 17 00:00:00 2001 From: Justin Carstens Date: Thu, 22 Jun 2017 11:56:07 -0700 Subject: [PATCH 3/3] Remove ":" at end of Content Type --- AFWebDAVManager/AFWebDAVManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFWebDAVManager/AFWebDAVManager.m b/AFWebDAVManager/AFWebDAVManager.m index 765b85f..6ad009c 100644 --- a/AFWebDAVManager/AFWebDAVManager.m +++ b/AFWebDAVManager/AFWebDAVManager.m @@ -293,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];