Comparing version 1.4.2 to 1.5.0
@@ -62,2 +62,10 @@ // Load modules | ||
// Set the content-length for the corresponding payload if none set | ||
if (payload && | ||
!this.headers.hasOwnProperty('content-length')) { | ||
this.headers['content-length'] = (Buffer.isBuffer(payload) ? payload.length : Buffer.byteLength(payload)).toString(); | ||
} | ||
this._shot = { | ||
@@ -64,0 +72,0 @@ payload: payload, |
{ | ||
"name": "shot", | ||
"description": "Injects a fake HTTP request/response into a node HTTP server", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"repository": "git://github.com/hapijs/shot", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -8,3 +8,3 @@ ![shot Logo](https://raw.github.com/hapijs/shot/master/images/shot.png) | ||
Lead Maintainer: [Chris Dickinson](https://github.com/chrisdickinson) | ||
Lead Maintainer: [Eran Hammer](https://github.com/hueniverse) | ||
@@ -11,0 +11,0 @@ For example: |
@@ -376,2 +376,34 @@ // Load modules | ||
}); | ||
it('adds a content-length header if none set when payload specified', function (done) { | ||
var dispatch = function (req, res) { | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end(req.headers['content-length']); | ||
}; | ||
Shot.inject(dispatch, { method: 'post', url: '/test', payload: { a: 1 } }, function (res) { | ||
expect(res.payload).to.equal('{"a":1}'.length.toString()); | ||
done(); | ||
}); | ||
}); | ||
it('retains a content-length header when payload specified', function (done) { | ||
var dispatch = function (req, res) { | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end(req.headers['content-length']); | ||
}; | ||
Shot.inject(dispatch, { method: 'post', url: '/test', payload: '', headers: { 'content-length': '10' } }, function (res) { | ||
expect(res.payload).to.equal('10'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -378,0 +410,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66315
619