From b87e42f3294318244deae8126b3ac18d543fd3d7 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Fri, 9 Aug 2019 17:52:33 +0300 Subject: fix uploads --- client.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index 3102e99..7c5c079 100644 --- a/client.go +++ b/client.go @@ -10,13 +10,14 @@ import ( ) type client struct { - key string - version string - url *url.URL + key string + version string + url *url.URL + httpClient *http.Client } -func newClient(key string, version string, url *url.URL) *client { - return &client{key: key, version: version, url: url} +func newClient(key string, version string, url *url.URL, httpClient *http.Client) *client { + return &client{key: key, version: version, url: url, httpClient: httpClient} } func (cl *client) request(method, path string, query url.Values, body interface{}) (io.ReadCloser, error) { @@ -28,7 +29,6 @@ func (cl *client) request(method, path string, query url.Values, body interface{ } func (cl *client) requestReader(method, path string, query url.Values, body io.Reader) (io.ReadCloser, error) { - c := http.DefaultClient u := *cl.url u.Path = path query.Set("access_token", cl.key) @@ -38,7 +38,7 @@ func (cl *client) requestReader(method, path string, query url.Values, body io.R if err != nil { return nil, err } - resp, err := c.Do(req) + resp, err := cl.httpClient.Do(req) if err != nil { return nil, err } -- cgit v1.2.3