Fix commonMain cancellation handling in HTTP server loop

This commit is contained in:
Sergey Chernov 2026-04-26 10:21:33 +03:00
parent 01ceecd7df
commit b969edd30a

View File

@ -87,8 +87,8 @@ private class StartedHttpServer(
withTimeout(config.keepAliveTimeoutMillis) { withTimeout(config.keepAliveTimeoutMillis) {
parseHttpRequest(reader, config) parseHttpRequest(reader, config)
} }
} catch (_: CancellationException) { } catch (e: CancellationException) {
throw CancellationException() throw e
} catch (e: HttpProtocolException) { } catch (e: HttpProtocolException) {
safeWriteError(socket, e.status, e.message ?: defaultReason(e.status)) safeWriteError(socket, e.status, e.message ?: defaultReason(e.status))
break break
@ -99,8 +99,8 @@ private class StartedHttpServer(
val result = try { val result = try {
handler.handle(request) handler.handle(request)
} catch (_: CancellationException) { } catch (e: CancellationException) {
throw CancellationException() throw e
} catch (_: Throwable) { } catch (_: Throwable) {
HttpHandlerResult.Response(HttpResponse(status = 500, close = true)) HttpHandlerResult.Response(HttpResponse(status = 500, close = true))
} }