Skip to content

Commit

Permalink
Merge 7c1f87a into 8c19f6f
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaifullin committed Aug 14, 2018
2 parents 8c19f6f + 7c1f87a commit 2f7fdc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions conn.go
Expand Up @@ -213,25 +213,21 @@ func (c *conn) doRequest(ctx context.Context, req *http.Request) ([]byte, error)

func (c *conn) buildRequest(query string, params []driver.Value, readonly bool) (*http.Request, error) {
var (
req *http.Request
err error
method string
err error
)
if params != nil {
if query, err = interpolateParams(query, params); err != nil {
return nil, err
}
}
c.log("query: ", query)
if readonly {
u := *c.url
q := u.Query()
q.Set("query", query)
u.RawQuery = q.Encode()
req, err = http.NewRequest(http.MethodGet, u.String(), nil)
method = http.MethodGet
} else {
req, err = http.NewRequest(http.MethodPost, c.url.String(), strings.NewReader(query))
method = http.MethodPost
}

c.log("query: ", query)
req, err := http.NewRequest(method, c.url.String(), strings.NewReader(query))
// http.Transport ignores url.User argument, handle it here
if err == nil && c.user != nil {
p, _ := c.user.Password()
Expand Down
2 changes: 1 addition & 1 deletion conn_test.go
Expand Up @@ -159,7 +159,7 @@ func (s *connSuite) TestBuildRequestReadonlyWithAuth() {
s.Equal("user", user)
s.Equal("password", password)
s.Equal(http.MethodGet, req.Method)
s.Equal(cn.url.String()+"&query=SELECT+1", req.URL.String())
s.Equal(cn.url.String(), req.URL.String())
s.Nil(req.URL.User)
}
}
Expand Down

0 comments on commit 2f7fdc4

Please sign in to comment.