From: helge Date: Sun, 23 Apr 2006 01:37:41 +0000 (+0000) Subject: added support for x-http-method-override header X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7118d31b4773c2d851b67f59263a21588147ceb5;p=sope added support for x-http-method-override header git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1254 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 20052f36..07f98f3c 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,5 +1,8 @@ 2006-04-23 Helge Hess + * SoObjects/SoObjectMethodDispatcher.m: added support for + x-http-method-override header (v4.5.228) + * SoObjects/SoHTTPAuthenticator.m: prepared some Google login API support (v4.5.227) diff --git a/sope-appserver/NGObjWeb/SoObjects/SoObjectMethodDispatcher.m b/sope-appserver/NGObjWeb/SoObjects/SoObjectMethodDispatcher.m index 25bf5032..ccd43e1f 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoObjectMethodDispatcher.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoObjectMethodDispatcher.m @@ -62,6 +62,7 @@ static BOOL useRedirectsForDefaultMethods = NO; - (id)dispatchInContext:(WOContext *)_ctx { NSAutoreleasePool *pool; WORequest *rq; + NSString *httpMethod; id clientObject; id methodObject; id resultObject; @@ -92,7 +93,14 @@ static BOOL useRedirectsForDefaultMethods = NO; } // TODO: should check XML-RPC !!! - // (hm, why ? XML-RPC is handled by other dispatcher ?) + // (hm, why? XML-RPC is handled by other dispatcher?) + + /* + This X- field is used by Google which uses POST to trigger REST methods, + don't ask me why ... ;-/ + */ + if (![(httpMethod = [rq headerForKey:@"x-http-method-override"]) isNotEmpty]) + httpMethod = [rq method]; /* find callable (method) object */ @@ -101,7 +109,7 @@ static BOOL useRedirectsForDefaultMethods = NO; [self debugWithFormat:@"traversed object is callable: %@", self->object]; methodObject = self->object; } - else if ([[self->object soClass] hasKey:[rq method] inContext:_ctx]) { + else if ([[self->object soClass] hasKey:httpMethod inContext:_ctx]) { // TODO: I'm not sure whether this step is correct /* the class has a GET/PUT/xxx method */ methodObject = [self->object lookupName:[rq method] @@ -115,24 +123,22 @@ static BOOL useRedirectsForDefaultMethods = NO; NSString *defaultName; defaultName = [self->object defaultMethodNameInContext:_ctx]; - if ([defaultName isNotNull]) { - if ([defaultName length] > 0) { - WOResponse *r; - NSString *url; + if ([defaultName isNotEmpty]) { + WOResponse *r; + NSString *url; - url = [self->object baseURLInContext:_ctx]; - if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; - url = [url stringByAppendingString:defaultName]; + url = [self->object baseURLInContext:_ctx]; + if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; + url = [url stringByAppendingString:defaultName]; - [self debugWithFormat:@"redirect to default method %@ of %@: %@", - defaultName, self->object, url]; + [self debugWithFormat:@"redirect to default method %@ of %@: %@", + defaultName, self->object, url]; - r = [[_ctx response] retain]; - [r setStatus:302 /* moved */]; - [r setHeader:url forKey:@"location"]; - [pool release]; - return [r autorelease]; - } + r = [[_ctx response] retain]; + [r setStatus:302 /* moved */]; + [r setHeader:url forKey:@"location"]; + [pool release]; + return [r autorelease]; } } else { diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 237873aa..ba6f797d 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=227 +SUBMINOR_VERSION:=228 # v4.5.214 requires libNGExtensions v4.5.179 # v4.5.122 requires libNGExtensions v4.5.153