]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOResourceRequestHandler.m
increased element nesting depth
[sope] / sope-appserver / NGObjWeb / WOResourceRequestHandler.m
index ef6d526d36b6baede04d03ad9b576efc00f4d676..61ed41fd9978aeeab666c7ca9ae97a1ceb87bad9 100644 (file)
@@ -1,24 +1,23 @@
 /*
-  Copyright (C) 2000-2003 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
 
-  This file is part of OGo
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE 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; either version 2, or (at your option) any
   later version.
 
-  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with OGo; see the file COPYING.  If not, write to the
+  License along with SOPE; see the file COPYING.  If not, write to the
   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];