summaryrefslogtreecommitdiffstats
path: root/modules/httplib/httplib.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/httplib/httplib.go')
-rw-r--r--modules/httplib/httplib.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/httplib/httplib.go b/modules/httplib/httplib.go
index a1984400d6..e904d77e14 100644
--- a/modules/httplib/httplib.go
+++ b/modules/httplib/httplib.go
@@ -8,6 +8,7 @@ import (
"bytes"
"context"
"crypto/tls"
+ "fmt"
"io"
"net"
"net/http"
@@ -68,6 +69,11 @@ func (r *Request) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Re
return r
}
+func (r *Request) SetReadWriteTimeout(readWriteTimeout time.Duration) *Request {
+ r.setting.ReadWriteTimeout = readWriteTimeout
+ return r
+}
+
// SetTLSClientConfig sets tls connection configurations if visiting https url.
func (r *Request) SetTLSClientConfig(config *tls.Config) *Request {
r.setting.TLSClientConfig = config
@@ -138,11 +144,11 @@ func (r *Request) getResponse() (*http.Response, error) {
r.Body(paramBody)
}
- url, err := url.Parse(r.url)
+ var err error
+ r.req.URL, err = url.Parse(r.url)
if err != nil {
return nil, err
}
- r.req.URL = url
trans := r.setting.Transport
if trans == nil {
@@ -194,3 +200,7 @@ func TimeoutDialer(cTimeout time.Duration) func(ctx context.Context, net, addr s
return conn, nil
}
}
+
+func (r *Request) GoString() string {
+ return fmt.Sprintf("%s %s", r.req.Method, r.url)
+}