Skip to content

Commit

Permalink
fix SetCommonContentType is not respected when SetBody is called (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Aug 11, 2023
1 parent 924664a commit ad9fd1e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,14 @@ func parseRequestBody(c *Client, r *Request) (err error) {
return
}
// body is in-memory []byte, so we can guess content type
if r.getHeader(header.ContentType) == "" {
r.SetContentType(http.DetectContentType(r.Body))

if c.Headers != nil && c.Headers.Get(header.ContentType) != "" { // ignore if content type set at client-level
return
}
if r.getHeader(header.ContentType) != "" { // ignore if content-type set at request-level
return
}
r.SetContentType(http.DetectContentType(r.Body))
return
}

Expand Down

0 comments on commit ad9fd1e

Please sign in to comment.