Skip to content

Commit

Permalink
feat(http): change init options adn remove trash code
Browse files Browse the repository at this point in the history
  • Loading branch information
bundleman committed Dec 9, 2021
1 parent 7380e89 commit 81220a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
10 changes: 5 additions & 5 deletions pkg/drivers/http/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ func NewDriver(opts ...Option) *Driver {
drv.options = NewOptions(opts)

drv.client = newHTTPClient(drv.options)
drv.client.Concurrency = drv.options.Concurrency
drv.client.MaxRetries = drv.options.MaxRetries
drv.client.Backoff = drv.options.Backoff

return drv
}

func newHTTPClient(options *Options) (httpClient *pester.Client) {
httpClient = pester.New()

httpClient.Concurrency = options.Concurrency
httpClient.MaxRetries = options.MaxRetries
httpClient.Backoff = options.Backoff
httpClient.Timeout = options.Timeout

if options.HTTPTransport != nil {
httpClient.Transport = options.HTTPTransport
}
Expand All @@ -55,8 +57,6 @@ func newHTTPClient(options *Options) (httpClient *pester.Client) {
return
}

httpClient = pester.NewExtendedClient(&http.Client{Transport: httpClient.Transport})

return
}

Expand Down
27 changes: 0 additions & 27 deletions pkg/drivers/http/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ func Test_newHTTPClientWithTransport(t *testing.T) {
HTTPTransport: httpTransport,
}},
},
{
name: "check transport exist with pester.NewExtendedClient()",
args: args{options: &Options{
Options: &drivers.Options{
Proxy: "http://0.0.0.0",
},
HTTPTransport: httpTransport,
}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -95,24 +86,6 @@ func Test_newHTTPClient(t *testing.T) {

So(hc, ShouldBeNil)
})

Convey("pester.NewExtend()", t, func() {
var (
client = newHTTPClient(&Options{
Options: &drivers.Options{
Proxy: "http://0.0.0.0",
},
})

rValue = reflect.ValueOf(client).Elem()
rField = rValue.Field(0)
)

rField = reflect.NewAt(rField.Type(), unsafe.Pointer(rField.UnsafeAddr())).Elem()
hc := rField.Interface().(*http.Client)

So(hc, ShouldNotBeNil)
})
}

func TestDriver_convertToUTF8(t *testing.T) {
Expand Down

0 comments on commit 81220a7

Please sign in to comment.