[Pkg-javascript-commits] [node-multiparty] 03/05: Imported Upstream version 3.3.2

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Tue Sep 9 17:26:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-multiparty.

commit 32c2dd4d7c27a028640ee0a1ca844b14ced0512c
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Tue Sep 9 17:23:02 2014 +0000

    Imported Upstream version 3.3.2
---
 CHANGELOG.md                                      |  24 +++++++++--
 index.js                                          |  21 ++++++----
 package.json                                      |   3 +-
 test/fixture/http/encoding/pf1y5.png.http         | Bin 769113 -> 0 bytes
 test/fixture/js/encoding.js                       |  15 -------
 test/fixture/multi_video.upload                   | Bin 1953781 -> 0 bytes
 test/standalone/test-connection-aborted-closed.js |  44 +++++++++++++++++++
 test/standalone/test-issue-46.js                  |  49 ----------------------
 8 files changed, 79 insertions(+), 77 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5663f4a..3f6ce81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,31 @@
+### 3.3.2
+
+ * Douglas Christopher Wilson:
+   - Do not invoke callback after close 
+   - Share callback ending logic between error and close
+
+### 3.3.1
+
+ * Andrew Kelley:
+   - update request dev dependency to latest
+   - remove problematic test fixtures
+
 ### 3.3.0
 
- * Douglas Christopher Wilson (4):
-   - Expand form.parse in README
+ * Douglas Christopher Wilson:
    - Always emit close after all parts ended
+
+### 3.2.10
+
+ * Douglas Christopher Wilson:
+   - Expand form.parse in README
    - Remove execute bit from files
    - Fix callback hang in node.js 0.8 on errors
 
- * Andrew Kelley (1):
+ * Andrew Kelley:
    - tests refactor
 
- * Thanasis Polychronakis (1):
+ * Thanasis Polychronakis:
    - docs: fix code error in readme
 
 ### 3.2.9
diff --git a/index.js b/index.js
index 890dd37..dd3c7e0 100644
--- a/index.js
+++ b/index.js
@@ -89,9 +89,8 @@ Form.prototype.parse = function(req, cb) {
     self.autoFields = true;
     self.autoFiles = true;
 
-    var fields = {};
-    var files = {};
-    self.on('error', function(err) {
+    // wait for request to end before calling cb
+    var end = function (done) {
       if (called) return;
 
       called = true;
@@ -101,12 +100,18 @@ Form.prototype.parse = function(req, cb) {
         if (waitend && req.readable) {
           // dump rest of request
           req.resume();
-          req.once('end', function() {
-            cb(err);
-          });
+          req.once('end', done);
           return;
         }
 
+        done();
+      });
+    };
+
+    var fields = {};
+    var files = {};
+    self.on('error', function(err) {
+      end(function() {
         cb(err);
       });
     });
@@ -119,7 +124,9 @@ Form.prototype.parse = function(req, cb) {
       filesArray.push(file);
     });
     self.on('close', function() {
-      cb(null, fields, files);
+      end(function() {
+        cb(null, fields, files);
+      });
     });
   }
 
diff --git a/package.json b/package.json
index 260ae68..e0cd4d7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "multiparty",
-  "version": "3.3.0",
+  "version": "3.3.2",
   "description": "multipart/form-data parser which supports streaming",
   "repository": {
     "type": "git",
@@ -17,7 +17,6 @@
     "findit": "~2.0.0",
     "mkdirp": "~0.5.0",
     "pend": "~1.1.1",
-    "request": "~2.16.6",
     "rimraf": "~2.2.8",
     "superagent": "~0.18.0"
   },
diff --git a/test/fixture/http/encoding/pf1y5.png.http b/test/fixture/http/encoding/pf1y5.png.http
deleted file mode 100644
index 20c2c2d..0000000
Binary files a/test/fixture/http/encoding/pf1y5.png.http and /dev/null differ
diff --git a/test/fixture/js/encoding.js b/test/fixture/js/encoding.js
index 1ade965..bba1eea 100644
--- a/test/fixture/js/encoding.js
+++ b/test/fixture/js/encoding.js
@@ -52,18 +52,3 @@ module.exports['plain.txt.http'] = [
     size: 23,
   }
 ];
