Skip to content

Commit

Permalink
fix: no need to send content-type header if no header sent (#91)
Browse files Browse the repository at this point in the history
* fix: no need to send content-type header if no header sent

close: #76

* Update gerrit.go

Co-authored-by: Andy Grunwald <andygrunwald@gmail.com>
  • Loading branch information
xobotyi and andygrunwald authored Jul 26, 2021
1 parent 9d38b0b commit cc4e14e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gerrit.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ
// Request compact JSON
// See https://gerrit-review.googlesource.com/Documentation/rest-api.html#output
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")

// No need to send the content type if there is no content
if body != nil {
req.Header.Add("Content-Type", "application/json")
}

// TODO: Add gzip encoding
// Accept-Encoding request header is set to gzip
Expand Down

0 comments on commit cc4e14e

Please sign in to comment.