Skip to content

Commit 4d618ed

Browse files
Version Bump v2.1.0: Automatically add Content-Type: application/json when there is a request body
1 parent 7c779cf commit 4d618ed

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [2.1.0] - 2016-06-10
7+
### Added
8+
- Automatically add Content-Type: application/json when there is a request body
9+
610
## [2.0.0] - 2016-06-03
711
### Changed
812
- Made the Response variables non-redundant. e.g. response.response_body becomes response.body

examples/example.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# This example uses the SendGrid API as an example
44
headers = JSON.parse('
55
{
6-
"Authorization": "Bearer ' + ENV['SENDGRID_API_KEY'] + '",
7-
"Content-Type": "application/json"
6+
"Authorization": "Bearer ' + ENV['SENDGRID_API_KEY'] + '"
87
}
98
')
109
host = 'https://api.sendgrid.com'

lib/ruby_http_client.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def build_request(name, args)
148148
request = net_http.new(uri.request_uri)
149149
request = build_request_headers(request)
150150
request.body = @request_body.to_json if @request_body
151+
if request.body
152+
request['Content-Type'] = 'application/json'
153+
end
151154
make_request(http, request)
152155
end
153156

ruby_http_client.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
44

55
Gem::Specification.new do |spec|
66
spec.name = 'ruby_http_client'
7-
spec.version = '2.0.0'
7+
spec.version = '2.1.0'
88
spec.authors = ['Elmer Thomas']
99
spec.email = '[email protected]'
1010
spec.summary = 'A simple REST client'

0 commit comments

Comments
 (0)