use SSEClientExcpetion instead of ClientRequestException (#207)

* use SSEClientExcpetion instead of ClientRequestClient

* address feedback
This commit is contained in:
shiqicao 2025-08-07 03:18:32 -07:00 • committed by GitHub
commit 6bae9874c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,8 +2,8 @@ package io.modelcontextprotocol.kotlin.sdk.client
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.client.HttpClient
import io.ktor.client.plugins.ClientRequestException
import io.ktor.client.plugins.sse.ClientSSESession
import io.ktor.client.plugins.sse.SSEClientException
import io.ktor.client.plugins.sse.sseSession
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.accept
@ -230,8 +230,8 @@ public class StreamableHttpClientTransport(
requestBuilder()
}
logger.debug { "Client SSE session started successfully." }
} catch (e: ClientRequestException) {
if (e.response.status == HttpStatusCode.MethodNotAllowed) {
} catch (e: SSEClientException) {
if (e.response?.status == HttpStatusCode.MethodNotAllowed) {
logger.info { "Server returned 405 for GET/SSE, stream disabled." }
return
}