Skip to content

Commit

Permalink
Drain response body on exec call to enable keep-alive connection reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiery-Fenix committed Feb 4, 2021
1 parent e482166 commit 5327164
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conn.go
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -211,6 +212,8 @@ func (c *conn) killQuery(req *http.Request, args []driver.Value) error {
return err
}
if body != nil {
// Drain body to enable connection reuse
io.Copy(ioutil.Discard, body)
body.Close()
}
return nil
Expand Down Expand Up @@ -248,6 +251,8 @@ func (c *conn) exec(ctx context.Context, query string, args []driver.Value) (dri
}
body, err := c.doRequest(ctx, req)
if body != nil {
// Drain body to enable connection reuse
io.Copy(ioutil.Discard, body)
body.Close()
}
return emptyResult, err
Expand Down

0 comments on commit 5327164

Please sign in to comment.