Changeset 1115
- Timestamp:
- 07/10/08 01:05:51 (5 months ago)
- Files:
-
- trunk/mango/net/servlet/ServletResponse.d (modified) (3 diffs)
- trunk/mango/net/servlet/model/IServletResponse.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/mango/net/servlet/ServletResponse.d
r1114 r1115 222 222 ***********************************************************************/ 223 223 224 voidcacheFile (IServletContext context, char[] path, IFileCache cache)224 bool cacheFile (IServletContext context, char[] path, IFileCache cache) 225 225 { 226 226 cache.Info info; … … 229 229 if (file is null) 230 230 file = new FileConduit; 231 232 scope (failure)233 sendError (HttpResponses.NotFound);234 231 235 232 auto log = (cast(ServletContext) context).log; … … 239 236 setHeaders (cast(uint) info.size, info.mime); 240 237 buffer.append (info.data); 241 return ;238 return true; 242 239 } 243 240 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); 241 try { 242 char[512] tmp = void; 243 file.open (context.getResourceAsPath (path, tmp)); 244 245 auto p = Path.parse (path); 246 info.size = cast(ulong) file.length; 247 info.mime = context.getMimeType (p.suffix); 248 setHeaders (cast(uint) info.size, info.mime); 249 250 // should we cache this? 251 if (cache && cache.put (path, info, file)) 252 buffer.append (info.data); 253 else 254 buffer.copy (file); 255 } catch (IOException e) 256 { 257 sendError (HttpResponses.NotFound); 258 return false; 259 } 260 finally 261 { 262 file.detach; 263 } 264 return true; 259 265 } 260 266 } trunk/mango/net/servlet/model/IServletResponse.d
r1114 r1115 139 139 ***********************************************************************/ 140 140 141 voidcacheFile (IServletContext context, char[] path, IFileCache cache);141 bool cacheFile (IServletContext context, char[] path, IFileCache cache); 142 142 }
