incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [47/51] [partial] Apache-ization, port to node.js
Date Wed, 15 Feb 2012 17:42:38 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js
new file mode 100644
index 0000000..9ca567c
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js
@@ -0,0 +1,312 @@
+var Buffer = require('buffer').Buffer,
+    s = 0,
+    S =
+    { PARSER_UNINITIALIZED: s++,
+      START: s++,
+      START_BOUNDARY: s++,
+      HEADER_FIELD_START: s++,
+      HEADER_FIELD: s++,
+      HEADER_VALUE_START: s++,
+      HEADER_VALUE: s++,
+      HEADER_VALUE_ALMOST_DONE: s++,
+      HEADERS_ALMOST_DONE: s++,
+      PART_DATA_START: s++,
+      PART_DATA: s++,
+      PART_END: s++,
+      END: s++,
+    },
+
+    f = 1,
+    F =
+    { PART_BOUNDARY: f,
+      LAST_BOUNDARY: f *= 2,
+    },
+
+    LF = 10,
+    CR = 13,
+    SPACE = 32,
+    HYPHEN = 45,
+    COLON = 58,
+    A = 97,
+    Z = 122,
+
+    lower = function(c) {
+      return c | 0x20;
+    };
+
+for (var s in S) {
+  exports[s] = S[s];
+}
+
+function MultipartParser() {
+  this.boundary = null;
+  this.boundaryChars = null;
+  this.lookbehind = null;
+  this.state = S.PARSER_UNINITIALIZED;
+
+  this.index = null;
+  this.flags = 0;
+};
+exports.MultipartParser = MultipartParser;
+
+MultipartParser.stateToString = function(stateNumber) {
+  for (var state in S) {
+    var number = S[state];
+    if (number === stateNumber) return state;
+  }
+};
+
+MultipartParser.prototype.initWithBoundary = function(str) {
+  this.boundary = new Buffer(str.length+4);
+  this.boundary.write('\r\n--', 'ascii', 0);
+  this.boundary.write(str, 'ascii', 4);
+  this.lookbehind = new Buffer(this.boundary.length+8);
+  this.state = S.START;
+
+  this.boundaryChars = {};
+  for (var i = 0; i < this.boundary.length; i++) {
+    this.boundaryChars[this.boundary[i]] = true;
+  }
+};
+
+MultipartParser.prototype.write = function(buffer) {
+  var self = this,
+      i = 0,
+      len = buffer.length,
+      prevIndex = this.index,
+      index = this.index,
+      state = this.state,
+      flags = this.flags,
+      lookbehind = this.lookbehind,
+      boundary = this.boundary,
+      boundaryChars = this.boundaryChars,
+      boundaryLength = this.boundary.length,
+      boundaryEnd = boundaryLength - 1,
+      bufferLength = buffer.length,
+      c,
+      cl,
+
+      mark = function(name) {
+        self[name+'Mark'] = i;
+      },
+      clear = function(name) {
+        delete self[name+'Mark'];
+      },
+      callback = function(name, buffer, start, end) {
+        if (start !== undefined && start === end) {
+          return;
+        }
+
+        var callbackSymbol = 'on'+name.substr(0, 1).toUpperCase()+name.substr(1);
+        if (callbackSymbol in self) {
+          self[callbackSymbol](buffer, start, end);
+        }
+      },
+      dataCallback = function(name, clear) {
+        var markSymbol = name+'Mark';
+        if (!(markSymbol in self)) {
+          return;
+        }
+
+        if (!clear) {
+          callback(name, buffer, self[markSymbol], buffer.length);
+          self[markSymbol] = 0;
+        } else {
+          callback(name, buffer, self[markSymbol], i);
+          delete self[markSymbol];
+        }
+      };
+
+  for (i = 0; i < len; i++) {
+    c = buffer[i];
+    switch (state) {
+      case S.PARSER_UNINITIALIZED:
+        return i;
+      case S.START:
+        index = 0;
+        state = S.START_BOUNDARY;
+      case S.START_BOUNDARY:
+        if (index == boundary.length - 2) {
+          if (c != CR) {
+            return i;
+          }
+          index++;
+          break;
+        } else if (index - 1 == boundary.length - 2) {
+          if (c != LF) {
+            return i;
+          }
+          index = 0;
+          callback('partBegin');
+          state = S.HEADER_FIELD_START;
+          break;
+        }
+
+        if (c != boundary[index+2]) {
+          return i;
+        }
+        index++;
+        break;
+      case S.HEADER_FIELD_START:
+        state = S.HEADER_FIELD;
+        mark('headerField');
+        index = 0;
+      case S.HEADER_FIELD:
+        if (c == CR) {
+          clear('headerField');
+          state = S.HEADERS_ALMOST_DONE;
+          break;
+        }
+
+        index++;
+        if (c == HYPHEN) {
+          break;
+        }
+
+        if (c == COLON) {
+          if (index == 1) {
+            // empty header field
+            return i;
+          }
+          dataCallback('headerField', true);
+          state = S.HEADER_VALUE_START;
+          break;
+        }
+
+        cl = lower(c);
+        if (cl < A || cl > Z) {
+          return i;
+        }
+        break;
+      case S.HEADER_VALUE_START:
+        if (c == SPACE) {
+          break;
+        }
+
+        mark('headerValue');
+        state = S.HEADER_VALUE;
+      case S.HEADER_VALUE:
+        if (c == CR) {
+          dataCallback('headerValue', true);
+          callback('headerEnd');
+          state = S.HEADER_VALUE_ALMOST_DONE;
+        }
+        break;
+      case S.HEADER_VALUE_ALMOST_DONE:
+        if (c != LF) {
+          return i;
+        }
+        state = S.HEADER_FIELD_START;
+        break;
+      case S.HEADERS_ALMOST_DONE:
+        if (c != LF) {
+          return i;
+        }
+
+        callback('headersEnd');
+        state = S.PART_DATA_START;
+        break;
+      case S.PART_DATA_START:
+        state = S.PART_DATA
+        mark('partData');
+      case S.PART_DATA:
+        prevIndex = index;
+
+        if (index == 0) {
+          // boyer-moore derrived algorithm to safely skip non-boundary data
+          i += boundaryEnd;
+          while (i < bufferLength && !(buffer[i] in boundaryChars)) {
+            i += boundaryLength;
+          }
+          i -= boundaryEnd;
+          c = buffer[i];
+        }
+
+        if (index < boundary.length) {
+          if (boundary[index] == c) {
+            if (index == 0) {
+              dataCallback('partData', true);
+            }
+            index++;
+          } else {
+            index = 0;
+          }
+        } else if (index == boundary.length) {
+          index++;
+          if (c == CR) {
+            // CR = part boundary
+            flags |= F.PART_BOUNDARY;
+          } else if (c == HYPHEN) {
+            // HYPHEN = end boundary
+            flags |= F.LAST_BOUNDARY;
+          } else {
+            index = 0;
+          }
+        } else if (index - 1 == boundary.length)  {
+          if (flags & F.PART_BOUNDARY) {
+            index = 0;
+            if (c == LF) {
+              // unset the PART_BOUNDARY flag
+              flags &= ~F.PART_BOUNDARY;
+              callback('partEnd');
+              callback('partBegin');
+              state = S.HEADER_FIELD_START;
+              break;
+            }
+          } else if (flags & F.LAST_BOUNDARY) {
+            if (c == HYPHEN) {
+              callback('partEnd');
+              callback('end');
+              state = S.END;
+            } else {
+              index = 0;
+            }
+          } else {
+            index = 0;
+          }
+        }
+
+        if (index > 0) {
+          // when matching a possible boundary, keep a lookbehind reference
+          // in case it turns out to be a false lead
+          lookbehind[index-1] = c;
+        } else if (prevIndex > 0) {
+          // if our boundary turned out to be rubbish, the captured lookbehind
+          // belongs to partData
+          callback('partData', lookbehind, 0, prevIndex);
+          prevIndex = 0;
+          mark('partData');
+
+          // reconsider the current character even so it interrupted the sequence
+          // it could be the beginning of a new sequence
+          i--;
+        }
+
+        break;
+      case S.END:
+        break;
+      default:
+        return i;
+    }
+  }
+
+  dataCallback('headerField');
+  dataCallback('headerValue');
+  dataCallback('partData');
+
+  this.index = index;
+  this.state = state;
+  this.flags = flags;
+
+  return len;
+};
+
+MultipartParser.prototype.end = function() {
+  if (this.state != S.END) {
+    return new Error('MultipartParser.end(): stream ended unexpectedly: ' + this.explain());
+  }
+};
+
+MultipartParser.prototype.explain = function() {
+  return 'state = ' + MultipartParser.stateToString(this.state);
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js
new file mode 100644
index 0000000..63f109e
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js
@@ -0,0 +1,25 @@
+if (global.GENTLY) require = GENTLY.hijack(require);
+
+// This is a buffering parser, not quite as nice as the multipart one.
+// If I find time I'll rewrite this to be fully streaming as well
+var querystring = require('querystring');
+
+function QuerystringParser() {
+  this.buffer = '';
+};
+exports.QuerystringParser = QuerystringParser;
+
+QuerystringParser.prototype.write = function(buffer) {
+  this.buffer += buffer.toString('ascii');
+  return buffer.length;
+};
+
+QuerystringParser.prototype.end = function() {
+  var fields = querystring.parse(this.buffer);
+  for (var field in fields) {
+    this.onField(field, fields[field]);
+  }
+  this.buffer = '';
+
+  this.onEnd();
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js
new file mode 100644
index 0000000..e9493e9
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js
@@ -0,0 +1,6 @@
+// Backwards compatibility ...
+try {
+  module.exports = require('util');
+} catch (e) {
+  module.exports = require('sys');
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js
new file mode 100644
index 0000000..eb432ad
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js
@@ -0,0 +1,19 @@
+var mysql = require('..');
+var path = require('path');
+
+var root = path.join(__dirname, '../');
+exports.dir = {
+  root    : root,
+  lib     : root + '/lib',
+  fixture : root + '/test/fixture',
+  tmp     : root + '/test/tmp',
+};
+
+exports.port = 13532;
+
+exports.formidable = require('..');
+exports.assert     = require('assert');
+
+exports.require = function(lib) {
+  return require(exports.dir.lib + '/' + lib);
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt
new file mode 100644
index 0000000..e7a4785
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt
@@ -0,0 +1 @@
+I am a text file with a funky name!

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt
new file mode 100644
index 0000000..9b6903e
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt
@@ -0,0 +1 @@
+I am a plain text file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http
new file mode 100644
index 0000000..e0dee27
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http
@@ -0,0 +1,13 @@
+POST /upload HTTP/1.1
+Host: localhost:8080
+Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG
+Content-Length: 1000
+
+------WebKitFormBoundarytyE4wkKlZ5CQJVTG
+Content-Disposition: form-data; name="upload"; filename=""
+Content-Type: text/plain
+
+I am a plain text file
+
+------WebKitFormBoundarytyE4wkKlZ5CQJVTG--
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md
new file mode 100644
index 0000000..3c9dbe3
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md
@@ -0,0 +1,3 @@
+* Opera does not allow submitting this file, it shows a warning to the
+  user that the file could not be found instead. Tested in 9.8, 11.51 on OSX.
+  Reported to Opera on 08.09.2011 (tracking email DSK-346009@bugs.opera.com).

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http
new file mode 100644
index 0000000..4ef3917
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http
@@ -0,0 +1,26 @@
+POST /upload HTTP/1.1
+Host: localhost:8080
+Connection: keep-alive
+Referer: http://localhost:8080/
+Content-Length: 383
+Cache-Control: max-age=0
+Origin: http://localhost:8080
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
+Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
+Accept-Encoding: gzip,deflate,sdch
+Accept-Language: en-US,en;q=0.8
+Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
+Cookie: jqCookieJar_tablesorter=%7B%22showListTable%22%3A%5B%5B5%2C1%5D%2C%5B1%2C0%5D%5D%7D
+
+------WebKitFormBoundarytyE4wkKlZ5CQJVTG
+Content-Disposition: form-data; name="title"
+
+Weird filename
+------WebKitFormBoundarytyE4wkKlZ5CQJVTG
+Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: text/plain
+
+I am a text file with a funky name!
+
+------WebKitFormBoundarytyE4wkKlZ5CQJVTG--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http
new file mode 100644
index 0000000..bf49f85
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http
@@ -0,0 +1,24 @@
+POST /upload HTTP/1.1
+Host: localhost:8080
+User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
+Accept-Language: en-us,en;q=0.5
+Accept-Encoding: gzip,deflate
+Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
+Keep-Alive: 115
+Connection: keep-alive
+Referer: http://localhost:8080/
+Content-Type: multipart/form-data; boundary=---------------------------9849436581144108930470211272
+Content-Length: 438
+
+-----------------------------9849436581144108930470211272
+Content-Disposition: form-data; name="title"
+
+Weird filename
+-----------------------------9849436581144108930470211272
+Content-Disposition: form-data; name="upload"; filename=": \ ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: text/plain
+
+I am a text file with a funky name!
+
+-----------------------------9849436581144108930470211272--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http
new file mode 100644
index 0000000..ff158a4
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http
@@ -0,0 +1,23 @@
+POST /upload HTTP/1.1
+Host: localhost:8080
+Origin: http://localhost:8080
+Content-Length: 383
+User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
+Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQJZ1gvhvdgfisJPJ
+Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
+Referer: http://localhost:8080/
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+Connection: keep-alive
+
+------WebKitFormBoundaryQJZ1gvhvdgfisJPJ
+Content-Disposition: form-data; name="title"
+
+Weird filename
+------WebKitFormBoundaryQJZ1gvhvdgfisJPJ
+Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: text/plain
+
+I am a text file with a funky name!
+
+------WebKitFormBoundaryQJZ1gvhvdgfisJPJ--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http
new file mode 100644
index 0000000..f0fc533
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http
@@ -0,0 +1,24 @@
+POST /upload HTTP/1.1
+Host: 192.168.56.1:8080
+Connection: keep-alive
+Referer: http://192.168.56.1:8080/
+Content-Length: 344
+Cache-Control: max-age=0
+Origin: http://192.168.56.1:8080
+User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30
+Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryEvqBNplR3ByrwQPa
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
+Accept-Encoding: gzip,deflate,sdch
+Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
+Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
+
+------WebKitFormBoundaryEvqBNplR3ByrwQPa
+Content-Disposition: form-data; name="title"
+
+Weird filename
+------WebKitFormBoundaryEvqBNplR3ByrwQPa
+Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: text/plain
+
+
+------WebKitFormBoundaryEvqBNplR3ByrwQPa--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http
new file mode 100644
index 0000000..2e2c61c
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http
@@ -0,0 +1,22 @@
+POST /upload HTTP/1.1
+Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */*
+Referer: http://192.168.56.1:8080/
+Accept-Language: de
+User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
+Content-Type: multipart/form-data; boundary=---------------------------7db1fe232017c
+Accept-Encoding: gzip, deflate
+Host: 192.168.56.1:8080
+Content-Length: 368
+Connection: Keep-Alive
+Cache-Control: no-cache
+
+-----------------------------7db1fe232017c
+Content-Disposition: form-data; name="title"
+
+Weird filename
+-----------------------------7db1fe232017c
+Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: application/octet-stream
+
+
+-----------------------------7db1fe232017c--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http
new file mode 100644
index 0000000..e2b94fa
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http
@@ -0,0 +1,22 @@
+POST /upload HTTP/1.1
+Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */*
+Referer: http://192.168.56.1:8080/
+Accept-Language: de
+User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
+Content-Type: multipart/form-data; boundary=---------------------------7db3a8372017c
+Accept-Encoding: gzip, deflate
+Host: 192.168.56.1:8080
+Content-Length: 368
+Connection: Keep-Alive
+Cache-Control: no-cache
+
+-----------------------------7db3a8372017c
+Content-Disposition: form-data; name="title"
+
+Weird filename
+-----------------------------7db3a8372017c
+Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: application/octet-stream
+
+
+-----------------------------7db3a8372017c--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http
new file mode 100644
index 0000000..6379ac0
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http
@@ -0,0 +1,22 @@
+POST /upload HTTP/1.1
+Host: 192.168.56.1:8080
+Referer: http://192.168.56.1:8080/
+Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
+Accept-Language: en-US
+Origin: http://192.168.56.1:8080
+User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
+Accept-Encoding: gzip, deflate
+Content-Type: multipart/form-data; boundary=----WebKitFormBoundarykmaWSUbu697WN9TM
+Content-Length: 344
+Connection: keep-alive
+
+------WebKitFormBoundarykmaWSUbu697WN9TM
+Content-Disposition: form-data; name="title"
+
+Weird filename
+------WebKitFormBoundarykmaWSUbu697WN9TM
+Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
+Content-Type: text/plain
+
+
+------WebKitFormBoundarykmaWSUbu697WN9TM--

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js
new file mode 100644
index 0000000..0bae449
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js
@@ -0,0 +1,3 @@
+module.exports['generic.http'] = [
+  {type: 'file', name: 'upload', filename: '', fixture: 'plain.txt'},
+];

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js
new file mode 100644
index 0000000..eb76fdc
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js
@@ -0,0 +1,21 @@
+var properFilename = 'funkyfilename.txt';
+
+function expect(filename) {
+  return [
+    {type: 'field', name: 'title', value: 'Weird filename'},
+    {type: 'file', name: 'upload', filename: filename, fixture: properFilename},
+  ];
+};
+
+var webkit = " ? % * | \" < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt";
+var ffOrIe = " ? % * | \" < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt";
+
+module.exports = {
+  'osx-chrome-13.http'   : expect(webkit),
+  'osx-firefox-3.6.http' : expect(ffOrIe),
+  'osx-safari-5.http'    : expect(webkit),
+  'xp-chrome-12.http'    : expect(webkit),
+  'xp-ie-7.http'         : expect(ffOrIe),
+  'xp-ie-8.http'         : expect(ffOrIe),
+  'xp-safari-5.http'     : expect(webkit),
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js
new file mode 100644
index 0000000..a476169
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js
@@ -0,0 +1,72 @@
+exports['rfc1867'] =
+  { boundary: 'AaB03x',
+    raw:
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="field1"\r\n'+
+      '\r\n'+
+      'Joe Blow\r\nalmost tricked you!\r\n'+
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+
+      'Content-Type: text/plain\r\n'+
+      '\r\n'+
+      '... contents of file1.txt ...\r\r\n'+
+      '--AaB03x--\r\n',
+    parts:
+    [ { headers: {
+          'content-disposition': 'form-data; name="field1"',
+        },
+        data: 'Joe Blow\r\nalmost tricked you!',
+      },
+      { headers: {
+          'content-disposition': 'form-data; name="pics"; filename="file1.txt"',
+          'Content-Type': 'text/plain',
+        },
+        data: '... contents of file1.txt ...\r',
+      }
+    ]
+  };
+
+exports['noTrailing\r\n'] =
+  { boundary: 'AaB03x',
+    raw:
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="field1"\r\n'+
+      '\r\n'+
+      'Joe Blow\r\nalmost tricked you!\r\n'+
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+
+      'Content-Type: text/plain\r\n'+
+      '\r\n'+
+      '... contents of file1.txt ...\r\r\n'+
+      '--AaB03x--',
+    parts:
+    [ { headers: {
+          'content-disposition': 'form-data; name="field1"',
+        },
+        data: 'Joe Blow\r\nalmost tricked you!',
+      },
+      { headers: {
+          'content-disposition': 'form-data; name="pics"; filename="file1.txt"',
+          'Content-Type': 'text/plain',
+        },
+        data: '... contents of file1.txt ...\r',
+      }
+    ]
+  };
+
+exports['emptyHeader'] =
+  { boundary: 'AaB03x',
+    raw:
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="field1"\r\n'+
+      ': foo\r\n'+
+      '\r\n'+
+      'Joe Blow\r\nalmost tricked you!\r\n'+
+      '--AaB03x\r\n'+
+      'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+
+      'Content-Type: text/plain\r\n'+
+      '\r\n'+
+      '... contents of file1.txt ...\r\r\n'+
+      '--AaB03x--\r\n',
+    expectError: true,
+  };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js
new file mode 100644
index 0000000..66ad259
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js
@@ -0,0 +1,89 @@
+var hashish = require('hashish');
+var fs = require('fs');
+var findit = require('findit');
+var path = require('path');
+var http = require('http');
+var net = require('net');
+var assert = require('assert');
+
+var common = require('../common');
+var formidable = common.formidable;
+
+var server = http.createServer();
+server.listen(common.port, findFixtures);
+
+function findFixtures() {
+  var fixtures = [];
+  findit
+    .sync(common.dir.fixture + '/js')
+    .forEach(function(jsPath) {
+      if (!/\.js$/.test(jsPath)) return;
+
+      var group = path.basename(jsPath, '.js');
+      hashish.forEach(require(jsPath), function(fixture, name) {
+        fixtures.push({
+          name    : group + '/' + name,
+          fixture : fixture,
+        });
+      });
+    });
+
+  testNext(fixtures);
+}
+
+function testNext(fixtures) {
+  var fixture = fixtures.shift();
+  if (!fixture) return server.close();
+
+  var name    = fixture.name;
+  var fixture = fixture.fixture;
+
+  uploadFixture(name, function(err, parts) {
+    if (err) throw err;
+
+    fixture.forEach(function(expectedPart, i) {
+      var parsedPart = parts[i];
+      assert.equal(parsedPart.type, expectedPart.type);
+      assert.equal(parsedPart.name, expectedPart.name);
+
+      if (parsedPart.type === 'file') {
+        var filename = parsedPart.value.name;
+        assert.equal(filename, expectedPart.filename);
+      }
+    });
+
+    testNext(fixtures);
+  });
+};
+
+function uploadFixture(name, cb) {
+  server.once('request', function(req, res) {
+    var form = new formidable.IncomingForm();
+    form.uploadDir = common.dir.tmp;
+    form.parse(req);
+
+    function callback() {
+      var realCallback = cb;
+      cb = function() {};
+      realCallback.apply(null, arguments);
+    }
+
+    var parts = [];
+    form
+      .on('error', callback)
+      .on('fileBegin', function(name, value) {
+        parts.push({type: 'file', name: name, value: value});
+      })
+      .on('field', function(name, value) {
+        parts.push({type: 'field', name: name, value: value});
+      })
+      .on('end', function() {
+        callback(null, parts);
+      });
+  });
+
+  var socket = net.createConnection(common.port);
+  var file = fs.createReadStream(common.dir.fixture + '/http/' + name);
+
+  file.pipe(socket);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js
new file mode 100644
index 0000000..2b98598
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js
@@ -0,0 +1,24 @@
+var path = require('path'),
+    fs = require('fs');
+
+try {
+  global.Gently = require('gently');
+} catch (e) {
+  throw new Error('this test suite requires node-gently');
+}
+
+exports.lib = path.join(__dirname, '../../lib');
+
+global.GENTLY = new Gently();
+
+global.assert = require('assert');
+global.TEST_PORT = 13532;
+global.TEST_FIXTURES = path.join(__dirname, '../fixture');
+global.TEST_TMP = path.join(__dirname, '../tmp');
+
+// Stupid new feature in node that complains about gently attaching too many
+// listeners to process 'exit'. This is a workaround until I can think of a
+// better way to deal with this.
+if (process.setMaxListeners) {
+  process.setMaxListeners(10000);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js
new file mode 100644
index 0000000..75232aa
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js
@@ -0,0 +1,80 @@
+var common = require('../common');
+var CHUNK_LENGTH = 10,
+    multipartParser = require(common.lib + '/multipart_parser'),
+    MultipartParser = multipartParser.MultipartParser,
+    parser = new MultipartParser(),
+    fixtures = require(TEST_FIXTURES + '/multipart'),
+    Buffer = require('buffer').Buffer;
+
+Object.keys(fixtures).forEach(function(name) {
+  var fixture = fixtures[name],
+      buffer = new Buffer(Buffer.byteLength(fixture.raw, 'binary')),
+      offset = 0,
+      chunk,
+      nparsed,
+
+      parts = [],
+      part = null,
+      headerField,
+      headerValue,
+      endCalled = '';
+
+  parser.initWithBoundary(fixture.boundary);
+  parser.onPartBegin = function() {
+    part = {headers: {}, data: ''};
+    parts.push(part);
+    headerField = '';
+    headerValue = '';
+  };
+
+  parser.onHeaderField = function(b, start, end) {
+    headerField += b.toString('ascii', start, end);
+  };
+
+  parser.onHeaderValue = function(b, start, end) {
+    headerValue += b.toString('ascii', start, end);
+  }
+
+  parser.onHeaderEnd = function() {
+    part.headers[headerField] = headerValue;
+    headerField = '';
+    headerValue = '';
+  };
+
+  parser.onPartData = function(b, start, end) {
+    var str = b.toString('ascii', start, end);
+    part.data += b.slice(start, end);
+  }
+
+  parser.onEnd = function() {
+    endCalled = true;
+  }
+
+  buffer.write(fixture.raw, 'binary', 0);
+
+  while (offset < buffer.length) {
+    if (offset + CHUNK_LENGTH < buffer.length) {
+      chunk = buffer.slice(offset, offset+CHUNK_LENGTH);
+    } else {
+      chunk = buffer.slice(offset, buffer.length);
+    }
+    offset = offset + CHUNK_LENGTH;
+
+    nparsed = parser.write(chunk);
+    if (nparsed != chunk.length) {
+      if (fixture.expectError) {
+        return;
+      }
+      puts('-- ERROR --');
+      p(chunk.toString('ascii'));
+      throw new Error(chunk.length+' bytes written, but only '+nparsed+' bytes parsed!');
+    }
+  }
+
+  if (fixture.expectError) {
+    throw new Error('expected parse error did not happen');
+  }
+
+  assert.ok(endCalled);
+  assert.deepEqual(parts, fixture.parts);
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js
new file mode 100644
index 0000000..52ceedb
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js
@@ -0,0 +1,104 @@
+var common = require('../common');
+var WriteStreamStub = GENTLY.stub('fs', 'WriteStream');
+
+var File = require(common.lib + '/file'),
+    EventEmitter = require('events').EventEmitter,
+    file,
+    gently;
+
+function test(test) {
+  gently = new Gently();
+  file = new File();
+  test();
+  gently.verify(test.name);
+}
+
+test(function constructor() {
+  assert.ok(file instanceof EventEmitter);
+  assert.strictEqual(file.size, 0);
+  assert.strictEqual(file.path, null);
+  assert.strictEqual(file.name, null);
+  assert.strictEqual(file.type, null);
+  assert.strictEqual(file.lastModifiedDate, null);
+
+  assert.strictEqual(file._writeStream, null);
+
+  (function testSetProperties() {
+    var file2 = new File({foo: 'bar'});
+    assert.equal(file2.foo, 'bar');
+  })();
+});
+
+test(function open() {
+  var WRITE_STREAM;
+  file.path = '/foo';
+
+  gently.expect(WriteStreamStub, 'new', function (path) {
+    WRITE_STREAM = this;
+    assert.strictEqual(path, file.path);
+  });
+
+  file.open();
+  assert.strictEqual(file._writeStream, WRITE_STREAM);
+});
+
+test(function write() {
+  var BUFFER = {length: 10},
+      CB_STUB,
+      CB = function() {
+        CB_STUB.apply(this, arguments);
+      };
+
+  file._writeStream = {};
+
+  gently.expect(file._writeStream, 'write', function (buffer, cb) {
+    assert.strictEqual(buffer, BUFFER);
+
+    gently.expect(file, 'emit', function (event, bytesWritten) {
+      assert.ok(file.lastModifiedDate instanceof Date);
+      assert.equal(event, 'progress');
+      assert.equal(bytesWritten, file.size);
+    });
+
+    CB_STUB = gently.expect(function writeCb() {
+      assert.equal(file.size, 10);
+    });
+
+    cb();
+
+    gently.expect(file, 'emit', function (event, bytesWritten) {
+      assert.equal(event, 'progress');
+      assert.equal(bytesWritten, file.size);
+    });
+
+    CB_STUB = gently.expect(function writeCb() {
+      assert.equal(file.size, 20);
+    });
+
+    cb();
+  });
+
+  file.write(BUFFER, CB);
+});
+
+test(function end() {
+  var CB_STUB,
+      CB = function() {
+        CB_STUB.apply(this, arguments);
+      };
+
+  file._writeStream = {};
+
+  gently.expect(file._writeStream, 'end', function (cb) {
+    gently.expect(file, 'emit', function (event) {
+      assert.equal(event, 'end');
+    });
+
+    CB_STUB = gently.expect(function endCb() {
+    });
+
+    cb();
+  });
+
+  file.end(CB);
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js
new file mode 100644
index 0000000..de2bd0c
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js
@@ -0,0 +1,715 @@
+var common = require('../common');
+var MultipartParserStub = GENTLY.stub('./multipart_parser', 'MultipartParser'),
+    QuerystringParserStub = GENTLY.stub('./querystring_parser', 'QuerystringParser'),
+    EventEmitterStub = GENTLY.stub('events', 'EventEmitter'),
+    FileStub = GENTLY.stub('./file');
+
+var formidable = require(common.lib + '/index'),
+    IncomingForm = formidable.IncomingForm,
+    events = require('events'),
+    fs = require('fs'),
+    path = require('path'),
+    Buffer = require('buffer').Buffer,
+    fixtures = require(TEST_FIXTURES + '/multipart'),
+    form,
+    gently;
+
+function test(test) {
+  gently = new Gently();
+  gently.expect(EventEmitterStub, 'call');
+  form = new IncomingForm();
+  test();
+  gently.verify(test.name);
+}
+
+test(function constructor() {
+  assert.strictEqual(form.error, null);
+  assert.strictEqual(form.ended, false);
+  assert.strictEqual(form.type, null);
+  assert.strictEqual(form.headers, null);
+  assert.strictEqual(form.keepExtensions, false);
+  assert.strictEqual(form.uploadDir, '/tmp');
+  assert.strictEqual(form.encoding, 'utf-8');
+  assert.strictEqual(form.bytesReceived, null);
+  assert.strictEqual(form.bytesExpected, null);
+  assert.strictEqual(form.maxFieldsSize, 2 * 1024 * 1024);
+  assert.strictEqual(form._parser, null);
+  assert.strictEqual(form._flushing, 0);
+  assert.strictEqual(form._fieldsSize, 0);
+  assert.ok(form instanceof EventEmitterStub);
+  assert.equal(form.constructor.name, 'IncomingForm');
+
+  (function testSimpleConstructor() {
+    gently.expect(EventEmitterStub, 'call');
+    var form = IncomingForm();
+    assert.ok(form instanceof IncomingForm);
+  })();
+
+  (function testSimpleConstructorShortcut() {
+    gently.expect(EventEmitterStub, 'call');
+    var form = formidable();
+    assert.ok(form instanceof IncomingForm);
+  })();
+});
+
+test(function parse() {
+  var REQ = {headers: {}}
+    , emit = {};
+
+  gently.expect(form, 'writeHeaders', function(headers) {
+    assert.strictEqual(headers, REQ.headers);
+  });
+
+  var events = ['error', 'aborted', 'data', 'end'];
+  gently.expect(REQ, 'on', events.length, function(event, fn) {
+    assert.equal(event, events.shift());
+    emit[event] = fn;
+    return this;
+  });
+
+  form.parse(REQ);
+
+  (function testPause() {
+    gently.expect(REQ, 'pause');
+    assert.strictEqual(form.pause(), true);
+  })();
+
+  (function testPauseCriticalException() {
+    form.ended = false;
+
+    var ERR = new Error('dasdsa');
+    gently.expect(REQ, 'pause', function() {
+      throw ERR;
+    });
+
+    gently.expect(form, '_error', function(err) {
+      assert.strictEqual(err, ERR);
+    });
+
+    assert.strictEqual(form.pause(), false);
+  })();
+
+  (function testPauseHarmlessException() {
+    form.ended = true;
+
+    var ERR = new Error('dasdsa');
+    gently.expect(REQ, 'pause', function() {
+      throw ERR;
+    });
+
+    assert.strictEqual(form.pause(), false);
+  })();
+
+  (function testResume() {
+    gently.expect(REQ, 'resume');
+    assert.strictEqual(form.resume(), true);
+  })();
+
+  (function testResumeCriticalException() {
+    form.ended = false;
+
+    var ERR = new Error('dasdsa');
+    gently.expect(REQ, 'resume', function() {
+      throw ERR;
+    });
+
+    gently.expect(form, '_error', function(err) {
+      assert.strictEqual(err, ERR);
+    });
+
+    assert.strictEqual(form.resume(), false);
+  })();
+
+  (function testResumeHarmlessException() {
+    form.ended = true;
+
+    var ERR = new Error('dasdsa');
+    gently.expect(REQ, 'resume', function() {
+      throw ERR;
+    });
+
+    assert.strictEqual(form.resume(), false);
+  })();
+
+  (function testEmitError() {
+    var ERR = new Error('something bad happened');
+    gently.expect(form, '_error',function(err) {
+      assert.strictEqual(err, ERR);
+    });
+    emit.error(ERR);
+  })();
+
+  (function testEmitAborted() {
+    gently.expect(form, 'emit',function(event) {
+      assert.equal(event, 'aborted');
+    });
+
+    emit.aborted();
+  })();
+
+
+  (function testEmitData() {
+    var BUFFER = [1, 2, 3];
+    gently.expect(form, 'write', function(buffer) {
+      assert.strictEqual(buffer, BUFFER);
+    });
+    emit.data(BUFFER);
+  })();
+
+  (function testEmitEnd() {
+    form._parser = {};
+
+    (function testWithError() {
+      var ERR = new Error('haha');
+      gently.expect(form._parser, 'end', function() {
+        return ERR;
+      });
+
+      gently.expect(form, '_error', function(err) {
+        assert.strictEqual(err, ERR);
+      });
+
+      emit.end();
+    })();
+
+    (function testWithoutError() {
+      gently.expect(form._parser, 'end');
+      emit.end();
+    })();
+
+    (function testAfterError() {
+      form.error = true;
+      emit.end();
+    })();
+  })();
+
+  (function testWithCallback() {
+    gently.expect(EventEmitterStub, 'call');
+    var form = new IncomingForm(),
+        REQ = {headers: {}},
+        parseCalled = 0;
+
+    gently.expect(form, 'writeHeaders');
+    gently.expect(REQ, 'on', 4, function() {
+      return this;
+    });
+
+    gently.expect(form, 'on', 4, function(event, fn) {
+      if (event == 'field') {
+        fn('field1', 'foo');
+        fn('field1', 'bar');
+        fn('field2', 'nice');
+      }
+
+      if (event == 'file') {
+        fn('file1', '1');
+        fn('file1', '2');
+        fn('file2', '3');
+      }
+
+      if (event == 'end') {
+        fn();
+      }
+      return this;
+    });
+
+    form.parse(REQ, gently.expect(function parseCbOk(err, fields, files) {
+      assert.deepEqual(fields, {field1: 'bar', field2: 'nice'});
+      assert.deepEqual(files, {file1: '2', file2: '3'});
+    }));
+
+    gently.expect(form, 'writeHeaders');
+    gently.expect(REQ, 'on', 4, function() {
+      return this;
+    });
+
+    var ERR = new Error('test');
+    gently.expect(form, 'on', 3, function(event, fn) {
+      if (event == 'field') {
+        fn('foo', 'bar');
+      }
+
+      if (event == 'error') {
+        fn(ERR);
+        gently.expect(form, 'on');
+      }
+      return this;
+    });
+
+    form.parse(REQ, gently.expect(function parseCbErr(err, fields, files) {
+      assert.strictEqual(err, ERR);
+      assert.deepEqual(fields, {foo: 'bar'});
+    }));
+  })();
+});
+
+test(function pause() {
+  assert.strictEqual(form.pause(), false);
+});
+
+test(function resume() {
+  assert.strictEqual(form.resume(), false);
+});
+
+
+test(function writeHeaders() {
+  var HEADERS = {};
+  gently.expect(form, '_parseContentLength');
+  gently.expect(form, '_parseContentType');
+
+  form.writeHeaders(HEADERS);
+  assert.strictEqual(form.headers, HEADERS);
+});
+
+test(function write() {
+  var parser = {},
+      BUFFER = [1, 2, 3];
+
+  form._parser = parser;
+  form.bytesExpected = 523423;
+
+  (function testBasic() {
+    gently.expect(form, 'emit', function(event, bytesReceived, bytesExpected) {
+      assert.equal(event, 'progress');
+      assert.equal(bytesReceived, BUFFER.length);
+      assert.equal(bytesExpected, form.bytesExpected);
+    });
+
+    gently.expect(parser, 'write', function(buffer) {
+      assert.strictEqual(buffer, BUFFER);
+      return buffer.length;
+    });
+
+    assert.equal(form.write(BUFFER), BUFFER.length);
+    assert.equal(form.bytesReceived, BUFFER.length);
+  })();
+
+  (function testParserError() {
+    gently.expect(form, 'emit');
+
+    gently.expect(parser, 'write', function(buffer) {
+      assert.strictEqual(buffer, BUFFER);
+      return buffer.length - 1;
+    });
+
+    gently.expect(form, '_error', function(err) {
+      assert.ok(err.message.match(/parser error/i));
+    });
+
+    assert.equal(form.write(BUFFER), BUFFER.length - 1);
+    assert.equal(form.bytesReceived, BUFFER.length + BUFFER.length);
+  })();
+
+  (function testUninitialized() {
+    delete form._parser;
+
+    gently.expect(form, '_error', function(err) {
+      assert.ok(err.message.match(/unintialized parser/i));
+    });
+    form.write(BUFFER);
+  })();
+});
+
+test(function parseContentType() {
+  var HEADERS = {};
+
+  form.headers = {'content-type': 'application/x-www-form-urlencoded'};
+  gently.expect(form, '_initUrlencoded');
+  form._parseContentType();
+
+  // accept anything that has 'urlencoded' in it
+  form.headers = {'content-type': 'broken-client/urlencoded-stupid'};
+  gently.expect(form, '_initUrlencoded');
+  form._parseContentType();
+
+  var BOUNDARY = '---------------------------57814261102167618332366269';
+  form.headers = {'content-type': 'multipart/form-data; boundary='+BOUNDARY};
+
+  gently.expect(form, '_initMultipart', function(boundary) {
+    assert.equal(boundary, BOUNDARY);
+  });
+  form._parseContentType();
+
+  (function testQuotedBoundary() {
+    form.headers = {'content-type': 'multipart/form-data; boundary="' + BOUNDARY + '"'};
+
+    gently.expect(form, '_initMultipart', function(boundary) {
+      assert.equal(boundary, BOUNDARY);
+    });
+    form._parseContentType();
+  })();
+
+  (function testNoBoundary() {
+    form.headers = {'content-type': 'multipart/form-data'};
+
+    gently.expect(form, '_error', function(err) {
+      assert.ok(err.message.match(/no multipart boundary/i));
+    });
+    form._parseContentType();
+  })();
+
+  (function testNoContentType() {
+    form.headers = {};
+
+    gently.expect(form, '_error', function(err) {
+      assert.ok(err.message.match(/no content-type/i));
+    });
+    form._parseContentType();
+  })();
+
+  (function testUnknownContentType() {
+    form.headers = {'content-type': 'invalid'};
+
+    gently.expect(form, '_error', function(err) {
+      assert.ok(err.message.match(/unknown content-type/i));
+    });
+    form._parseContentType();
+  })();
+});
+
+test(function parseContentLength() {
+  var HEADERS = {};
+
+  form.headers = {};
+  form._parseContentLength();
+  assert.strictEqual(form.bytesExpected, null);
+
+  form.headers['content-length'] = '8';
+  form._parseContentLength();
+  assert.strictEqual(form.bytesReceived, 0);
+  assert.strictEqual(form.bytesExpected, 8);
+
+  // JS can be evil, lets make sure we are not
+  form.headers['content-length'] = '08';
+  form._parseContentLength();
+  assert.strictEqual(form.bytesExpected, 8);
+});
+
+test(function _initMultipart() {
+  var BOUNDARY = '123',
+      PARSER;
+
+  gently.expect(MultipartParserStub, 'new', function() {
+    PARSER = this;
+  });
+
+  gently.expect(MultipartParserStub.prototype, 'initWithBoundary', function(boundary) {
+    assert.equal(boundary, BOUNDARY);
+  });
+
+  form._initMultipart(BOUNDARY);
+  assert.equal(form.type, 'multipart');
+  assert.strictEqual(form._parser, PARSER);
+
+  (function testRegularField() {
+    var PART;
+    gently.expect(EventEmitterStub, 'new', function() {
+      PART = this;
+    });
+
+    gently.expect(form, 'onPart', function(part) {
+      assert.strictEqual(part, PART);
+      assert.deepEqual
+        ( part.headers
+        , { 'content-disposition': 'form-data; name="field1"'
+          , 'foo': 'bar'
+          }
+        );
+      assert.equal(part.name, 'field1');
+
+      var strings = ['hello', ' world'];
+      gently.expect(part, 'emit', 2, function(event, b) {
+          assert.equal(event, 'data');
+          assert.equal(b.toString(), strings.shift());
+      });
+
+      gently.expect(part, 'emit', function(event, b) {
+          assert.equal(event, 'end');
+      });
+    });
+
+    PARSER.onPartBegin();
+    PARSER.onHeaderField(new Buffer('content-disposition'), 0, 10);
+    PARSER.onHeaderField(new Buffer('content-disposition'), 10, 19);
+    PARSER.onHeaderValue(new Buffer('form-data; name="field1"'), 0, 14);
+    PARSER.onHeaderValue(new Buffer('form-data; name="field1"'), 14, 24);
+    PARSER.onHeaderEnd();
+    PARSER.onHeaderField(new Buffer('foo'), 0, 3);
+    PARSER.onHeaderValue(new Buffer('bar'), 0, 3);
+    PARSER.onHeaderEnd();
+    PARSER.onHeadersEnd();
+    PARSER.onPartData(new Buffer('hello world'), 0, 5);
+    PARSER.onPartData(new Buffer('hello world'), 5, 11);
+    PARSER.onPartEnd();
+  })();
+
+  (function testFileField() {
+    var PART;
+    gently.expect(EventEmitterStub, 'new', function() {
+      PART = this;
+    });
+
+    gently.expect(form, 'onPart', function(part) {
+      assert.deepEqual
+        ( part.headers
+        , { 'content-disposition': 'form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'
+          , 'content-type': 'text/plain'
+          }
+        );
+      assert.equal(part.name, 'field2');
+      assert.equal(part.filename, 'Sun"et.jpg');
+      assert.equal(part.mime, 'text/plain');
+
+      gently.expect(part, 'emit', function(event, b) {
+        assert.equal(event, 'data');
+        assert.equal(b.toString(), '... contents of file1.txt ...');
+      });
+
+      gently.expect(part, 'emit', function(event, b) {
+          assert.equal(event, 'end');
+      });
+    });
+
+    PARSER.onPartBegin();
+    PARSER.onHeaderField(new Buffer('content-disposition'), 0, 19);
+    PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'), 0, 85);
+    PARSER.onHeaderEnd();
+    PARSER.onHeaderField(new Buffer('Content-Type'), 0, 12);
+    PARSER.onHeaderValue(new Buffer('text/plain'), 0, 10);
+    PARSER.onHeaderEnd();
+    PARSER.onHeadersEnd();
+    PARSER.onPartData(new Buffer('... contents of file1.txt ...'), 0, 29);
+    PARSER.onPartEnd();
+  })();
+
+  (function testEnd() {
+    gently.expect(form, '_maybeEnd');
+    PARSER.onEnd();
+    assert.ok(form.ended);
+  })();
+});
+
+test(function _fileName() {
+  // TODO
+  return;
+});
+
+test(function _initUrlencoded() {
+  var PARSER;
+
+  gently.expect(QuerystringParserStub, 'new', function() {
+    PARSER = this;
+  });
+
+  form._initUrlencoded();
+  assert.equal(form.type, 'urlencoded');
+  assert.strictEqual(form._parser, PARSER);
+
+  (function testOnField() {
+    var KEY = 'KEY', VAL = 'VAL';
+    gently.expect(form, 'emit', function(field, key, val) {
+      assert.equal(field, 'field');
+      assert.equal(key, KEY);
+      assert.equal(val, VAL);
+    });
+
+    PARSER.onField(KEY, VAL);
+  })();
+
+  (function testOnEnd() {
+    gently.expect(form, '_maybeEnd');
+
+    PARSER.onEnd();
+    assert.equal(form.ended, true);
+  })();
+});
+
+test(function _error() {
+  var ERR = new Error('bla');
+
+  gently.expect(form, 'pause');
+  gently.expect(form, 'emit', function(event, err) {
+    assert.equal(event, 'error');
+    assert.strictEqual(err, ERR);
+  });
+
+  form._error(ERR);
+  assert.strictEqual(form.error, ERR);
+
+  // make sure _error only does its thing once
+  form._error(ERR);
+});
+
+test(function onPart() {
+  var PART = {};
+  gently.expect(form, 'handlePart', function(part) {
+    assert.strictEqual(part, PART);
+  });
+
+  form.onPart(PART);
+});
+
+test(function handlePart() {
+  (function testUtf8Field() {
+    var PART = new events.EventEmitter();
+    PART.name = 'my_field';
+
+    gently.expect(form, 'emit', function(event, field, value) {
+      assert.equal(event, 'field');
+      assert.equal(field, 'my_field');
+      assert.equal(value, 'hello world: €');
+    });
+
+    form.handlePart(PART);
+    PART.emit('data', new Buffer('hello'));
+    PART.emit('data', new Buffer(' world: '));
+    PART.emit('data', new Buffer([0xE2]));
+    PART.emit('data', new Buffer([0x82, 0xAC]));
+    PART.emit('end');
+  })();
+
+  (function testBinaryField() {
+    var PART = new events.EventEmitter();
+    PART.name = 'my_field2';
+
+    gently.expect(form, 'emit', function(event, field, value) {
+      assert.equal(event, 'field');
+      assert.equal(field, 'my_field2');
+      assert.equal(value, 'hello world: '+new Buffer([0xE2, 0x82, 0xAC]).toString('binary'));
+    });
+
+    form.encoding = 'binary';
+    form.handlePart(PART);
+    PART.emit('data', new Buffer('hello'));
+    PART.emit('data', new Buffer(' world: '));
+    PART.emit('data', new Buffer([0xE2]));
+    PART.emit('data', new Buffer([0x82, 0xAC]));
+    PART.emit('end');
+  })();
+
+  (function testFieldSize() {
+    form.maxFieldsSize = 8;
+    var PART = new events.EventEmitter();
+    PART.name = 'my_field';
+
+    gently.expect(form, '_error', function(err) {
+      assert.equal(err.message, 'maxFieldsSize exceeded, received 9 bytes of field data');
+    });
+
+    form.handlePart(PART);
+    form._fieldsSize = 1;
+    PART.emit('data', new Buffer(7));
+    PART.emit('data', new Buffer(1));
+  })();
+
+  (function testFilePart() {
+    var PART = new events.EventEmitter(),
+        FILE = new events.EventEmitter(),
+        PATH = '/foo/bar';
+
+    PART.name = 'my_file';
+    PART.filename = 'sweet.txt';
+    PART.mime = 'sweet.txt';
+
+    gently.expect(form, '_uploadPath', function(filename) {
+      assert.equal(filename, PART.filename);
+      return PATH;
+    });
+
+    gently.expect(FileStub, 'new', function(properties) {
+      assert.equal(properties.path, PATH);
+      assert.equal(properties.name, PART.filename);
+      assert.equal(properties.type, PART.mime);
+      FILE = this;
+
+      gently.expect(form, 'emit', function (event, field, file) {
+        assert.equal(event, 'fileBegin');
+        assert.strictEqual(field, PART.name);
+        assert.strictEqual(file, FILE);
+      });
+
+      gently.expect(FILE, 'open');
+    });
+
+    form.handlePart(PART);
+    assert.equal(form._flushing, 1);
+
+    var BUFFER;
+    gently.expect(form, 'pause');
+    gently.expect(FILE, 'write', function(buffer, cb) {
+      assert.strictEqual(buffer, BUFFER);
+      gently.expect(form, 'resume');
+      // @todo handle cb(new Err)
+      cb();
+    });
+
+    PART.emit('data', BUFFER = new Buffer('test'));
+
+    gently.expect(FILE, 'end', function(cb) {
+      gently.expect(form, 'emit', function(event, field, file) {
+        assert.equal(event, 'file');
+        assert.strictEqual(file, FILE);
+      });
+
+      gently.expect(form, '_maybeEnd');
+
+      cb();
+      assert.equal(form._flushing, 0);
+    });
+
+    PART.emit('end');
+  })();
+});
+
+test(function _uploadPath() {
+  (function testUniqueId() {
+    var UUID_A, UUID_B;
+    gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, uuid) {
+      assert.equal(uploadDir, form.uploadDir);
+      UUID_A = uuid;
+    });
+    form._uploadPath();
+
+    gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, uuid) {
+      UUID_B = uuid;
+    });
+    form._uploadPath();
+
+    assert.notEqual(UUID_A, UUID_B);
+  })();
+
+  (function testFileExtension() {
+    form.keepExtensions = true;
+    var FILENAME = 'foo.jpg',
+        EXT = '.bar';
+
+    gently.expect(GENTLY.hijacked.path, 'extname', function(filename) {
+      assert.equal(filename, FILENAME);
+      gently.restore(path, 'extname');
+
+      return EXT;
+    });
+
+    gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, name) {
+      assert.equal(path.extname(name), EXT);
+    });
+    form._uploadPath(FILENAME);
+  })();
+});
+
+test(function _maybeEnd() {
+  gently.expect(form, 'emit', 0);
+  form._maybeEnd();
+
+  form.ended = true;
+  form._flushing = 1;
+  form._maybeEnd();
+
+  gently.expect(form, 'emit', function(event) {
+    assert.equal(event, 'end');
+  });
+
+  form.ended = true;
+  form._flushing = 0;
+  form._maybeEnd();
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js
new file mode 100644
index 0000000..d8dc968
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js
@@ -0,0 +1,50 @@
+var common = require('../common');
+var multipartParser = require(common.lib + '/multipart_parser'),
+    MultipartParser = multipartParser.MultipartParser,
+    events = require('events'),
+    Buffer = require('buffer').Buffer,
+    parser;
+
+function test(test) {
+  parser = new MultipartParser();
+  test();
+}
+
+test(function constructor() {
+  assert.equal(parser.boundary, null);
+  assert.equal(parser.state, 0);
+  assert.equal(parser.flags, 0);
+  assert.equal(parser.boundaryChars, null);
+  assert.equal(parser.index, null);
+  assert.equal(parser.lookbehind, null);
+  assert.equal(parser.constructor.name, 'MultipartParser');
+});
+
+test(function initWithBoundary() {
+  var boundary = 'abc';
+  parser.initWithBoundary(boundary);
+  assert.deepEqual(Array.prototype.slice.call(parser.boundary), [13, 10, 45, 45, 97, 98, 99]);
+  assert.equal(parser.state, multipartParser.START);
+
+  assert.deepEqual(parser.boundaryChars, {10: true, 13: true, 45: true, 97: true, 98: true, 99: true});
+});
+
+test(function parserError() {
+  var boundary = 'abc',
+      buffer = new Buffer(5);
+
+  parser.initWithBoundary(boundary);
+  buffer.write('--ad', 'ascii', 0);
+  assert.equal(parser.write(buffer), 3);
+});
+
+test(function end() {
+  (function testError() {
+    assert.equal(parser.end().message, 'MultipartParser.end(): stream ended unexpectedly: ' + parser.explain());
+  })();
+
+  (function testRegular() {
+    parser.state = multipartParser.END;
+    assert.strictEqual(parser.end(), undefined);
+  })();
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js
new file mode 100644
index 0000000..54d3e2d
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js
@@ -0,0 +1,45 @@
+var common = require('../common');
+var QuerystringParser = require(common.lib + '/querystring_parser').QuerystringParser,
+    Buffer = require('buffer').Buffer,
+    gently,
+    parser;
+
+function test(test) {
+  gently = new Gently();
+  parser = new QuerystringParser();
+  test();
+  gently.verify(test.name);
+}
+
+test(function constructor() {
+  assert.equal(parser.buffer, '');
+  assert.equal(parser.constructor.name, 'QuerystringParser');
+});
+
+test(function write() {
+  var a = new Buffer('a=1');
+  assert.equal(parser.write(a), a.length);
+
+  var b = new Buffer('&b=2');
+  parser.write(b);
+  assert.equal(parser.buffer, a + b);
+});
+
+test(function end() {
+  var FIELDS = {a: ['b', {c: 'd'}], e: 'f'};
+
+  gently.expect(GENTLY.hijacked.querystring, 'parse', function(str) {
+    assert.equal(str, parser.buffer);
+    return FIELDS;
+  });
+
+  gently.expect(parser, 'onField', Object.keys(FIELDS).length, function(key, val) {
+    assert.deepEqual(FIELDS[key], val);
+  });
+
+  gently.expect(parser, 'onEnd');
+
+  parser.buffer = 'my buffer';
+  parser.end();
+  assert.equal(parser.buffer, '');
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js
new file mode 100644
index 0000000..fcfdb94
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js
@@ -0,0 +1,72 @@
+var common = require('../common');
+var BOUNDARY = '---------------------------10102754414578508781458777923',
+    FIXTURE = TEST_FIXTURES+'/multi_video.upload',
+    fs = require('fs'),
+    util = require(common.lib + '/util'),
+    http = require('http'),
+    formidable = require(common.lib + '/index'),
+    server = http.createServer();
+
+server.on('request', function(req, res) {
+  var form = new formidable.IncomingForm(),
+      uploads = {};
+
+  form.uploadDir = TEST_TMP;
+  form.parse(req);
+
+  form
+    .on('fileBegin', function(field, file) {
+      assert.equal(field, 'upload');
+
+      var tracker = {file: file, progress: [], ended: false};
+      uploads[file.filename] = tracker;
+      file
+        .on('progress', function(bytesReceived) {
+          tracker.progress.push(bytesReceived);
+          assert.equal(bytesReceived, file.length);
+        })
+        .on('end', function() {
+          tracker.ended = true;
+        });
+    })
+    .on('field', function(field, value) {
+      assert.equal(field, 'title');
+      assert.equal(value, '');
+    })
+    .on('file', function(field, file) {
+      assert.equal(field, 'upload');
+      assert.strictEqual(uploads[file.filename].file, file);
+    })
+    .on('end', function() {
+      assert.ok(uploads['shortest_video.flv']);
+      assert.ok(uploads['shortest_video.flv'].ended);
+      assert.ok(uploads['shortest_video.flv'].progress.length > 3);
+      assert.equal(uploads['shortest_video.flv'].progress.slice(-1), uploads['shortest_video.flv'].file.length);
+      assert.ok(uploads['shortest_video.mp4']);
+      assert.ok(uploads['shortest_video.mp4'].ended);
+      assert.ok(uploads['shortest_video.mp4'].progress.length > 3);
+
+      server.close();
+      res.writeHead(200);
+      res.end('good');
+    });
+});
+
+server.listen(TEST_PORT, function() {
+  var client = http.createClient(TEST_PORT),
+      stat = fs.statSync(FIXTURE),
+      headers = {
+        'content-type': 'multipart/form-data; boundary='+BOUNDARY,
+        'content-length': stat.size,
+      }
+      request = client.request('POST', '/', headers),
+      fixture = new fs.ReadStream(FIXTURE);
+
+  fixture
+    .on('data', function(b) {
+      request.write(b);
+    })
+    .on('end', function() {
+      request.end();
+    });
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js
new file mode 100755
index 0000000..50b2361
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('urun')(__dirname)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js
new file mode 100644
index 0000000..bcf61d7
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js
@@ -0,0 +1,63 @@
+var common       = require('../common');
+var test         = require('utest');
+var assert       = common.assert;
+var IncomingForm = common.require('incoming_form').IncomingForm;
+var path         = require('path');
+
+var from;
+test('IncomingForm', {
+  before: function() {
+    form = new IncomingForm();
+  },
+
+  '#_fileName with regular characters': function() {
+    var filename = 'foo.txt';
+    assert.equal(form._fileName(makeHeader(filename)), 'foo.txt');
+  },
+
+  '#_fileName with unescaped quote': function() {
+    var filename = 'my".txt';
+    assert.equal(form._fileName(makeHeader(filename)), 'my".txt');
+  },
+
+  '#_fileName with escaped quote': function() {
+    var filename = 'my%22.txt';
+    assert.equal(form._fileName(makeHeader(filename)), 'my".txt');
+  },
+
+  '#_fileName with bad quote and additional sub-header': function() {
+    var filename = 'my".txt';
+    var header = makeHeader(filename) + '; foo="bar"';
+    assert.equal(form._fileName(header), filename);
+  },
+
+  '#_fileName with semicolon': function() {
+    var filename = 'my;.txt';
+    assert.equal(form._fileName(makeHeader(filename)), 'my;.txt');
+  },
+
+  '#_fileName with utf8 character': function() {
+    var filename = 'my&#9731;.txt';
+    assert.equal(form._fileName(makeHeader(filename)), 'my☃.txt');
+  },
+
+  '#_uploadPath strips harmful characters from extension when keepExtensions': function() {
+    form.keepExtensions = true;
+
+    var ext = path.extname(form._uploadPath('fine.jpg?foo=bar'));
+    assert.equal(ext, '.jpg');
+
+    var ext = path.extname(form._uploadPath('fine?foo=bar'));
+    assert.equal(ext, '');
+
+    var ext = path.extname(form._uploadPath('super.cr2+dsad'));
+    assert.equal(ext, '.cr2');
+
+    var ext = path.extname(form._uploadPath('super.bar'));
+    assert.equal(ext, '.bar');
+  },
+});
+
+function makeHeader(filename) {
+  return 'Content-Disposition: form-data; name="upload"; filename="' + filename + '"';
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js
new file mode 100644
index 0000000..9f1cef8
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js
@@ -0,0 +1,47 @@
+var http = require('http');
+var fs = require('fs');
+var connections = 0;
+
+var server = http.createServer(function(req, res) {
+  var socket = req.socket;
+  console.log('Request: %s %s -> %s', req.method, req.url, socket.filename);
+
+  req.on('end', function() {
+    if (req.url !== '/') {
+      res.end(JSON.stringify({
+        method: req.method,
+        url: req.url,
+        filename: socket.filename,
+      }));
+      return;
+    }
+
+    res.writeHead(200, {'content-type': 'text/html'});
+    res.end(
+      '<form action="/upload" enctype="multipart/form-data" method="post">'+
+      '<input type="text" name="title"><br>'+
+      '<input type="file" name="upload" multiple="multiple"><br>'+
+      '<input type="submit" value="Upload">'+
+      '</form>'
+    );
+  });
+});
+
+server.on('connection', function(socket) {
+  connections++;
+
+  socket.id = connections;
+  socket.filename = 'connection-' + socket.id + '.http';
+  socket.file = fs.createWriteStream(socket.filename);
+  socket.pipe(socket.file);
+
+  console.log('--> %s', socket.filename);
+  socket.on('close', function() {
+    console.log('<-- %s', socket.filename);
+  });
+});
+
+var port = process.env.PORT || 8080;
+server.listen(port, function() {
+  console.log('Recording connections on port %s', port);
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/connect/test.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/connect/test.js b/weinre.server/node_modules/express/node_modules/connect/test.js
new file mode 100644
index 0000000..a1e1d55
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/connect/test.js
@@ -0,0 +1,52 @@
+
+var connect = require('./')
+  , http = require('http')
+  , RedisStore = require('connect-redis')(connect);
+
+var app = connect();
+app.use(connect.cookieParser('fucj'));
+app.use(connect.session({store:new RedisStore}));
+app.use(function(req, res, next){
+  req.session.views = (req.session.views || 0) + 1;
+  res.writeHead(200, {"Content-Type": "text/plain"});
+  res.end("You've viewed this page "+req.session.views+" times.");
+})
+
+http.createServer(app).listen(3000);
+
+
+// var set = RedisStore.prototype.set;
+// 
+// function slow(sid){
+//   console.log('%s saving', sid);
+//   var args = arguments;
+//   setTimeout(function(self){
+//     console.log('%s saved', sid);
+//     set.apply(self, args);
+//   }, 2000, this);
+// };
+// 
+// http.createServer(connect()
+//   .use(connect.logger('dev'))
+//   .use(connect.cookieParser('keyboard cat'))
+//   .use(connect.session({ store: new RedisStore }))
+//   .use(function(req, res, next){
+//     var sess = req.session;
+//     switch (req.url) {
+//       case '/foo.js':
+//         console.log('%s foo.js sid', sess.id);
+//         RedisStore.prototype.set = set;
+//         res.end('data');
+//         break;
+//       default:
+//         console.log('%s html sid', sess.id);
+//         RedisStore.prototype.set = slow;
+//         res.setHeader('Content-Type', 'html');
+//         res.write('<html><head><script src="/foo.js"></script></head><body>');
+//         setTimeout(function(){
+//           res.end('</body></html>');
+//         }, 1000);
+//     }
+//   })).listen(3000);
+// 
+// console.log('port 3000');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/mime/LICENSE
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/mime/LICENSE b/weinre.server/node_modules/express/node_modules/mime/LICENSE
new file mode 100644
index 0000000..451fc45
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/mime/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/mime/README.md
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/mime/README.md b/weinre.server/node_modules/express/node_modules/mime/README.md
new file mode 100644
index 0000000..a157de1
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/mime/README.md
@@ -0,0 +1,50 @@
+# mime
+
+Support for mapping between file extensions and MIME types.  This module uses the latest version of the Apache "mime.types" file (maps over 620 types to 800+ extensions).  It is also trivially easy to add your own types and extensions, should you need to do that.
+
+## Install
+
+Install with [npm](http://github.com/isaacs/npm):
+
+    npm install mime
+
+## API - Queries
+
+### mime.lookup(path)
+Get the mime type associated with a file. This is method is case-insensitive. Everything in path up to and including the last '/' or '.' is ignored, so you can pass it paths, filenames, or extensions, like so:
+
+    var mime = require('mime');
+
+    mime.lookup('/path/to/file.txt');         // => 'text/plain'
+    mime.lookup('file.txt');                  // => 'text/plain'
+    mime.lookup('.txt');                      // => 'text/plain'
+    mime.lookup('htm');                       // => 'text/html'
+
+### mime.extension(type) - lookup the default extension for type
+
+    mime.extension('text/html');                 // => 'html'
+    mime.extension('application/octet-stream');  // => 'bin'
+
+### mime.charsets.lookup() - map mime-type to charset
+
+    mime.charsets.lookup('text/plain');        // => 'UTF-8'
+
+(The logic for charset lookups is pretty rudimentary.  Feel free to suggest improvements.)
+
+## API - Customizing
+
+The following APIs allow you to add your own type mappings within your project.  If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/bentomas/node-mime/wiki/Requesting-New-Types).
+### mime.define() - Add custom mime/extension mappings
+
+    mime.define({
+        'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
+        'application/x-my-type': ['x-mt', 'x-mtt'],
+        // etc ...
+    });
+
+    mime.lookup('x-sft');                 // => 'text/x-some-format'
+    mime.extension('text/x-some-format'); // => 'x-sf'
+
+### mime.load(filepath) - Load mappings from an Apache ".types" format file
+
+    mime.load('./my_project.types');

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/mime/mime.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/mime/mime.js b/weinre.server/node_modules/express/node_modules/mime/mime.js
new file mode 100644
index 0000000..5fac753
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/mime/mime.js
@@ -0,0 +1,92 @@
+var path = require('path'),
+    fs = require('fs');
+
+var mime = module.exports = {
+  /** Map of extension to mime type */
+  types: {},
+
+  /** Map of mime type to extension */
+  extensions :{},
+
+  /**
+   * Define mimetype -> extension mappings.  Each key is a mime-type that maps
+   * to an array of extensions associated with the type.  The first extension is
+   * used as the default extension for the type.
+   *
+   * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
+   *
+   * @param map (Object) type definitions
+   */
+  define: function(map) {
+    for (var type in map) {
+      var exts = map[type];
+
+      for (var i = 0; i < exts.length; i++) {
+        mime.types[exts[i]] = type;
+      }
+
+      // Default extension is the first one we encounter
+      if (!mime.extensions[type]) {
+        mime.extensions[type] = exts[0];
+      }
+    }
+  },
+
+  /**
+   * Load an Apache2-style ".types" file
+   *
+   * This may be called multiple times (it's expected).  Where files declare
+   * overlapping types/extensions, the last file wins.
+   *
+   * @param file (String) path of file to load.
+   */
+  load: function(file) {
+    // Read file and split into lines
+    var map = {},
+        content = fs.readFileSync(file, 'ascii'),
+        lines = content.split(/[\r\n]+/);
+
+    lines.forEach(function(line, lineno) {
+      // Clean up whitespace/comments, and split into fields
+      var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
+      map[fields.shift()] = fields;
+    });
+
+    mime.define(map);
+  },
+
+  /**
+   * Lookup a mime type based on extension
+   */
+  lookup: function(path, fallback) {
+    var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
+    return mime.types[ext] || fallback || mime.default_type;
+  },
+
+  /**
+   * Return file extension associated with a mime type
+   */
+  extension: function(mimeType) {
+    return mime.extensions[mimeType];
+  },
+
+  /**
+   * Lookup a charset based on mime type.
+   */
+  charsets: {
+    lookup: function (mimeType, fallback) {
+      // Assume text types are utf8.  Modify mime logic as needed.
+      return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
+    }
+  }
+};
+
+// Load our local copy of
+// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
+mime.load(path.join(__dirname, 'types/mime.types'));
+
+// Overlay enhancements submitted by the node.js community
+mime.load(path.join(__dirname, 'types/node.types'));
+
+// Set the default type
+mime.default_type = mime.types.bin;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.server/node_modules/express/node_modules/mime/test.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/express/node_modules/mime/test.js b/weinre.server/node_modules/express/node_modules/mime/test.js
new file mode 100644
index 0000000..b904895
--- /dev/null
+++ b/weinre.server/node_modules/express/node_modules/mime/test.js
@@ -0,0 +1,79 @@
+/**
+ * Requires the async_testing module
+ *
+ * Usage: node test.js
+ */
+var mime = require('./mime');
+exports["test mime lookup"] = function(test) {
+  // easy
+  test.equal('text/plain', mime.lookup('text.txt'));
+
+  // hidden file or multiple periods
+  test.equal('text/plain', mime.lookup('.text.txt'));
+
+  // just an extension
+  test.equal('text/plain', mime.lookup('.txt'));
+
+  // just an extension without a dot
+  test.equal('text/plain', mime.lookup('txt'));
+
+  // default
+  test.equal('application/octet-stream', mime.lookup('text.nope'));
+
+  // fallback
+  test.equal('fallback', mime.lookup('text.fallback', 'fallback'));
+
+  test.finish();
+};
+
+exports["test extension lookup"] = function(test) {
+  // easy
+  test.equal('txt', mime.extension(mime.types.text));
+  test.equal('html', mime.extension(mime.types.htm));
+  test.equal('bin', mime.extension('application/octet-stream'));
+
+  test.finish();
+};
+
+exports["test mime lookup uppercase"] = function(test) {
+  // easy
+  test.equal('text/plain', mime.lookup('TEXT.TXT'));
+
+  // just an extension
+  test.equal('text/plain', mime.lookup('.TXT'));
+
+  // just an extension without a dot
+  test.equal('text/plain', mime.lookup('TXT'));
+
+  // default
+  test.equal('application/octet-stream', mime.lookup('TEXT.NOPE'));
+
+  // fallback
+  test.equal('fallback', mime.lookup('TEXT.FALLBACK', 'fallback'));
+
+  test.finish();
+};
+
+exports["test custom types"] = function(test) {
+  test.equal('application/octet-stream', mime.lookup('file.buffer'));
+  test.equal('audio/mp4', mime.lookup('file.m4a'));
+
+  test.finish();
+};
+
+exports["test charset lookup"] = function(test) {
+  // easy
+  test.equal('UTF-8', mime.charsets.lookup('text/plain'));
+
+  // none
+  test.ok(typeof mime.charsets.lookup(mime.types.js) == 'undefined');
+
+  // fallback
+  test.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
+
+  test.finish();
+};
+
+if (module == require.main) {
+  require('async_testing').run(__filename, process.ARGV);
+}


Mime
View raw message