Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

WebDav Response Namespace not always 'D' #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AFWebDAVManager/AFWebDAVManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 13 additions & 10 deletions AFWebDAVManager/AFWebDAVManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}];
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 -
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions AFWebDAVManager.podspec → BPWebDAVManager.podspec
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]" }
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
Expand All @@ -16,4 +16,4 @@ Pod::Spec.new do |s|

s.dependency 'AFNetworking', '~> 2.4'
s.dependency 'Ono', '~> 1.1'
end
end