long_string_spec.js 641 B

12345678910111213141516171819202122232425262728293031323334
  1. var needle = require('../'),
  2. should = require('should');
  3. describe('when posting a very long string', function() {
  4. this.timeout(20000);
  5. function get_string(length) {
  6. var str = '';
  7. for (var i = 0; i < length; i++) {
  8. str += 'x';
  9. }
  10. return str;
  11. }
  12. it("shouldn't throw an EPIPE error out of nowhere", function(done) {
  13. var error;
  14. function finished() {
  15. setTimeout(function() {
  16. should.not.exist(error);
  17. done();
  18. }, 300);
  19. }
  20. try {
  21. needle.post('https://google.com', { data: get_string(Math.pow(2, 20)) }, finished)
  22. } catch(e) {
  23. error = e;
  24. }
  25. })
  26. })