You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
810 B

  1. var assert = require('assert');
  2. var http = require('http');
  3. var net = require('net');
  4. var formidable = require('../../lib/index');
  5. var server = http.createServer(function (req, res) {
  6. var form = new formidable.IncomingForm();
  7. var aborted_received = false;
  8. form.on('aborted', function () {
  9. aborted_received = true;
  10. });
  11. form.on('error', function () {
  12. assert(aborted_received, 'Error event should follow aborted');
  13. server.close();
  14. });
  15. form.on('end', function () {
  16. throw new Error('Unexpected "end" event');
  17. });
  18. form.parse(req);
  19. }).listen(0, 'localhost', function () {
  20. var client = net.connect(server.address().port);
  21. client.write(
  22. "POST / HTTP/1.1\r\n" +
  23. "Content-Length: 70\r\n" +
  24. "Content-Type: multipart/form-data; boundary=foo\r\n\r\n");
  25. client.end();
  26. });