We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95201f2 commit ef2e795Copy full SHA for ef2e795
client/transport/streamable_http.go
@@ -252,12 +252,14 @@ func (c *StreamableHTTP) SendRequest(
252
return nil, fmt.Errorf("failed to send request: %w", err)
253
}
254
255
+
256
+ // Only proceed if we have a valid response.
257
// When sendHTTP fails and resp is nil but method is mcp.MethodInitialize
258
// defer resp.Body.Close() fails with nil pointer dereference.
- // TODO: Restructure this fallthrough logic properly.
- if resp != nil {
259
- defer resp.Body.Close()
+ if resp == nil {
260
+ return nil, fmt.Errorf("failed to send request: %w", err)
261
262
+ defer resp.Body.Close()
263
264
// Check if we got an error response
265
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
0 commit comments