mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
fix(rest/httpc): reject request body for HEAD method in buildRequest (#5457)
Co-authored-by: 1911860538 <alxps1911@gmail.com>
This commit is contained in:
@@ -84,8 +84,11 @@ func buildRequest(ctx context.Context, method, url string, data any) (*http.Requ
|
||||
var reader io.Reader
|
||||
jsonVars, hasJsonBody := val[jsonKey]
|
||||
if hasJsonBody {
|
||||
if method == http.MethodGet {
|
||||
switch method {
|
||||
case http.MethodGet:
|
||||
return nil, ErrGetWithBody
|
||||
case http.MethodHead:
|
||||
return nil, ErrHeadWithBody
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user