|
@@ -27,9 +27,11 @@ import (
|
|
jsoniter "github.com/json-iterator/go"
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
)
|
|
|
|
|
|
-var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
|
|
|
|
-var defaultCookieJar http.CookieJar
|
|
|
|
-var settingMutex sync.Mutex
|
|
|
|
|
|
+var (
|
|
|
|
+ defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
|
|
|
|
+ defaultCookieJar http.CookieJar
|
|
|
|
+ settingMutex sync.Mutex
|
|
|
|
+)
|
|
|
|
|
|
// createDefaultCookie creates a global cookiejar to store cookies.
|
|
// createDefaultCookie creates a global cookiejar to store cookies.
|
|
func createDefaultCookie() {
|
|
func createDefaultCookie() {
|
|
@@ -270,7 +272,7 @@ func (r *Request) getResponse() (*http.Response, error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
- //iocopy
|
|
|
|
|
|
+ // iocopy
|
|
_, err = io.Copy(fileWriter, fh)
|
|
_, err = io.Copy(fileWriter, fh)
|
|
_ = fh.Close()
|
|
_ = fh.Close()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -437,7 +439,7 @@ func (r *Request) Response() (*http.Response, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field.
|
|
// TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field.
|
|
-func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error) {
|
|
|
|
|
|
+func TimeoutDialer(cTimeout, rwTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error) {
|
|
return func(ctx context.Context, netw, addr string) (net.Conn, error) {
|
|
return func(ctx context.Context, netw, addr string) (net.Conn, error) {
|
|
conn, err := net.DialTimeout(netw, addr, cTimeout)
|
|
conn, err := net.DialTimeout(netw, addr, cTimeout)
|
|
if err != nil {
|
|
if err != nil {
|