- Timestamp:
- Aug 6, 2022, 11:32:32 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MapRendering/Web/Handlers/ItemIconHandler.cs
r382 r387 4 4 using System.Net; 5 5 using UnityEngine; 6 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;8 6 using Object = UnityEngine.Object; 9 7 … … 26 24 public static ItemIconHandler Instance { get; private set; } 27 25 28 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 29 int _permissionLevel) { 26 public override void HandleRequest (RequestContext _context) { 30 27 if (!loaded) { 31 _ resp.StatusCode = (int) HttpStatusCode.InternalServerError;28 _context.Response.StatusCode = (int) HttpStatusCode.InternalServerError; 32 29 Log.Out ("Web:IconHandler: Icons not loaded"); 33 30 return; 34 31 } 35 32 36 string requestFileName = _ requestPath.Remove (0, urlBasePath.Length);33 string requestFileName = _context.RequestPath.Remove (0, urlBasePath.Length); 37 34 requestFileName = requestFileName.Remove (requestFileName.LastIndexOf ('.')); 38 35 39 if (icons.ContainsKey (requestFileName) && _ requestPath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) {40 _ resp.ContentType = MimeType.GetMimeType (".png");36 if (icons.ContainsKey (requestFileName) && _context.RequestPath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 37 _context.Response.ContentType = MimeType.GetMimeType (".png"); 41 38 42 39 byte[] itemIconData = icons [requestFileName]; 43 40 44 _ resp.ContentLength64 = itemIconData.Length;45 _ resp.OutputStream.Write (itemIconData, 0, itemIconData.Length);41 _context.Response.ContentLength64 = itemIconData.Length; 42 _context.Response.OutputStream.Write (itemIconData, 0, itemIconData.Length); 46 43 } else { 47 _ resp.StatusCode = (int) HttpStatusCode.NotFound;44 _context.Response.StatusCode = (int) HttpStatusCode.NotFound; 48 45 if (logMissingFiles) { 49 Log.Out ("Web:IconHandler:FileNotFound: \"" + _ requestPath + "\" ");46 Log.Out ("Web:IconHandler:FileNotFound: \"" + _context.RequestPath + "\" "); 50 47 } 51 48 }
Note:
See TracChangeset
for help on using the changeset viewer.