Ignore:
Timestamp:
Aug 6, 2022, 11:32:32 PM (2 years ago)
Author:
alloc
Message:

Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/MapRendering/Web/Handlers/StaticHandler.cs

    r382 r387  
    22using System.Net;
    33using AllocsFixes.FileCache;
    4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
    5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
    64
    75namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
     
    1816                }
    1917
    20                 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con,
    21                         int _permissionLevel) {
    22                         string fn = _requestPath.Remove (0, urlBasePath.Length);
     18                public override void HandleRequest (RequestContext _context) {
     19                        string fn = _context.RequestPath.Remove (0, urlBasePath.Length);
    2320
    2421                        byte[] content = cache.GetFileContent (datapath + fn);
    2522
    2623                        if (content != null) {
    27                                 _resp.ContentType = MimeType.GetMimeType (Path.GetExtension (fn));
    28                                 _resp.ContentLength64 = content.Length;
    29                                 _resp.OutputStream.Write (content, 0, content.Length);
     24                                _context.Response.ContentType = MimeType.GetMimeType (Path.GetExtension (fn));
     25                                _context.Response.ContentLength64 = content.Length;
     26                                _context.Response.OutputStream.Write (content, 0, content.Length);
    3027                        } else {
    31                                 _resp.StatusCode = (int) HttpStatusCode.NotFound;
     28                                _context.Response.StatusCode = (int) HttpStatusCode.NotFound;
    3229                                if (logMissingFiles) {
    33                                         Log.Out ("Web:Static:FileNotFound: \"" + _requestPath + "\" @ \"" + datapath + fn + "\"");
     30                                        Log.Out ("Web:Static:FileNotFound: \"" + _context.RequestPath + "\" @ \"" + datapath + fn + "\"");
    3431                                }
    3532                        }
Note: See TracChangeset for help on using the changeset viewer.