github.com/0chain/gosdk@v1.17.11/zcnbridge/http/client.go (about) 1 package http 2 3 import ( 4 "net/http" 5 "time" 6 7 "github.com/0chain/gosdk/zboxcore/zboxutil" 8 "github.com/hashicorp/go-retryablehttp" 9 ) 10 11 const ( 12 RetryWaitMax = 120 * time.Second 13 RetryMax = 60 14 ) 15 16 // NewClient creates default http.Client with timeouts. 17 func NewClient() *http.Client { 18 return &http.Client{ 19 Transport: zboxutil.DefaultTransport, 20 } 21 } 22 23 func CleanClient() *http.Client { 24 client := &http.Client{ 25 Transport: zboxutil.DefaultTransport, 26 } 27 client.Timeout = 250 * time.Second 28 return client 29 } 30 31 // NewRetryableClient creates default retryablehttp.Client with timeouts and embedded NewClient result. 32 func NewRetryableClient(verbose bool) *retryablehttp.Client { 33 client := retryablehttp.NewClient() 34 client.HTTPClient = &http.Client{ 35 Transport: zboxutil.DefaultTransport, 36 } 37 38 if !verbose { 39 client.Logger = nil 40 } 41 42 return client 43 }