Skip to content

Commit

Permalink
close response body on error (#5222)
Browse files Browse the repository at this point in the history
* close response body on error

* fix

* fix
  • Loading branch information
pjain1 committed Jul 9, 2024
1 parent c81f48e commit 4028b09
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/drivers/druid/druidsqldriver/druid_api_sql_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func (c *sqlConnection) QueryContext(ctx context.Context, query string, args []d
return nil, err
}

if resp.StatusCode != http.StatusOK {
// Druid sends well-formed response for 200, 400 and 500 status codes, for others use this
// ref - https://druid.apache.org/docs/latest/api-reference/sql-api/#responses
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusBadRequest && resp.StatusCode != http.StatusInternalServerError {
resp.Body.Close()
return nil, fmt.Errorf("unexpected status code: %d, status: %s", resp.StatusCode, resp.Status)
}

Expand Down

0 comments on commit 4028b09

Please sign in to comment.