func (c *Client) SetError(err interface{}) *Client {
	c.Error = typeOf(err)
	return c
}
SetError method is to register the global or client common `Error` object into go-resty.
It is used for automatic unmarshalling if response status code is greater than 399 and
content type either JSON or XML. Can be pointer or non-pointer.
resty.SetError(&Error{})
// OR
resty.SetError(Error{})
package resty
import (
	"bytes"
	"compress/gzip"
	"crypto/tls"
	"crypto/x509"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"reflect"
	"regexp"
	"strings"
	"sync"
	"time"
)
const (
	MethodGet = "GET"
	MethodPost = "POST"
	MethodPut = "PUT"
	MethodDelete = "DELETE"
	MethodPatch = "PATCH"
	MethodHead = "HEAD"
	MethodOptions = "OPTIONS"
)
var (
	hdrUserAgentKey       = http.CanonicalHeaderKey("User-Agent")
	hdrAcceptKey          = http.CanonicalHeaderKey("Accept")
	hdrContentTypeKey     = http.CanonicalHeaderKey("Content-Type")
	hdrContentLengthKey   = http.CanonicalHeaderKey("Content-Length")
	hdrContentEncodingKey = http.CanonicalHeaderKey("Content-Encoding")
	hdrAuthorizationKey   = http.CanonicalHeaderKey("Authorization")
	plainTextType   = "text/plain; charset=utf-8"
	jsonContentType = "application/json; charset=utf-8"
	formContentType = "application/x-www-form-urlencoded"
	jsonCheck = regexp.MustCompile(`(?i:(application|text)/(json|.*\+json)(;|$))`)
	xmlCheck  = regexp.MustCompile(`(?i:(application|text)/(xml|.*\+xml)(;|$))`)
	hdrUserAgentValue = "go-resty/%s (https://github.com/go-resty/resty)"
	bufPool           = &sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}
)
type Client struct {
	HostURL               string
	QueryParam            url.Values
	FormData              url.Values
	Header                http.Header
	UserInfo              *User
	Token                 string
	Cookies               []*http.Cookie
	Error                 reflect.Type
	Debug                 bool
	DisableWarn           bool
	AllowGetMethodPayload bool
	Log                   *log.Logger
	RetryCount            int
	RetryWaitTime         time.Duration
	RetryMaxWaitTime      time.Duration
	RetryConditions       []RetryConditionFunc
	JSONMarshal           func(v interface{}) ([]byte, error)
	JSONUnmarshal         func(data []byte, v interface{}) error
	jsonEscapeHTML     bool
	httpClient         *http.Client
	setContentLength   bool
	isHTTPMode         bool
	outputDirectory    string
	scheme             string
	proxyURL           *url.URL
	closeConnection    bool
	notParseResponse   bool
	debugBodySizeLimit int64
	logPrefix          string
	pathParams         map[string]string
	beforeRequest      []func(*Client, *Request) error
	udBeforeRequest    []func(*Client, *Request) error
	preReqHook         func(*Client, *Request) error
	afterResponse      []func(*Client, *Response) error
}
type User struct {
	Username, Password string
}
func (c *Client) SetHostURL(url string) *Client {
	c.HostURL = strings.TrimRight(url, "/")
	return c
}
func (c *Client) SetHeader(header, value string) *Client {
	c.Header.Set(header, value)
	return c
}
func (c *Client) SetHeaders(headers map[string]string) *Client {
	for h, v := range headers {
		c.Header.Set(h, v)
	}
	return c
}
func (c *Client) SetCookieJar(jar http.CookieJar) *Client {
	c.httpClient.Jar = jar
	return c
}
func (c *Client) SetCookie(hc *http.Cookie) *Client {
	c.Cookies = append(c.Cookies, hc)
	return c
}
func (c *Client) SetCookies(cs []*http.Cookie) *Client {
	c.Cookies = append(c.Cookies, cs...)
	return c
}
func (c *Client) SetQueryParam(param, value string) *Client {
	c.QueryParam.Set(param, value)
	return c
}
func (c *Client) SetQueryParams(params map[string]string) *Client {
	for p, v := range params {
		c.SetQueryParam(p, v)
	}
	return c
}
func (c *Client) SetFormData(data map[string]string) *Client {
	for k, v := range data {
		c.FormData.Set(k, v)
	}
	return c
}
func (c *Client) SetBasicAuth(username, password string) *Client {
	c.UserInfo = &User{Username: username, Password: password}
	return c
}
func (c *Client) SetAuthToken(token string) *Client {
	c.Token = token
	return c
}
func (c *Client) R() *Request {
	r := &Request{
		QueryParam: url.Values{},
		FormData:   url.Values{},
		Header:     http.Header{},
		client:          c,
		multipartFiles:  []*File{},
		multipartFields: []*multipartField{},
		pathParams:      map[string]string{},
		jsonEscapeHTML:  true,
	}
	return r
}
func (c *Client) NewRequest() *Request {
	return c.R()
}
func (c *Client) OnBeforeRequest(m func(*Client, *Request) error) *Client {
	c.udBeforeRequest = append(c.udBeforeRequest, m)
	return c
}
func (c *Client) OnAfterResponse(m func(*Client, *Response) error) *Client {
	c.afterResponse = append(c.afterResponse, m)
	return c
}
func (c *Client) SetPreRequestHook(h func(*Client, *Request) error) *Client {
	if c.preReqHook != nil {
		c.Log.Printf("Overwriting an existing pre-request hook: %s", functionName(h))
	}
	c.preReqHook = h
	return c
}
func (c *Client) SetDebug(d bool) *Client {
	c.Debug = d
	return c
}
func (c *Client) SetDebugBodyLimit(sl int64) *Client {
	c.debugBodySizeLimit = sl
	return c
}
func (c *Client) SetDisableWarn(d bool) *Client {
	c.DisableWarn = d
	return c
}
func (c *Client) SetAllowGetMethodPayload(a bool) *Client {
	c.AllowGetMethodPayload = a
	return c
}
func (c *Client) SetLogger(w io.Writer) *Client {
	c.Log = getLogger(w)
	return c
}
func (c *Client) SetContentLength(l bool) *Client {
	c.setContentLength = l
	return c
}
func (c *Client) SetTimeout(timeout time.Duration) *Client {
	c.httpClient.Timeout = timeout
	return c
}