Skip to content

Commit a51e32d

Browse files
committed
BaseHTTPRequestHandler: when peer is disconnected, don't log unknown exception
1 parent c2ac8b7 commit a51e32d

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Snake Server Change Log
22

3+
## 1.2.1 (2026-04-08)
4+
5+
- Fixed unknown exception when client disconnects before a request is completed.
6+
37
## 1.2.0 (2024-08-06)
48

59
- Added `--silent` command line option to disable request logging (internal errors are still logged).

haxelib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "Public",
55
"tags": ["tcp", "http", "server", "sys", "web"],
66
"description": "Create TCP/HTTP servers in Haxe, or start a simple HTTP static file server from the command line",
7-
"version": "1.2.0",
7+
"version": "1.2.1",
88
"classPath": "src",
99
"main": "snake.Run",
1010
"dependencies": {

src/snake/http/BaseHTTPRequestHandler.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ class BaseHTTPRequestHandler extends StreamRequestHandler {
285285
// NOTE: Haxe does not seem to actually flush here!
286286
wfile.flush();
287287
} catch (e:Exception) {
288+
try {
289+
connection.peer();
290+
} catch(e:Exception) {
291+
// the peer disconnected before we could complete the request
292+
closeConnection = true;
293+
return;
294+
}
288295
logError("Unknown exception: " + e.toString());
289296
closeConnection = true;
290297
return;

0 commit comments

Comments
 (0)