test-emptyBody.js 549 B

1234567891011121314151617181920
  1. var request = require('../index')
  2. , http = require('http')
  3. , assert = require('assert')
  4. ;
  5. var s = http.createServer(function (req, resp) {
  6. resp.statusCode = 200
  7. resp.end('')
  8. }).listen(8080, function () {
  9. var r = request('http://localhost:8080', function (e, resp, body) {
  10. assert.equal(resp.statusCode, 200)
  11. assert.equal(body, "")
  12. var r2 = request({ url: 'http://localhost:8080', json: {} }, function (e, resp, body) {
  13. assert.equal(resp.statusCode, 200)
  14. assert.equal(body, undefined)
  15. s.close()
  16. });
  17. })
  18. })