Skip to content

Commit

Permalink
expose http.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Feb 26, 2022
1 parent 8335591 commit d345ea9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,17 @@ func (c *Client) isPayloadForbid(m string) bool {
return (m == http.MethodGet && !c.AllowGetMethodPayload) || m == http.MethodHead || m == http.MethodOptions
}

// GetClient is a global wrapper methods which delegated
// to the default client's GetClient.
func GetClient() *http.Client {
return defaultClient.GetClient()
}

// GetClient returns the underlying `http.Client`.
func (c *Client) GetClient() *http.Client {
return c.httpClient
}

// NewClient is the alias of C
func NewClient() *Client {
return C()
Expand Down
2 changes: 2 additions & 0 deletions req_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ func TestGlobalWrapper(t *testing.T) {
DisableForceHttpVersion()
assertEqual(t, true, DefaultClient().t.ForceHttpVersion == "")

assertEqual(t, GetClient(), DefaultClient().httpClient)

r = NewRequest()
assertEqual(t, true, r != nil)
c = NewClient()
Expand Down

0 comments on commit d345ea9

Please sign in to comment.