Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft-murchison-webdav-prefer-05 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
31 changes: 27 additions & 4 deletions sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,22 @@ - (id)doMKCOL:(WOContext *)_ctx {
return [NSNumber numberWithBool:YES];
}

- (NSString *)scopeForDepth:(NSString *)_depth inContext:(WOContext *)_ctx {
- (NSString *)scopeForDepth:(NSString *)_depth withPrefer:(NSString *)_prefer inContext:(WOContext *)_ctx {
NSString *scope;
NSArray *preferArray;
NSString *noroot;
int pos, count;

//Parse Prefer header for draft-murchison-webdav-prefer-05
preferArray = [_prefer componentsSeparatedByString:@","];
count = [preferArray count];
for (pos = 0; pos < count; pos++) {
NSString *headElement = [[preferArray objectAtIndex:pos] stringByTrimmingSpaces];
if ([headElement isEqualToString:@"depth-noroot"]) {
noroot = headElement;
break;
}
}

if ([_depth hasPrefix:@"0"])
scope = @"self";
Expand All @@ -366,7 +380,11 @@ - (NSString *)scopeForDepth:(NSString *)_depth inContext:(WOContext *)_ctx {
else if ([_depth hasPrefix:@"1"]) {
NSString *ua;

scope = @"flat+self";
if ( noroot ) {
scope = @"flat";
} else {
scope = @"flat+self";
}

/* some special handling for IE ... */
if ((ua = [[[_ctx request] clientCapabilities] userAgentType])) {
Expand All @@ -376,6 +394,7 @@ - (NSString *)scopeForDepth:(NSString *)_depth inContext:(WOContext *)_ctx {
scope = @"flat";
}
}
/* TODO: deep can also be +self or with noroot */
else if ([_depth hasPrefix:@"infinity"])
scope = @"deep";
else
Expand Down Expand Up @@ -411,6 +430,7 @@ - (id)doPROPFIND:(WOContext *)_ctx {
WORequest *rq;
NSString *uri;
NSString *depth; /* 0, 1, 1,noroot or infinity */
NSString *prefer;
NSArray *propNames, *rtargets;
BOOL findAll;
BOOL findNames;
Expand All @@ -435,6 +455,7 @@ - (id)doPROPFIND:(WOContext *)_ctx {

rq = [_ctx request];
depth = [rq headerForKey:@"depth"];
prefer= [rq headerForKey:@"prefer"];
uri = [rq uri];

if (![depth isNotEmpty]) depth = @"infinity";
Expand Down Expand Up @@ -516,7 +537,7 @@ properly report their default properties (they sometimes report missing
{
NSMutableDictionary *hints;

hints = [self hintsWithScope:[self scopeForDepth:depth inContext:_ctx]
hints = [self hintsWithScope:[self scopeForDepth:depth withPrefer:prefer inContext:_ctx]
propNames:propNames findAll:findAll namesOnly:findNames];
if (rtargets != nil) /* range-query keys */
[hints setObject:rtargets forKey:@"bulkTargetKeys"];
Expand Down Expand Up @@ -1321,6 +1342,7 @@ - (id)doBPROPFIND:(WOContext *)_ctx {
EOFetchSpecification *fs;
WORequest *rq;
NSString *depth; /* 0, 1, 1,noroot or infinity */
NSString *prefer;
NSArray *propNames;
NSArray *targets, *rtargets;
BOOL findAll;
Expand All @@ -1345,6 +1367,7 @@ - (id)doBPROPFIND:(WOContext *)_ctx {

rq = [_ctx request];
depth = [rq headerForKey:@"depth"];
prefer= [rq headerForKey:@"prefer"];
if (![depth isNotEmpty]) depth = @"infinity";

[self lockParser:davsax];
Expand Down Expand Up @@ -1378,7 +1401,7 @@ - (id)doBPROPFIND:(WOContext *)_ctx {
{
NSMutableDictionary *hints;

hints = [self hintsWithScope:[self scopeForDepth:depth inContext:_ctx]
hints = [self hintsWithScope:[self scopeForDepth:depth withPrefer:prefer inContext:_ctx]
propNames:propNames findAll:findAll namesOnly:findNames];
[hints setObject:rtargets forKey:@"bulkTargetKeys"];

Expand Down