- Timestamp:
- Jan 19, 2019, 6:12:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/Handlers/StaticHandler.cs
r332 r351 10 10 private readonly string staticPart; 11 11 12 public StaticHandler (string staticPart, string filePath, AbstractCache cache, boollogMissingFiles,13 string moduleName = null) : base (moduleName) {14 this.staticPart =staticPart;15 datapath = filePath + (filePath [filePath.Length - 1] == '/' ? "" : "/");16 this.cache =cache;17 this.logMissingFiles =logMissingFiles;12 public StaticHandler (string _staticPart, string _filePath, AbstractCache _cache, bool _logMissingFiles, 13 string _moduleName = null) : base (_moduleName) { 14 staticPart = _staticPart; 15 datapath = _filePath + (_filePath [_filePath.Length - 1] == '/' ? "" : "/"); 16 cache = _cache; 17 logMissingFiles = _logMissingFiles; 18 18 } 19 19 20 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnectionuser,21 int permissionLevel) {22 string fn = req.Url.AbsolutePath.Remove (0, staticPart.Length);20 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 21 int _permissionLevel) { 22 string fn = _req.Url.AbsolutePath.Remove (0, staticPart.Length); 23 23 24 24 byte[] content = cache.GetFileContent (datapath + fn); 25 25 26 26 if (content != null) { 27 resp.ContentType = MimeType.GetMimeType (Path.GetExtension (fn));28 resp.ContentLength64 = content.Length;29 resp.OutputStream.Write (content, 0, content.Length);27 _resp.ContentType = MimeType.GetMimeType (Path.GetExtension (fn)); 28 _resp.ContentLength64 = content.Length; 29 _resp.OutputStream.Write (content, 0, content.Length); 30 30 } else { 31 resp.StatusCode = (int) HttpStatusCode.NotFound;31 _resp.StatusCode = (int) HttpStatusCode.NotFound; 32 32 if (logMissingFiles) { 33 Log.Out ("Web:Static:FileNotFound: \"" + req.Url.AbsolutePath + "\" @ \"" + datapath + fn + "\"");33 Log.Out ("Web:Static:FileNotFound: \"" + _req.Url.AbsolutePath + "\" @ \"" + datapath + fn + "\""); 34 34 } 35 35 }
Note:
See TracChangeset
for help on using the changeset viewer.