Permalink
Browse files

WebDAV additions and fixes.

  • Loading branch information...
1 parent 0c836ab commit f3872b0f05057a3fb3fa2f27b5c200e830e0566d @ccgus committed May 25, 2011
Showing with 26 additions and 7 deletions.
  1. +7 −0 WebDAV/FMWebDAVRequest.h
  2. +19 −7 WebDAV/FMWebDAVRequest.m
@@ -43,6 +43,13 @@ enum {
FMHTTPNotImplementedErrorCode = 501,
};
+
+extern NSString *FMWebDAVContentTypeKey;
+extern NSString *FMWebDAVETagKey;
+extern NSString *FMWebDAVHREFKey;
+extern NSString *FMWebDAVURIKey;
+
+
@class FMWebDAVRequest;
@interface FMWebDAVRequest : NSObject <NSXMLParserDelegate> {
@@ -17,6 +17,11 @@
NSString * const FMWebDAVRequestTestResponseCode = @"FMWebDAVRequestTestResponseCode";
NSString * const FMWebDAVRequestTestPayloadURL = @"FMWebDAVRequestTestPayloadURL";
+NSString *FMWebDAVContentTypeKey = @"contenttype";
+NSString *FMWebDAVETagKey = @"etag";
+NSString *FMWebDAVHREFKey = @"href";
+NSString *FMWebDAVURIKey = @"uri";
+
static NSMutableArray *FMWebDAVRequestTestResponses = nil;
@interface FMWebDAVRequest ()
@@ -635,7 +640,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
- if (!_delegate || !(_username && _password)) {
+ if (!_delegate && !(_username && _password)) {
NSLog(@"No delegate set, or password + username set for an auth challenge");
}
@@ -860,16 +865,19 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
// aakkkk!
NSURL *junk = [NSURL URLWithString:_xmlChars];
BOOL trailingSlash = [_xmlChars hasSuffix:@"/"];
- // [_xmlChars setString:[[junk path] stringByAppendingString:@"/"]];
[_xmlChars setString:[junk path]];
if (trailingSlash) {
[_xmlChars appendString:@"/"];
}
}
+ if ([_xmlChars length]) {
+ [_xmlBucket setObject:[[_xmlChars copy] autorelease] forKey:FMWebDAVURIKey];
+ }
+
NSString *lastBit = [_xmlChars substringFromIndex:_uriLength];
if ([lastBit length]) {
- [_xmlBucket setObject:lastBit forKey:@"href"];
+ [_xmlBucket setObject:lastBit forKey:FMWebDAVHREFKey];
}
}
else if ([elementName hasSuffix:@":creationdate"] || [elementName hasSuffix:@":modificationdate"]) {
@@ -881,7 +889,7 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
// stolen from http://www.cocoabuilder.com/archive/message/cocoa/2008/3/18/201578
- if ( [_xmlChars length] ) {
+ if ([_xmlChars length]) {
NSDate *d = [[self class] parseDateString:_xmlChars];
@@ -898,6 +906,7 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
}
else if ([elementName hasSuffix:@":getlastmodified"]) {
+ #pragma message "FIXME: go ahead and do this bit."
// 'Thu, 30 Oct 2008 02:52:47 GMT'
// Monday, 12-Jan-98 09:25:56 GMT
// Value: HTTP-date ; defined in section 3.3.1 of RFC2068
@@ -912,17 +921,20 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
//
// I'll take a patch. kthx, bai now.
}
+ else if ([elementName hasSuffix:@":getetag"] && [_xmlChars length]) {
+ [_xmlBucket setObject:[[_xmlChars copy] autorelease] forKey:FMWebDAVETagKey];
+ }
+ else if ([elementName hasSuffix:@":getcontenttype"] && [_xmlChars length]) {
+ [_xmlBucket setObject:[[_xmlChars copy] autorelease] forKey:FMWebDAVContentTypeKey];
+ }
else if ([elementName isEqualToString:@"D:response"]) {
if ([_xmlBucket objectForKey:@"href"]) {
[_directoryBucket addObject:_xmlBucket];
}
[_xmlBucket release];
_xmlBucket = nil;
}
-
-
}
-
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {

0 comments on commit f3872b0

Please sign in to comment.