From 69ad7303637bc7476ebba73560b934ce721f4cb1 Mon Sep 17 00:00:00 2001 From: gospider <2216403312@qq.com> Date: Fri, 15 Aug 2025 11:14:01 +0800 Subject: [PATCH] sync --- conn.go | 12 ++++-------- go.mod | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/conn.go b/conn.go index 823afe3..cd32de3 100644 --- a/conn.go +++ b/conn.go @@ -23,20 +23,16 @@ func taskMain(conn http1.Conn, task *reqTask) (err error) { if err != nil { task.cnl(err) } else { - var bodyCtx context.Context - if task.reqCtx.response != nil && task.reqCtx.response.Body != nil { - bodyCtx = task.reqCtx.response.Body.(*http1.Body).Context() - } task.cnl(tools.ErrNoErr) - if bodyCtx != nil { + if bodyContext := conn.BodyContext(); bodyContext != nil { select { case <-task.reqCtx.Context().Done(): if context.Cause(task.reqCtx.Context()) != tools.ErrNoErr { err = context.Cause(task.reqCtx.Context()) } - case <-bodyCtx.Done(): - if context.Cause(bodyCtx) != tools.ErrNoErr { - err = context.Cause(bodyCtx) + case <-bodyContext.Done(): + if context.Cause(bodyContext) != tools.ErrNoErr { + err = context.Cause(bodyContext) } } } diff --git a/go.mod b/go.mod index 1d50eea..b17d6b9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gospider007/requests -go 1.24.0 +go 1.25 require ( github.com/golang/snappy v1.0.0