Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
Version Bump v2.2.0: Automatically add Content-Type: application/json…
Browse files Browse the repository at this point in the history
… when there is a request body
  • Loading branch information
thinkingserious committed Jun 11, 2016
1 parent 356c363 commit 2ab5938
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

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

## [2.2.0] - 2016-06-10
### Added
- Automatically add Content-Type: application/json when there is a request body

## [2.1.0] - 2016-06-08
### Added
- Cleaner request object initialization
Expand Down
1 change: 0 additions & 1 deletion examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var Client = require('../lib/client.js').Client
// These values persist across of subsequent calls, unless overidden.
var globalRequest = require('../lib/client.js').emptyRequest
globalRequest.host = 'api.sendgrid.com';
globalRequest.headers['Content-Type'] = 'application/json'
// You must add your SendGrid API Key to your OS Environment
globalRequest.headers['Authorization'] = 'Bearer '.concat(process.env.SENDGRID_API_KEY)
var client = new Client(globalRequest)
Expand Down
1 change: 1 addition & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function Client (globalRequest) {
if (!isEmpty(endpointRequest.body)) {
body = JSON.stringify(endpointRequest.body)
request.headers['Content-Length'] = body.length
request.headers['Content-Type'] = 'application/json'
}

return request
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"name": "sendgrid-rest",
"description": "HTTP REST client, simplified for Node.js.",
"version": "2.1.0",
"version": "2.2.0",
"homepage": "https://sendgrid.com",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe('Client', function () {
'/test?limit=100&offset=0',
'path equal to /test?limit=100&offset=0')
assert.equal(JSON.stringify(JSON.parse(response.body).headers),
'{"x-test":"test","content-length":20,"host":"api.test.com"}',
'headers equal {"x-test":"test","content-length":20,"host":"api.test.com"}')
'{"x-test":"test","content-length":20,"content-type":"application/json","host":"api.test.com"}',
'headers equal {"x-test":"test","content-length":20,"content-type":"application/json","host":"api.test.com"}')
assert.equal(JSON.stringify(response.headers),
'{"content-type":"application/json"}',
'response.headers equal {"content-type":"application/json"}')
Expand Down

0 comments on commit 2ab5938

Please sign in to comment.