Skip to content
Merged
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
10 changes: 8 additions & 2 deletions client/transport/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,19 @@ func (c *SSE) SendRequest(
deleteResponseChan()
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()

// Drain any outstanding io
body, err := io.ReadAll(resp.Body)
resp.Body.Close()

if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}

// Check if we got an error response
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
deleteResponseChan()

body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("request failed with status %d: %s", resp.StatusCode, body)
}

Expand Down