|
@@ -12,10 +12,23 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
+
|
|
|
+ ReqContentTypeURL = `application/x-www-form-urlencoded; charset=utf-8`
|
|
|
+
|
|
|
+ ReqContentTypeJSON = `application/json; charset=utf-8`
|
|
|
+
|
|
|
+ ReqContentTypeXML = `application/xml; charset=utf-8`
|
|
|
+
|
|
|
+ ReqContentTypeMultipart = `multipart/form-data`
|
|
|
+
|
|
|
|
|
|
RequestTimeOut = 30
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ reqTimeOut = time.Duration(RequestTimeOut)
|
|
|
+)
|
|
|
+
|
|
|
|
|
|
func GetRealIP(req *http.Request) (ip string) {
|
|
|
if ips := req.Header["X-Real-Ip"]; ips != nil {
|
|
@@ -38,10 +51,10 @@ func newRequest(method, uri, certPath, keyPath string, header map[string]string,
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- conn.SetDeadline(time.Now().Add(time.Second * RequestTimeOut))
|
|
|
+ conn.SetDeadline(time.Now().Add(time.Second * reqTimeOut))
|
|
|
return conn, nil
|
|
|
},
|
|
|
- ResponseHeaderTimeout: time.Second * RequestTimeOut,
|
|
|
+ ResponseHeaderTimeout: time.Second * reqTimeOut,
|
|
|
}
|
|
|
|
|
|
if certPath != "" {
|