- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/Handlers/StaticHandler.cs
r251 r325 1 using System;2 using System.Collections.Generic;3 1 using System.IO; 4 2 using System.Net; 5 using System.Threading;3 using AllocsFixes.FileCache; 6 4 7 namespace AllocsFixes.NetConnections.Servers.Web.Handlers 8 { 9 public class StaticHandler : PathHandler 10 { 11 private string datapath; 12 private string staticPart; 13 private AllocsFixes.FileCache.AbstractCache cache; 14 private bool logMissingFiles; 5 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 6 public class StaticHandler : PathHandler { 7 private readonly AbstractCache cache; 8 private readonly string datapath; 9 private readonly bool logMissingFiles; 10 private readonly string staticPart; 15 11 16 public StaticHandler (string staticPart, string filePath, A llocsFixes.FileCache.AbstractCache cache, bool logMissingFiles, string moduleName = null) : base(moduleName)17 {12 public StaticHandler (string staticPart, string filePath, AbstractCache cache, bool logMissingFiles, 13 string moduleName = null) : base (moduleName) { 18 14 this.staticPart = staticPart; 19 this.datapath = filePath;15 datapath = filePath; 20 16 this.cache = cache; 21 17 this.logMissingFiles = logMissingFiles; 22 18 } 23 19 24 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)25 {20 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 21 int permissionLevel) { 26 22 string fn = req.Url.AbsolutePath.Remove (0, staticPart.Length); 27 23 … … 33 29 resp.OutputStream.Write (content, 0, content.Length); 34 30 } else { 35 resp.StatusCode = (int)HttpStatusCode.NotFound; 36 if (logMissingFiles) 37 Log.Out ("Web:Static:FileNotFound: \"" + req.Url.AbsolutePath + "\" @ \"" + datapath + "/" + req.Url.AbsolutePath.Remove (0, staticPart.Length) + "\""); 38 return; 31 resp.StatusCode = (int) HttpStatusCode.NotFound; 32 if (logMissingFiles) { 33 Log.Out ("Web:Static:FileNotFound: \"" + req.Url.AbsolutePath + "\" @ \"" + datapath + "/" + 34 req.Url.AbsolutePath.Remove (0, staticPart.Length) + "\""); 35 } 39 36 } 40 37 } 41 38 } 42 39 } 43
Note:
See TracChangeset
for help on using the changeset viewer.