mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	* github.com/yuin/goldmark v1.3.1 -> v1.3.2 * github.com/xanzy/go-gitlab v0.42.0 -> v0.44.0 * github.com/prometheus/client_golang v1.8.0 -> v1.9.0 * github.com/minio/minio-go v7.0.7 -> v7.0.9 * github.com/lafriks/xormstore v1.3.2 -> v1.4.0 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
package cleanhttp
 | 
						|
 | 
						|
import (
 | 
						|
	"net"
 | 
						|
	"net/http"
 | 
						|
	"runtime"
 | 
						|
	"time"
 | 
						|
)
 | 
						|
 | 
						|
// DefaultTransport returns a new http.Transport with similar default values to
 | 
						|
// http.DefaultTransport, but with idle connections and keepalives disabled.
 | 
						|
func DefaultTransport() *http.Transport {
 | 
						|
	transport := DefaultPooledTransport()
 | 
						|
	transport.DisableKeepAlives = true
 | 
						|
	transport.MaxIdleConnsPerHost = -1
 | 
						|
	return transport
 | 
						|
}
 | 
						|
 | 
						|
// DefaultPooledTransport returns a new http.Transport with similar default
 | 
						|
// values to http.DefaultTransport. Do not use this for transient transports as
 | 
						|
// it can leak file descriptors over time. Only use this for transports that
 | 
						|
// will be re-used for the same host(s).
 | 
						|
func DefaultPooledTransport() *http.Transport {
 | 
						|
	transport := &http.Transport{
 | 
						|
		Proxy: http.ProxyFromEnvironment,
 | 
						|
		DialContext: (&net.Dialer{
 | 
						|
			Timeout:   30 * time.Second,
 | 
						|
			KeepAlive: 30 * time.Second,
 | 
						|
			DualStack: true,
 | 
						|
		}).DialContext,
 | 
						|
		MaxIdleConns:          100,
 | 
						|
		IdleConnTimeout:       90 * time.Second,
 | 
						|
		TLSHandshakeTimeout:   10 * time.Second,
 | 
						|
		ExpectContinueTimeout: 1 * time.Second,
 | 
						|
		ForceAttemptHTTP2:     true,
 | 
						|
		MaxIdleConnsPerHost:   runtime.GOMAXPROCS(0) + 1,
 | 
						|
	}
 | 
						|
	return transport
 | 
						|
}
 | 
						|
 | 
						|
// DefaultClient returns a new http.Client with similar default values to
 | 
						|
// http.Client, but with a non-shared Transport, idle connections disabled, and
 | 
						|
// keepalives disabled.
 | 
						|
func DefaultClient() *http.Client {
 | 
						|
	return &http.Client{
 | 
						|
		Transport: DefaultTransport(),
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
// DefaultPooledClient returns a new http.Client with similar default values to
 | 
						|
// http.Client, but with a shared Transport. Do not use this function for
 | 
						|
// transient clients as it can leak file descriptors over time. Only use this
 | 
						|
// for clients that will be re-used for the same host(s).
 | 
						|
func DefaultPooledClient() *http.Client {
 | 
						|
	return &http.Client{
 | 
						|
		Transport: DefaultPooledTransport(),
 | 
						|
	}
 | 
						|
}
 |