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 b7ab1cf commit 2915b79Copy full SHA for 2915b79
client/transport/sse.go
@@ -278,13 +278,19 @@ func (c *SSE) SendRequest(
278
deleteResponseChan()
279
return nil, fmt.Errorf("failed to send request: %w", err)
280
}
281
- defer resp.Body.Close()
+
282
+ // Drain any outstanding io
283
+ body, err := io.ReadAll(resp.Body)
284
+ resp.Body.Close()
285
286
+ if err != nil {
287
+ return nil, fmt.Errorf("failed to read response body: %w", err)
288
+ }
289
290
// Check if we got an error response
291
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
292
293
- body, _ := io.ReadAll(resp.Body)
294
return nil, fmt.Errorf("request failed with status %d: %s", resp.StatusCode, body)
295
296
0 commit comments