]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOResourceRequestHandler.m
fixed OGo bug #888
[sope] / sope-appserver / NGObjWeb / WOResourceRequestHandler.m
index ef6d526d36b6baede04d03ad9b576efc00f4d676..32d6eff7c0413de32f4673c1e37b2e1f66724ae9 100644 (file)
@@ -1,7 +1,7 @@
 /*
-  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
@@ -18,7 +18,6 @@
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
-// $Id$
 
 #include <NGObjWeb/WORequestHandler.h>
 
@@ -39,6 +38,8 @@
 
 @implementation WOResourceRequestHandler
 
+static BOOL debugOn = NO;
+
 + (int)version {
   return [super version] + 0 /* v2 */;
 }
@@ -57,6 +58,8 @@
   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];