Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
link1st committed Aug 12, 2024
1 parent cf3c28d commit 482c0a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions model/request_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ func (r *Request) GetBody() (body io.Reader) {
return strings.NewReader(r.Body)
}

// CopyHeaders copy Headers
func (r *Request) CopyHeaders() map[string]string {
var result = make(map[string]string, len(r.Headers))
for k, v := range r.Headers {
result[k] = v
}
return result
}

// getVerifyKey 获取校验 key
func (r *Request) getVerifyKey() (key string) {
return fmt.Sprintf("%s.%s", r.Form, r.Verify)
Expand Down
2 changes: 1 addition & 1 deletion server/client/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func HTTPRequest(chanID uint64, request *model.Request) (resp *http.Response, re
url := request.URL
body := request.GetBody()
timeout := request.Timeout
headers := request.Headers
headers := request.CopyHeaders()

req, err := http.NewRequest(method, url, body)
if err != nil {
Expand Down

0 comments on commit 482c0a0

Please sign in to comment.