Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge pull request #22 from azaikin/query-url" #25

Merged
Show file tree
Hide file tree
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
16 changes: 6 additions & 10 deletions conn.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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