Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,22 @@ public class StreamableHttpClientTransport(
}
logger.debug { "Client SSE session started successfully." }
} catch (e: SSEClientException) {
if (e.response?.status == HttpStatusCode.MethodNotAllowed) {
val responseStatus = e.response?.status
val responseContentType = e.response?.contentType()
Comment on lines +237 to +238
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the response object to a local variable to avoid repeated null-safe calls and improve readability: val response = e.response

Suggested change
val responseStatus = e.response?.status
val responseContentType = e.response?.contentType()
val response = e.response
val responseStatus = response?.status
val responseContentType = response?.contentType()

Copilot uses AI. Check for mistakes.


// 405 means server doesn't support SSE at GET endpoint - this is expected and valid
if (responseStatus == HttpStatusCode.MethodNotAllowed) {
logger.info { "Server returned 405 for GET/SSE, stream disabled." }
return
}

// If server returns application/json, it means it doesn't support SSE for this session
// This is valid per spec - server can choose to only use JSON responses
if (responseContentType?.match(ContentType.Application.Json) == true) {
logger.info { "Server returned application/json for GET/SSE, using JSON-only mode." }
return
}

_onError(e)
throw e
}
Expand Down
Loading