// "encoding/binary"
)
+var (
+ ConnectTimeoutErr = errors.New(ConnectTimeoutErr)
+ ReadTimeoutErr = errors.New(ReadTimeoutErr)
+)
+
type Rval struct {
Url string
PostStr string
var returnErr error
_val := val;
-
- if _val.Timeout==0{_val.Timeout=3000}
-
+
defer func(){
this.idp.Put(this.id)
}()
}
cx, cancel := context.WithCancel(context.Background())
- if Timeout != -1 {
+ if Timeout > 0 {
cx, _ = context.WithTimeout(cx,time.Duration(Timeout)*time.Millisecond)
}
req,_ := http.NewRequest(Method, Url, body)
return
}
case <-After(ConnectTimeout):
- err = context.DeadlineExceeded
+ err = ConnectTimeoutErr
return
}
break
}
case <-After(ReadTimeout):
- err = context.DeadlineExceeded
+ err = ReadTimeoutErr
loop = false
break
}
}
func IsTimeout(e error) bool {
- return errors.Is(e, context.DeadlineExceeded)
+ return errors.Is(e, context.DeadlineExceeded) || errors.Is(e, ConnectTimeoutErr) || errors.Is(e, ReadTimeoutErr)
}
func IsDnsErr(e error) bool {