This commit is contained in:
gospider
2025-08-15 11:14:01 +08:00
parent f7f37f2c2f
commit 69ad730363
2 changed files with 5 additions and 9 deletions

12
conn.go
View File

@@ -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)
}
}
}

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/gospider007/requests
go 1.24.0
go 1.25
require (
github.com/golang/snappy v1.0.0