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.

38 lines
780 B

  1. var common = require('../common');
  2. var formidable = common.formidable;
  3. var http = require('http');
  4. var assert = require('assert');
  5. var testData = {
  6. numbers: [1, 2, 3, 4, 5],
  7. nested: { key: 'value' }
  8. };
  9. var server = http.createServer(function(req, res) {
  10. var form = new formidable.IncomingForm();
  11. form.parse(req, function(err, fields, files) {
  12. assert.deepEqual(fields, testData);
  13. res.end();
  14. server.close();
  15. });
  16. });
  17. var port = common.port;
  18. server.listen(port, function(err){
  19. assert.equal(err, null);
  20. var request = http.request({
  21. port: port,
  22. method: 'POST',
  23. headers: {
  24. 'Content-Type': 'application/json'
  25. }
  26. });
  27. request.write(JSON.stringify(testData));
  28. request.end();
  29. });