From b969edd30aa6cc0927f11671ec8c07f8c8067607 Mon Sep 17 00:00:00 2001 From: sergeych Date: Sun, 26 Apr 2026 10:21:33 +0300 Subject: [PATCH] Fix commonMain cancellation handling in HTTP server loop --- .../net/sergeych/lyngio/http/server/HttpServerLoop.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lyngio/src/commonMain/kotlin/net/sergeych/lyngio/http/server/HttpServerLoop.kt b/lyngio/src/commonMain/kotlin/net/sergeych/lyngio/http/server/HttpServerLoop.kt index a98c61d..4acdf63 100644 --- a/lyngio/src/commonMain/kotlin/net/sergeych/lyngio/http/server/HttpServerLoop.kt +++ b/lyngio/src/commonMain/kotlin/net/sergeych/lyngio/http/server/HttpServerLoop.kt @@ -87,8 +87,8 @@ private class StartedHttpServer( withTimeout(config.keepAliveTimeoutMillis) { parseHttpRequest(reader, config) } - } catch (_: CancellationException) { - throw CancellationException() + } catch (e: CancellationException) { + throw e } catch (e: HttpProtocolException) { safeWriteError(socket, e.status, e.message ?: defaultReason(e.status)) break @@ -99,8 +99,8 @@ private class StartedHttpServer( val result = try { handler.handle(request) - } catch (_: CancellationException) { - throw CancellationException() + } catch (e: CancellationException) { + throw e } catch (_: Throwable) { HttpHandlerResult.Response(HttpResponse(status = 500, close = true)) }