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

Commit 2ab5938

Browse files
Version Bump v2.2.0: Automatically add Content-Type: application/json when there is a request body
1 parent 356c363 commit 2ab5938

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
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.2.0] - 2016-06-10
7+
### Added
8+
- Automatically add Content-Type: application/json when there is a request body
9+
610
## [2.1.0] - 2016-06-08
711
### Added
812
- Cleaner request object initialization

examples/example.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var Client = require('../lib/client.js').Client
33
// These values persist across of subsequent calls, unless overidden.
44
var globalRequest = require('../lib/client.js').emptyRequest
55
globalRequest.host = 'api.sendgrid.com';
6-
globalRequest.headers['Content-Type'] = 'application/json'
76
// You must add your SendGrid API Key to your OS Environment
87
globalRequest.headers['Authorization'] = 'Bearer '.concat(process.env.SENDGRID_API_KEY)
98
var client = new Client(globalRequest)

lib/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function Client (globalRequest) {
7474
if (!isEmpty(endpointRequest.body)) {
7575
body = JSON.stringify(endpointRequest.body)
7676
request.headers['Content-Length'] = body.length
77+
request.headers['Content-Type'] = 'application/json'
7778
}
7879

7980
return request

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"name": "sendgrid-rest",
77
"description": "HTTP REST client, simplified for Node.js.",
8-
"version": "2.1.0",
8+
"version": "2.2.0",
99
"homepage": "https://sendgrid.com",
1010
"repository": {
1111
"type": "git",

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ describe('Client', function () {
6565
'/test?limit=100&offset=0',
6666
'path equal to /test?limit=100&offset=0')
6767
assert.equal(JSON.stringify(JSON.parse(response.body).headers),
68-
'{"x-test":"test","content-length":20,"host":"api.test.com"}',
69-
'headers equal {"x-test":"test","content-length":20,"host":"api.test.com"}')
68+
'{"x-test":"test","content-length":20,"content-type":"application/json","host":"api.test.com"}',
69+
'headers equal {"x-test":"test","content-length":20,"content-type":"application/json","host":"api.test.com"}')
7070
assert.equal(JSON.stringify(response.headers),
7171
'{"content-type":"application/json"}',
7272
'response.headers equal {"content-type":"application/json"}')

0 commit comments

Comments
 (0)