-
-module.exports['pf1y5.png.http'] = [
-  {
-    type: 'field',
-    name: 'path',
-  },
-  {
-    type: 'file',
-    name: 'upload',
-    filename: 'pf1y5.png',
-    fixture: 'pf1y5.png',
-    sha1: '805cc640c5b182e86f2b5c8ebf34ecf063cd34fd',
-    size: 768323,
-  }
-];
diff --git a/test/fixture/multi_video.upload b/test/fixture/multi_video.upload
deleted file mode 100644
index 9c82ba3..0000000
Binary files a/test/fixture/multi_video.upload and /dev/null differ
diff --git a/test/standalone/test-connection-aborted-closed.js b/test/standalone/test-connection-aborted-closed.js
new file mode 100644
index 0000000..1c3bc2c
--- /dev/null
+++ b/test/standalone/test-connection-aborted-closed.js
@@ -0,0 +1,44 @@
+var assert = require('assert');
+var http = require('http');
+var net = require('net');
+var multiparty = require('../../');
+
+var socket;
+var server = http.createServer(function (req, res) {
+  var called = false;
+  var form = new multiparty.Form();
+
+  form.parse(req, function (err, fields, files) {
+    assert.ok(!called);
+    called = true;
+
+    assert.ifError(err);
+    assert.equal(Object.keys(fields).length, 1);
+    socket.end();
+  });
+});
+
+server.listen(0, 'localhost', function () {
+  socket = net.connect(server.address().port, 'localhost', function () {
+    socket.write('POST / HTTP/1.1\r\n');
+    socket.write('Host: localhost\r\n');
+    socket.write('Connection: close\r\n');
+    socket.write('Content-Type: multipart/form-data; boundary=foo\r\n');
+    socket.write('Transfer-Encoding: chunked\r\n');
+    socket.write('\r\n');
+    socket.write('7\r\n');
+    socket.write('--foo\r\n\r\n');
+    socket.write('2D\r\n');
+    socket.write('Content-Disposition: form-data; name="data"\r\n\r\n');
+    socket.write('12\r\n');
+    socket.write('\r\nsome text here\r\n\r\n');
+    socket.write('7\r\n');
+    socket.write('--foo--\r\n');
+    socket.write('2\r\n');
+    socket.write('\r\n\r\n');
+    socket.write('0\r\n\r\n');
+    socket.on('close', function () {
+      server.close();
+    });
+  });
+});
diff --git a/test/standalone/test-issue-46.js b/test/standalone/test-issue-46.js
deleted file mode 100644
index 676b870..0000000
--- a/test/standalone/test-issue-46.js
+++ /dev/null
@@ -1,49 +0,0 @@
-var http       = require('http'),
-    multiparty = require('../../'),
-    request    = require('request'),
-    assert     = require('assert');
-
-var host = 'localhost';
-
-var index = [
-  '<form action="/" method="post" enctype="multipart/form-data">',
-  '  <input type="text" name="foo" />',
-  '  <input type="submit" />',
-  '</form>'
-].join("\n");
-
-var server = http.createServer(function(req, res) {
-
-  // Show a form for testing purposes.
-  if (req.method === 'GET') {
-    res.writeHead(200, {'content-type': 'text/html'});
-    res.end(index);
-    return;
-  }
-
-  // Parse form and write results to response.
-  var form = new multiparty.Form();
-  form.parse(req, function(err, fields, files) {
-    res.writeHead(200, {'content-type': 'text/plain'});
-    res.write(JSON.stringify({err: err, fields: fields, files: files}));
-    res.end();
-  });
-
-}).listen(0, host, function() {
-
-  //console.log("Server up and running...");
-
-  var server = this,
-      url    = 'http://' + host + ':' + server.address().port;
-
-  var parts  = [
-    {'Content-Disposition': 'form-data; name="foo"', 'body': 'bar'}
-  ]
-
-  var req = request({method: 'POST', url: url, multipart: parts}, function(e, res, body) {
-    var obj = JSON.parse(body);
-    assert.equal("bar", obj.fields.foo);
-    server.close();
-  });
-
-});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-multiparty.git



More information about the Pkg-javascript-commits mailing list