Changeset 415 for binary-improvements2/WebServer/src
- Timestamp:
- Feb 27, 2023, 9:37:08 PM (21 months ago)
- Location:
- binary-improvements2/WebServer/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/RequestContext.cs
r391 r415 2 2 3 3 namespace Webserver { 4 public enum ERequestMethod { 5 Other, 6 // ReSharper disable InconsistentNaming 7 GET, 8 PUT, 9 POST, 10 DELETE, 11 HEAD, 12 OPTIONS, 13 // ReSharper restore InconsistentNaming 14 Count 15 } 16 4 17 public class RequestContext { 5 18 public string RequestPath; 19 public readonly ERequestMethod Method; 6 20 public readonly HttpListenerRequest Request; 7 21 public readonly HttpListenerResponse Response; … … 15 29 Connection = _connection; 16 30 PermissionLevel = _permissionLevel; 31 Method = _request.HttpMethod switch { 32 "GET" => ERequestMethod.GET, 33 "PUT" => ERequestMethod.PUT, 34 "POST" => ERequestMethod.POST, 35 "DELETE" => ERequestMethod.DELETE, 36 "HEAD" => ERequestMethod.HEAD, 37 "OPTIONS" => ERequestMethod.OPTIONS, 38 _ => ERequestMethod.Other 39 }; 17 40 } 18 41 } -
binary-improvements2/WebServer/src/Web.cs
r412 r415 233 233 234 234 RequestContext context = new RequestContext (requestPath, request, response, conn, permissionLevel); 235 236 if (context.Method == ERequestMethod.Other) { 237 context.Response.StatusCode = (int)HttpStatusCode.BadRequest; 238 return; 239 } 235 240 236 241 ApplyPathHandler (context);
Note:
See TracChangeset
for help on using the changeset viewer.