Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #382

Merged
merged 7 commits into from
Sep 5, 2024
Merged

Dev #382

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func (c *Client) appendRootCertData(data []byte) {
config.RootCAs = x509.NewCertPool()
}
config.RootCAs.AppendCertsFromPEM(data)
return
}

// SetRootCertFromString set root certificates from string.
Expand Down
5 changes: 1 addition & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,7 @@ func TestAutoDecode(t *testing.T) {
assertSuccess(t, resp, err)
tests.AssertEqual(t, "我是roc", resp.String())
resp, err = c.SetAutoDecodeContentTypeFunc(func(contentType string) bool {
if strings.Contains(contentType, "text") {
return true
}
return false
return strings.Contains(contentType, "text")
}).R().Get("/gbk")
assertSuccess(t, resp, err)
tests.AssertEqual(t, "我是roc", resp.String())
Expand Down
1 change: 0 additions & 1 deletion internal/altsvcutil/altsvcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (p *altAvcParser) Parse() (as []*altsvc.AltSvc, err error) {
}
}
}
return
}

func (p *altAvcParser) parseKv() (key, value string, haveNextField bool, err error) {
Expand Down
7 changes: 3 additions & 4 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func unmarshalBody(c *Client, r *Response, v interface{}) (err error) {
}
return c.jsonUnmarshal(body, v)
}
return
}

func defaultResultStateChecker(resp *Response) ResultState {
Expand Down Expand Up @@ -490,9 +489,9 @@ func parseRequestHeader(c *Client, r *Request) error {
}

func parseRequestCookie(c *Client, r *Request) error {
if len(c.Cookies) == 0 || r.RetryAttempt > 0 {
return nil
if len(c.Cookies) > 0 || r.RetryAttempt <= 0 {
r.Cookies = append(r.Cookies, c.Cookies...)
}
r.Cookies = append(r.Cookies, c.Cookies...)

return nil
}
8 changes: 4 additions & 4 deletions redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func SameHostRedirectPolicy() RedirectPolicy {
// AllowedHostRedirectPolicy allows redirect only if the redirected host
// match one of the host that specified.
func AllowedHostRedirectPolicy(hosts ...string) RedirectPolicy {
m := make(map[string]bool)
m := make(map[string]struct{})
for _, h := range hosts {
m[strings.ToLower(getHostname(h))] = true
m[strings.ToLower(getHostname(h))] = struct{}{}
}

return func(req *http.Request, via []*http.Request) error {
Expand All @@ -72,9 +72,9 @@ func AllowedHostRedirectPolicy(hosts ...string) RedirectPolicy {
// AllowedDomainRedirectPolicy allows redirect only if the redirected domain
// match one of the domain that specified.
func AllowedDomainRedirectPolicy(hosts ...string) RedirectPolicy {
domains := make(map[string]bool)
domains := make(map[string]struct{})
for _, h := range hosts {
domains[strings.ToLower(getDomain(h))] = true
domains[strings.ToLower(getDomain(h))] = struct{}{}
}

return func(req *http.Request, via []*http.Request) error {
Expand Down
Loading