Changeset 332 for binary-improvements/MapRendering/Web/Web.cs
- Timestamp:
- Nov 16, 2018, 10:38:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/Web.cs
r326 r332 10 10 using AllocsFixes.NetConnections.Servers.Web.Handlers; 11 11 using UnityEngine; 12 using UnityEngine.Profiling; 12 13 13 14 namespace AllocsFixes.NetConnections.Servers.Web { … … 19 20 private readonly HttpListener _listener = new HttpListener (); 20 21 private readonly string dataFolder; 21 private readonly Dictionary<string, PathHandler> handlers = new Dictionary<string,PathHandler> ();22 private readonly Dictionary<string, PathHandler> handlers = new CaseInsensitiveStringDictionary<PathHandler> (); 22 23 private readonly bool useStaticCache; 23 24 … … 147 148 return false; 148 149 } 150 151 private readonly Version HttpProtocolVersion = new Version(1, 1); 152 153 #if ENABLE_PROFILER 154 private readonly CustomSampler authSampler = CustomSampler.Create ("Auth"); 155 private readonly CustomSampler handlerSampler = CustomSampler.Create ("Handler"); 156 #endif 149 157 150 158 private void HandleRequest (IAsyncResult result) { … … 157 165 158 166 // MicroStopwatch msw = new MicroStopwatch (); 167 #if ENABLE_PROFILER 168 Profiler.BeginThreadProfiling ("AllocsMods", "WebRequest"); 169 HttpListenerContext ctx = _listener.EndGetContext (result); 170 try { 171 #else 159 172 HttpListenerContext ctx = _listener.EndGetContext (result); 160 173 _listener.BeginGetContext (HandleRequest, _listener); 174 #endif 161 175 try { 162 176 HttpListenerRequest request = ctx.Request; … … 164 178 response.SendChunked = false; 165 179 166 response.ProtocolVersion = new Version ("1.1");180 response.ProtocolVersion = HttpProtocolVersion; 167 181 168 182 WebConnection conn; 183 #if ENABLE_PROFILER 184 authSampler.Begin (); 185 #endif 169 186 int permissionLevel = DoAuthentication (request, out conn); 187 #if ENABLE_PROFILER 188 authSampler.End (); 189 #endif 170 190 171 191 … … 200 220 } 201 221 } else { 222 #if ENABLE_PROFILER 223 handlerSampler.Begin (); 224 #endif 202 225 kvp.Value.HandleRequest (request, response, conn, permissionLevel); 226 #if ENABLE_PROFILER 227 handlerSampler.End (); 228 #endif 203 229 } 204 230 … … 230 256 Interlocked.Decrement (ref currentHandlers); 231 257 } 258 #if ENABLE_PROFILER 259 } finally { 260 _listener.BeginGetContext (HandleRequest, _listener); 261 Profiler.EndThreadProfiling (); 262 } 263 #endif 232 264 } 233 265 … … 241 273 242 274 if (!string.IsNullOrEmpty (sessionId)) { 243 WebConnection con = connectionHandler.IsLoggedIn (sessionId, _req.RemoteEndPoint.Address .ToString ());275 WebConnection con = connectionHandler.IsLoggedIn (sessionId, _req.RemoteEndPoint.Address); 244 276 if (con != null) { 245 277 _con = con; … … 259 291 } 260 292 261 if (_req.Url.AbsolutePath.StartsWith ("/session/verify" )) {293 if (_req.Url.AbsolutePath.StartsWith ("/session/verify", StringComparison.OrdinalIgnoreCase)) { 262 294 try { 263 295 ulong id = OpenID.Validate (_req); 264 296 if (id > 0) { 265 WebConnection con = connectionHandler.LogIn (id, _req.RemoteEndPoint.Address .ToString ());297 WebConnection con = connectionHandler.LogIn (id, _req.RemoteEndPoint.Address); 266 298 _con = con; 267 299 int level = GameManager.Instance.adminTools.GetAdminToolsClientInfo (id.ToString ())
Note:
See TracChangeset
for help on using the changeset viewer.