Changeset 1114

Show
Ignore:
Timestamp:
07/04/08 23:36:17 (2 months ago)
Author:
kris
Message:

fixed some warnings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/net/servlet/ServletResponse.d

    r1110 r1114  
    11/******************************************************************************* 
    22 
    3         copyright:      Copyright (c) 2004 Kris Bell. All rights reserved 
     3        copyright:      copyright (c) 2004 Kris Bell. All rights reserved 
    44 
    55        license:        BSD style: $(LICENSE) 
     
    213213        ***********************************************************************/ 
    214214 
    215         bool copyFile (IServletContext context, char[] path) 
    216         { 
    217                 return cacheFile (context, path, null); 
    218         } 
    219  
    220         /*********************************************************************** 
    221          
    222         ***********************************************************************/ 
    223  
    224         bool cacheFile (IServletContext context, char[] path, IFileCache cache) 
     215        void copyFile (IServletContext context, char[] path) 
     216        { 
     217                cacheFile (context, path, null); 
     218        } 
     219 
     220        /*********************************************************************** 
     221         
     222        ***********************************************************************/ 
     223 
     224        void cacheFile (IServletContext context, char[] path, IFileCache cache) 
    225225        { 
    226226                cache.Info info; 
     
    231231 
    232232                scope (failure) 
    233                       { 
    234233                      sendError (HttpResponses.NotFound); 
    235                       return false; 
    236                       } 
    237234 
    238235                auto log = (cast(ServletContext) context).log; 
    239                     if (cache) 
    240                         if (cache.get (path, info)) 
    241                            { 
    242                            setHeaders (cast(uint) info.size, info.mime); 
    243                            buffer.append (info.data); 
    244                            return true; 
    245                            } 
    246  
    247                     char[512] tmp = void; 
    248                     file.open (context.getResourceAsPath (path, tmp)); 
    249                     scope (exit) 
    250                            file.detach; 
    251  
    252                     auto p = Path.parse (path); 
    253                     info.size = cast(ulong) file.length; 
    254                     info.mime = context.getMimeType (p.suffix); 
    255                     setHeaders (cast(uint) info.size, info.mime); 
    256  
    257                     // should we cache this? 
    258                     if (cache && cache.put (path, info, file)) 
    259                         buffer.append (info.data); 
    260                     else 
    261                        buffer.copy (file); 
    262                     return true; 
    263                 return false; 
     236                if (cache) 
     237                    if (cache.get (path, info)) 
     238                       { 
     239                       setHeaders (cast(uint) info.size, info.mime); 
     240                       buffer.append (info.data); 
     241                       return; 
     242                       } 
     243 
     244                char[512] tmp = void; 
     245                file.open (context.getResourceAsPath (path, tmp)); 
     246                scope (exit) 
     247                       file.detach; 
     248 
     249                auto p = Path.parse (path); 
     250                info.size = cast(ulong) file.length; 
     251                info.mime = context.getMimeType (p.suffix); 
     252                setHeaders (cast(uint) info.size, info.mime); 
     253 
     254                // should we cache this? 
     255                if (cache && cache.put (path, info, file)) 
     256                    buffer.append (info.data); 
     257                else 
     258                   buffer.copy (file); 
    264259        } 
    265260} 
  • trunk/mango/net/servlet/model/IServletResponse.d

    r1106 r1114  
    133133        ***********************************************************************/ 
    134134 
    135         bool copyFile (IServletContext context, char[] path); 
     135        void copyFile (IServletContext context, char[] path); 
    136136 
    137137        /*********************************************************************** 
     
    139139        ***********************************************************************/ 
    140140 
    141         bool cacheFile (IServletContext context, char[] path, IFileCache cache); 
     141        void cacheFile (IServletContext context, char[] path, IFileCache cache); 
    142142}