/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include <NGObjWeb/WORequestHandler.h>
@implementation WOResourceRequestHandler
+static BOOL debugOn = NO;
+
+ (int)version {
return [super version] + 0 /* v2 */;
}
NSString *resourcePath;
NSData *data;
+ if (debugOn) [self logWithFormat:@"handle WS request: %@", _request];
+
if (_request == nil) return nil;
*(&app) = [WOApplication application];
/* check for WebServerResources requests ... */
- if ([handlerPath count] < 1)
+ if ([handlerPath count] < 1) {
+ if (debugOn) [self logWithFormat:@"path to short: '%@'", handlerPath];
return nil;
+ }
+ if (debugOn) [self logWithFormat:@" check path: '%@'", handlerPath];
/* ok, found a resource request */
pathForResourceNamed:resourceName
inFramework:nil
languages:languages];
+ if (debugOn) [self logWithFormat:@" resource path: '%@'", resourcePath];
- data = resourcePath
+ data = (resourcePath != nil)
? [NSData dataWithContentsOfFile:resourcePath]
: nil;
if (data == nil) {
response = [WOResponse responseWithRequest:_request];
[response setStatus:404]; /* not found */
- return nil;
+ [response setHeader:@"text/html" forKey:@"content-type"];
+ [response appendContentString:@"<h3>Resource not found</h3><pre>"];
+ [response appendContentHTMLString:@"Name: "];
+ [response appendContentHTMLString:resourceName];
+ [response appendContentHTMLString:@"\nLanguages: "];
+ [response appendContentHTMLString:[languages description]];
+ [response appendContentHTMLString:@"\nResourceManager: "];
+ [response appendContentHTMLString:[[app resourceManager] description]];
+ [response appendContentString:@"</pre>"];
+ return response;
}
//NSLog(@"shall deliver %@", resourcePath);
- (WOResponse *)handleRequest:(WORequest *)_request {
NSArray *handlerPath = nil;
+ if (debugOn) [self logWithFormat:@"handle request: %@", _request];
+
if ([[_request requestHandlerKey] isEqualToString:@"WebServerResources"])
return [self _handleWebServerResourcesRequest:_request];