- Timestamp:
- Aug 17, 2023, 4:57:23 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/UrlHandlers/ItemIconHandler.cs
r402 r463 31 31 } 32 32 33 if (!_context.RequestPath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 34 _context.Response.StatusCode = (int) HttpStatusCode.BadRequest; 35 return; 36 } 37 33 38 string requestFileName = _context.RequestPath.Remove (0, urlBasePath.Length); 34 requestFileName = requestFileName.Remove (requestFileName.LastIndexOf ('.')); 35 36 if (icons.ContainsKey (requestFileName) && _context.RequestPath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 37 _context.Response.ContentType = MimeType.GetMimeType (".png"); 38 39 byte[] itemIconData = icons [requestFileName]; 40 41 _context.Response.ContentLength64 = itemIconData.Length; 42 _context.Response.OutputStream.Write (itemIconData, 0, itemIconData.Length); 43 } else { 44 _context.Response.StatusCode = (int) HttpStatusCode.NotFound; 39 int indexOfExtSep = requestFileName.LastIndexOf ('.'); 40 if (indexOfExtSep < 0) { 41 _context.Response.StatusCode = (int) HttpStatusCode.BadRequest; 42 return; 43 } 44 45 requestFileName = requestFileName.Remove (indexOfExtSep); 46 47 if (!icons.TryGetValue (requestFileName, out byte[] icon)) { 48 _context.Response.StatusCode = (int)HttpStatusCode.NotFound; 45 49 if (logMissingFiles) { 46 50 Log.Out ($"[Web] IconHandler: FileNotFound: \"{_context.RequestPath}\" "); 47 51 } 48 } 52 return; 53 } 54 55 _context.Response.ContentType = MimeType.GetMimeType (".png"); 56 57 _context.Response.ContentLength64 = icon.Length; 58 _context.Response.OutputStream.Write (icon, 0, icon.Length); 49 59 } 50 60
Note:
See TracChangeset
for help on using the changeset viewer.