Compare commits

...

2 Commits

Author SHA1 Message Date
kzkzzzz 5e26ddfbcd Merge branch 'main' of ssh://git.makemake.in:5566/kzkzzzz/mycommon 2025-08-09 10:20:59 +08:00
kzkzzzz 1bf5b0eec4 update 2025-08-09 10:20:45 +08:00
1 changed files with 5 additions and 8 deletions

View File

@ -16,28 +16,25 @@ import (
)
var (
defaultClient *HttpClient
noRedirectClient *HttpClient
defaultClient *HttpClient
)
func init() {
defaultClient = New()
noRedirectClient = New(WithNoRedirect())
}
func ReInitDefault(timeout time.Duration) {
defaultClient = New(WithTimout(timeout))
noRedirectClient = New(WithTimout(timeout), WithNoRedirect())
}
func ReInitDefaultOpt(opts ...ConfigOpt) {
defaultClient = New(opts...)
}
func Client() *HttpClient {
return defaultClient
}
func NoRedirectClient() *HttpClient {
return noRedirectClient
}
func NewTransport(maxConn int, idleTimeout time.Duration) *http.Transport {
if maxConn <= 0 {
panic("max connection <= 0")