support 405 response from servers that don’t support streaming (#90)

* support 405 response from servers that don’t support streaming

* Rephrase comment

---------

Co-authored-by: Stephen Tallent <stallent@mercury.io>
Co-authored-by: Mattt Zmuda <mattt@loopwork.com>
This commit is contained in:
Stephen Tallent 2025-04-27 09:27:14 -05:00 • committed by GitHub
commit ccb070f2f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -205,6 +205,12 @@ public actor HTTPClientTransport: Actor, Transport {
// Check response status
guard httpResponse.statusCode == 200 else {
// If the server returns 405 Method Not Allowed,
// it indicates that the server doesn't support SSE streaming.
// We should cancel the task instead of retrying the connection.
if httpResponse.statusCode == 405 {
self.streamingTask?.cancel()
}
throw MCPError.internalError("HTTP error: \(httpResponse.statusCode)")
}