File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
OpenHardwareMonitor/Utilities Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,8 @@ private async Task HandleContextAsync(HttpListenerContext context)
341341 }
342342 }
343343
344+ try
345+ {
344346 if ( authenticated )
345347 {
346348 switch ( request . HttpMethod )
@@ -422,15 +424,23 @@ private async Task HandleContextAsync(HttpListenerContext context)
422424 await SendResponseAsync ( context . Response , responseString , "text/html" ) ;
423425 }
424426
425- try
427+ context . Response . Close ( ) ;
428+ }
429+ catch ( ArgumentException ex )
426430 {
431+ context . Response . StatusCode = 400 ;
432+ string responseString = @$ "<HTML><HEAD><TITLE>400 Bad Request</TITLE></HEAD>
433+ <BODY><H4>400 Bad Request</H4>
434+ { ex . Message } </BODY></HTML> " ;
435+ await SendResponseAsync ( context . Response , responseString , "text/html" ) ;
427436 context . Response . Close ( ) ;
428437 }
429438 catch
430439 {
431440 // client closed connection before the content was sent
432441 }
433442 }
443+
434444 private async Task ServeResourceFileAsync ( HttpListenerResponse response , string name , string ext )
435445 {
436446 // resource names do not support the hyphen
You can’t perform that action at this time.
0 commit comments