You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
799 B
41 lines
799 B
package client
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"net/http"
|
|
"net/url"
|
|
"time"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
|
)
|
|
|
|
// NewLegacyHttpClient creates legacy HTTP Client
|
|
func NewLegacyHttpClient(cfg config.LegacyConfig) *http.Client {
|
|
transCfg := &http.Transport{
|
|
TLSClientConfig: &tls.Config{
|
|
//nolint:gosec
|
|
InsecureSkipVerify: cfg.SSLSkipVerify,
|
|
},
|
|
}
|
|
|
|
var expiredTime time.Time
|
|
|
|
if cfg.Token != "" {
|
|
expiredTime = time.Now().AddDate(0, 0, 1)
|
|
}
|
|
|
|
return &http.Client{
|
|
Transport: &transportLegacy{
|
|
base: transCfg,
|
|
username: url.QueryEscape(cfg.Username),
|
|
password: url.QueryEscape(cfg.Password),
|
|
retries: cfg.Retries,
|
|
token: cfg.Token,
|
|
decortURL: cfg.DecortURL,
|
|
expiryTime: expiredTime,
|
|
},
|
|
|
|
Timeout: cfg.Timeout.Get(),
|
|
}
|
|
}
|