-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
isproxyset method, godoc update, travis config
- Loading branch information
Showing
7 changed files
with
29 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2015-2016 Jeevanandam M ([email protected]), All rights reserved. | ||
// Copyright (c) 2015-2017 Jeevanandam M ([email protected]), All rights reserved. | ||
// resty source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
|
@@ -214,7 +214,7 @@ func (c *Client) SetQueryParam(param, value string) *Client { | |
return c | ||
} | ||
|
||
// SetQueryParams method sets multiple paramaters and its values at one go in the client instance. | ||
// SetQueryParams method sets multiple parameters and its values at one go in the client instance. | ||
// It will be formed as query string for the request. For example: `search=kitchen%20papers&size=large` | ||
// in the URL after `?` mark. These query params will be added to all the request raised from this | ||
// client instance. Also it can be overridden at request level Query Param options, | ||
|
@@ -700,6 +700,11 @@ func (c *Client) getTLSConfig() *tls.Config { | |
return c.transport.TLSClientConfig | ||
} | ||
|
||
// IsProxySet method returns the true if proxy is set on client otherwise false. | ||
func (c *Client) IsProxySet() bool { | ||
return c.proxyURL != nil | ||
} | ||
|
||
// | ||
// Response | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2015-2016 Jeevanandam M ([email protected]), All rights reserved. | ||
// Copyright (c) 2015-2017 Jeevanandam M ([email protected]), All rights reserved. | ||
// resty source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
|
@@ -99,7 +99,7 @@ func SetQueryParam(param, value string) *Client { | |
return DefaultClient.SetQueryParam(param, value) | ||
} | ||
|
||
// SetQueryParams method sets multiple paramaters and its value. See `Client.SetQueryParams` for more information. | ||
// SetQueryParams method sets multiple parameters and its value. See `Client.SetQueryParams` for more information. | ||
func SetQueryParams(params map[string]string) *Client { | ||
return DefaultClient.SetQueryParams(params) | ||
} | ||
|
@@ -239,6 +239,12 @@ func SetCloseConnection(close bool) *Client { | |
return DefaultClient.SetCloseConnection(close) | ||
} | ||
|
||
// IsProxySet method returns the true if proxy is set on client otherwise false. | ||
// See `Client.IsProxySet` for more information. | ||
func IsProxySet() bool { | ||
return DefaultClient.IsProxySet() | ||
} | ||
|
||
func init() { | ||
DefaultClient = New() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2015-2016 Jeevanandam M ([email protected]), All rights reserved. | ||
// Copyright (c) 2015-2017 Jeevanandam M ([email protected]), All rights reserved. | ||
// resty source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
|
@@ -67,7 +67,7 @@ func (r *Request) SetQueryParam(param, value string) *Request { | |
return r | ||
} | ||
|
||
// SetQueryParams method sets multiple paramaters and its values at one go in the current request. | ||
// SetQueryParams method sets multiple parameters and its values at one go in the current request. | ||
// It will be formed as query string for the request. | ||
// Example: `search=kitchen%20papers&size=large` in the URL after `?` mark. | ||
// resty.R(). | ||
|
@@ -85,7 +85,7 @@ func (r *Request) SetQueryParams(params map[string]string) *Request { | |
return r | ||
} | ||
|
||
// SetMultiValueQueryParams method sets multiple paramaters with multi-value | ||
// SetMultiValueQueryParams method sets multiple parameters with multi-value | ||
// at one go in the current request. It will be formed as query string for the request. | ||
// Example: `status=pending&status=approved&status=open` in the URL after `?` mark. | ||
// resty.R(). | ||
|
@@ -140,7 +140,7 @@ func (r *Request) SetFormData(data map[string]string) *Request { | |
return r | ||
} | ||
|
||
// SetMultiValueFormData method sets multiple form paramaters with multi-value | ||
// SetMultiValueFormData method sets multiple form parameters with multi-value | ||
// at one go in the current request. | ||
// resty.R(). | ||
// SetMultiValueFormData(url.Values{ | ||
|
@@ -320,7 +320,7 @@ func (r *Request) SetAuthToken(token string) *Request { | |
} | ||
|
||
// SetOutput method sets the output file for current HTTP request. Current HTTP response will be | ||
// saved into given file. It is similar to `curl -o` flag. Absoulte path or relative path can be used. | ||
// saved into given file. It is similar to `curl -o` flag. Absolute path or relative path can be used. | ||
// If is it relative path then output file goes under the output directory, as mentioned | ||
// in the `Client.SetOutputDirectory`. | ||
// resty.R(). | ||
|
@@ -485,7 +485,7 @@ func (r *Request) fmtBodyString() (body string) { | |
body = base64.StdEncoding.EncodeToString(b) | ||
} | ||
|
||
if prtBodyBytes != nil { | ||
if prtBodyBytes != nil && err == nil { | ||
body = string(prtBodyBytes) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2015-2016 Jeevanandam M ([email protected]), All rights reserved. | ||
// Copyright (c) 2015-2017 Jeevanandam M ([email protected]), All rights reserved. | ||
// resty source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
|
@@ -948,11 +948,11 @@ func TestRawFileUploadByBody(t *testing.T) { | |
func TestProxySetting(t *testing.T) { | ||
c := dc() | ||
|
||
assertEqual(t, true, c.proxyURL == nil) | ||
assertEqual(t, true, !c.IsProxySet()) | ||
assertEqual(t, true, (c.transport.Proxy == nil)) | ||
|
||
c.SetProxy("http://sampleproxy:8888") | ||
assertEqual(t, true, c.proxyURL != nil) | ||
assertEqual(t, true, c.IsProxySet()) | ||
assertEqual(t, true, (c.transport.Proxy == nil)) | ||
|
||
c.SetProxy("//not.a.user@%66%6f%6f.com:8888") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2015-2016 Jeevanandam M ([email protected]), All rights reserved. | ||
// Copyright (c) 2015-2017 Jeevanandam M ([email protected]), All rights reserved. | ||
// resty source code and usage is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
|
@@ -9,7 +9,6 @@ import ( | |
"errors" | ||
"net/http" | ||
"reflect" | ||
"runtime" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
@@ -175,10 +174,6 @@ func TestClientRetryGet(t *testing.T) { | |
assertError(t, err) | ||
} | ||
|
||
func GetFunctionName(i interface{}) string { | ||
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() | ||
} | ||
|
||
func TestClientRetryPost(t *testing.T) { | ||
ts := createPostServer(t) | ||
defer ts.Close() | ||
|