Skip to content

Commit

Permalink
change client property name
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Mar 2, 2024
1 parent 6b01572 commit 907b8a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
type Client struct {
mu sync.RWMutex

client *fasthttp.Client
fasthttp *fasthttp.Client

baseURL string
userAgent string
Expand Down Expand Up @@ -158,18 +158,18 @@ func (c *Client) SetXMLUnmarshal(f utils.XMLUnmarshal) *Client {
// TLSConfig returns tlsConfig in client.
// If client don't have tlsConfig, this function will init it.
func (c *Client) TLSConfig() *tls.Config {
if c.client.TLSConfig == nil {
c.client.TLSConfig = &tls.Config{
if c.fasthttp.TLSConfig == nil {
c.fasthttp.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
}

return c.client.TLSConfig
return c.fasthttp.TLSConfig
}

// SetTLSConfig sets tlsConfig in client.
func (c *Client) SetTLSConfig(config *tls.Config) *Client {
c.client.TLSConfig = config
c.fasthttp.TLSConfig = config
return c
}

Expand Down Expand Up @@ -558,7 +558,7 @@ func (c *Client) SetDial(dial fasthttp.DialFunc) *Client {
c.mu.Lock()
defer c.mu.Unlock()

c.client.Dial = dial
c.fasthttp.Dial = dial
return c
}

Expand All @@ -578,7 +578,7 @@ func (c *Client) Logger() log.CommonLogger {

// Reset clear Client object
func (c *Client) Reset() {
c.client = &fasthttp.Client{}
c.fasthttp = &fasthttp.Client{}
c.baseURL = ""
c.timeout = 0
c.userAgent = ""
Expand Down Expand Up @@ -698,7 +698,7 @@ func NewClient() *Client {
// for the fiber client and the fasthttp client
// if possible also for other structs -> request header, cookie, query param, path param...
return &Client{
client: &fasthttp.Client{},
fasthttp: &fasthttp.Client{},
header: &Header{
RequestHeader: &fasthttp.RequestHeader{},
},
Expand Down
8 changes: 4 additions & 4 deletions client/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ func (c *core) execFunc() (*Response, error) {
if cfg != nil {
err = retry.NewExponentialBackoff(*cfg).Retry(func() error {
if c.req.maxRedirects > 0 && (string(reqv.Header.Method()) == fiber.MethodGet || string(reqv.Header.Method()) == fiber.MethodHead) {
return c.client.client.DoRedirects(reqv, respv, c.req.maxRedirects)
return c.client.fasthttp.DoRedirects(reqv, respv, c.req.maxRedirects)
}

return c.client.client.Do(reqv, respv)
return c.client.fasthttp.Do(reqv, respv)
})
} else {
if c.req.maxRedirects > 0 && (string(reqv.Header.Method()) == fiber.MethodGet || string(reqv.Header.Method()) == fiber.MethodHead) {
err = c.client.client.DoRedirects(reqv, respv, c.req.maxRedirects)
err = c.client.fasthttp.DoRedirects(reqv, respv, c.req.maxRedirects)
} else {
err = c.client.client.Do(reqv, respv)
err = c.client.fasthttp.Do(reqv, respv)
}
}

Expand Down

0 comments on commit 907b8a7

Please sign in to comment.