From 19a5df07bbfd82aedbf5fd7933408b1fb9f3def2 Mon Sep 17 00:00:00 2001 From: jjxu <428192774@qq.com> Date: Sun, 29 Oct 2023 23:16:35 +0800 Subject: [PATCH] update --- headers.go | 5 ----- simpleRequest.go | 7 +++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/headers.go b/headers.go index d248b5c..cedfc34 100644 --- a/headers.go +++ b/headers.go @@ -109,11 +109,6 @@ func (s *HeadersConf) ConentType_charsetUtf8() *HeadersConf { } func (s *HeadersConf) ConentType_formData() *HeadersConf { - //tmp := url.Values{} - - //for k, v := range s.simpleReq.BodyEntry { - // tmp.Add(k, fmt.Sprintf("%v", v)) - //} s.simpleReq.headers.Set(hdrContentTypeKey, formDataType) return s } diff --git a/simpleRequest.go b/simpleRequest.go index 4c693e0..148f35b 100644 --- a/simpleRequest.go +++ b/simpleRequest.go @@ -11,7 +11,6 @@ import ( "crypto/tls" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -160,7 +159,7 @@ func (s *SimpleRequest) do(request *http.Request) (body []byte, err error) { defer resp.Body.Close() //3.2 获取数据 - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) return } @@ -288,7 +287,7 @@ func (s *SimpleRequest) initBody() { s.body = parser.Unmarshal(s.BodyEntryMark, s.BodyEntries) case contentTypeData == "" || strings.Contains(contentTypeData, "form-urlencoded"): - //默认为x-www-form-urlencoded格式 + //default header type is "x-www-form-urlencoded" var parser, ok = s.bodyEntryParsers["form-urlencoded"] if !ok { tmpData := url.Values{} @@ -301,7 +300,7 @@ func (s *SimpleRequest) initBody() { } s.body = parser.Unmarshal(s.BodyEntryMark, s.BodyEntries) default: - //todo 自动判断数据类型 + //todo Automatically determine the data type tmpData := url.Values{} for k, v := range tmpData { tmpData.Set(k, fmt.Sprintf("%v", v))