发送
This commit is contained in:
@@ -119,7 +119,7 @@ func (c *Curlx) WithAddress(ctx context.Context, addr string) {
|
||||
* 简单请求
|
||||
*/
|
||||
func (c *Curlx) Send(ctx context.Context, p ...Param) (res string, httpcode int, err error) {
|
||||
_, response, err := c.sendExec(ctx, p...)
|
||||
_, response, err := c.SendExec(ctx, p...)
|
||||
if err != nil {
|
||||
return "", -1, err
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (c *Curlx) Send(ctx context.Context, p ...Param) (res string, httpcode int,
|
||||
* 执行发送
|
||||
* 注意:外部使用需要加这一句 defer response.Body.Close()
|
||||
*/
|
||||
func (c *Curlx) sendExec(ctx context.Context, ps ...Param) (req *http.Request, resp *http.Response, err error) {
|
||||
func (c *Curlx) SendExec(ctx context.Context, ps ...Param) (req *http.Request, resp *http.Response, err error) {
|
||||
client := &http.Client{
|
||||
Timeout: c.opts.TimeOut, // 整个请求的超时时间 设置该条连接的超时
|
||||
Transport: c.transport, //
|
||||
@@ -236,7 +236,7 @@ func (c *Curlx) SendChan(ctx context.Context, ps ...Param) (<-chan string, error
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*30)
|
||||
defer cancel()
|
||||
|
||||
_, response, err := c.sendExec(ctx, ps...)
|
||||
_, response, err := c.SendExec(ctx, ps...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user