Improve error handling
This commit is contained in:
parent
d6190b024d
commit
0b4975e74b
|
|
@ -137,13 +137,13 @@ public sealed class HttpServer {
|
|||
private string NormalizeUrlPath(string url) => '/' + url.TrimStart('/');
|
||||
|
||||
private async Task ProcessRequestAsync(HttpListenerContext ctx) {
|
||||
using RequestContext rc = new RequestContext(ctx);
|
||||
try {
|
||||
var decUri = WebUtility.UrlDecode(ctx.Request.RawUrl)!; // TODO add path escape countermeasures+unittests
|
||||
var splitted = NormalizeUrlPath(decUri).Split('?', 2, StringSplitOptions.None);
|
||||
var path = WebUtility.UrlDecode(splitted.First());
|
||||
|
||||
|
||||
using var rc = new RequestContext(ctx);
|
||||
if (simpleEndpointMethodInfos.TryGetValue((decUri, ctx.Request.HttpMethod.ToUpperInvariant()), out var endpointInvocationInfo)) {
|
||||
var mi = endpointInvocationInfo.methodInfo;
|
||||
var qparams = endpointInvocationInfo.queryParameters;
|
||||
|
|
@ -198,6 +198,7 @@ public sealed class HttpServer {
|
|||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
await HandleDefaultErrorPageAsync(rc, 500);
|
||||
logger.Fatal($"Caught otherwise uncaught exception while ProcessingRequest:\n{ex}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user