Documentation
¶
Index ¶
Constants ¶
View Source
const MAX_REDIRECT_TIMES = 10
Variables ¶
View Source
var ( ErrRetryNeeded = errors.New("req need retry") ErrAbnormalRespCode = errors.New("abnormal resp code") )
View Source
var (
ErrIllegalParam = errors.New("param is illegal")
)
result must be an address
View Source
var ShouldRetry = func(code int, err error) bool { urlErr, ok := err.(*url.Error) if ok && urlErr.Timeout() { return true } if err == nil { return false } if strings.Contains(err.Error(), "use of closed network connection") { return true } if strings.Contains(err.Error(), "connection reset by peer") { return true } return false }
retry on timeout only
Functions ¶
This section is empty.
Types ¶
type HttpClient ¶
type HttpClient struct { *conf.HttpCfg ClientId string sync.RWMutex // contains filtered or unexported fields }
func NewHttpClient ¶
func NewHttpClient(cfg *conf.HttpCfg, user *conf.UserInfo, clientID string, log *util.ClientLogger, cfaCfg *conf.Config) *HttpClient
func (*HttpClient) Close ¶
func (h *HttpClient) Close()
func (*HttpClient) DoPostWithJson ¶
func (p *HttpClient) DoPostWithJson(api_uri string, params interface{}, result interface{}, log *util.ClientLogger) (err error)
func (*HttpClient) UpdateHosts ¶
func (h *HttpClient) UpdateHosts(Hosts string)
type RetryReader ¶
prevents problems when the same host tries
func (*RetryReader) Close ¶
func (p *RetryReader) Close() error
Click to show internal directories.
Click to hide internal directories.