From 47d303390169a842d085d113d1b84bd2c78dbb77 Mon Sep 17 00:00:00 2001 From: roc Date: Thu, 16 May 2024 19:02:00 +0800 Subject: [PATCH] fix: avoid repeated append cookies when retry (#353) --- middleware.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/middleware.go b/middleware.go index c554e89d..59cd46f5 100644 --- a/middleware.go +++ b/middleware.go @@ -2,8 +2,6 @@ package req import ( "bytes" - "github.com/imroc/req/v3/internal/header" - "github.com/imroc/req/v3/internal/util" "io" "mime/multipart" "net/http" @@ -14,6 +12,9 @@ import ( "reflect" "strings" "time" + + "github.com/imroc/req/v3/internal/header" + "github.com/imroc/req/v3/internal/util" ) type ( @@ -489,7 +490,7 @@ func parseRequestHeader(c *Client, r *Request) error { } func parseRequestCookie(c *Client, r *Request) error { - if len(c.Cookies) == 0 { + if len(c.Cookies) == 0 || r.RetryAttempt > 0 { return nil } r.Cookies = append(r.Cookies, c.Cookies...)