This commit is contained in:
gospider
2025-04-09 10:18:00 +08:00
parent 064b6bbf41
commit 632ddbc93d
3 changed files with 6 additions and 7 deletions

View File

@@ -78,7 +78,10 @@ func (obj *clientConn) send() {
defer func() {
obj.task.readCnl(readErr)
}()
_, readErr = io.Copy(pw, rawBody)
noBody := obj.task.res.ContentLength == -1 && len(obj.task.res.TransferEncoding) == 0
if !noBody {
_, readErr = io.Copy(pw, rawBody)
}
pw.CloseWithError(readErr)
if readErr != nil && readErr != io.EOF && readErr != io.ErrUnexpectedEOF {
obj.task.err = tools.WrapError(readErr, "failed to read response body")