[Pkg-javascript-commits] [node-connect] 01/03: Imported Upstream version 3.3.0

Leo Iannacone l3on-guest at moszumanska.debian.org
Mon Oct 20 16:28:48 UTC 2014


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

l3on-guest pushed a commit to branch master
in repository node-connect.

commit 3fc37b7f73aac66113c5bcc6030d91b7b416a80e
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Mon Oct 20 18:21:17 2014 +0200

    Imported Upstream version 3.3.0
---
 History.md     | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Readme.md      |   4 +-
 lib/proto.js   |   4 +-
 package.json   |   8 ++--
 test/fqdn.js   |  96 +++++++++++++++++++++++++++++++--------------
 test/server.js |  65 +++++++++++++++++++++++++-----
 6 files changed, 251 insertions(+), 48 deletions(-)

diff --git a/History.md b/History.md
index c754572..54ff075 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,13 @@
+3.3.0 / 2014-10-17
+==================
+
+  * deps: debug@~2.1.0
+    - Implement `DEBUG_FD` env variable support
+  * deps: finalhandler at 0.3.1
+    - Terminate in progress response only on error
+    - Use `on-finished` to determine request status
+    - deps: debug@~2.1.0
+
 3.2.0 / 2014-09-08
 ==================
 
@@ -64,6 +74,118 @@
   * remove various private `connect.utils` functions
   * drop node.js 0.8 support
 
+2.27.0 / 2014-10-16
+===================
+
+  * Use `http-errors` module for creating errors
+  * Use `utils-merge` module for merging objects
+  * deps: body-parser@~1.9.0
+    - include the charset in "unsupported charset" error message
+    - include the encoding in "unsupported content encoding" error message
+    - deps: depd@~1.0.0
+  * deps: compression@~1.2.0
+    - deps: debug@~2.1.0
+  * deps: connect-timeout@~1.4.0
+    - Create errors with `http-errors`
+    - deps: debug@~2.1.0
+  * deps: debug@~2.1.0
+    - Implement `DEBUG_FD` env variable support
+  * deps: depd@~1.0.0
+  * deps: express-session@~1.9.0
+    - deps: debug@~2.1.0
+    - deps: depd@~1.0.0
+  * deps: finalhandler at 0.3.1
+    - Terminate in progress response only on error
+    - Use `on-finished` to determine request status
+    - deps: debug@~2.1.0
+  * deps: method-override@~2.3.0
+    - deps: debug@~2.1.0
+  * deps: morgan@~1.4.0
+    - Add `debug` messages
+    - deps: depd@~1.0.0
+  * deps: response-time@~2.2.0
+    - Add `header` option for custom header name
+    - Add `suffix` option
+    - Change `digits` argument to an `options` argument
+    - deps: depd@~1.0.0
+  * deps: serve-favicon@~2.1.6
+    - deps: etag@~1.5.0
+  * deps: serve-index@~1.5.0
+    - Add `dir` argument to `filter` function
+    - Add icon for mkv files
+    - Create errors with `http-errors`
+    - Fix incorrect 403 on Windows and Node.js 0.11
+    - Lookup icon by mime type for greater icon support
+    - Support using tokens multiple times
+    - deps: accepts@~1.1.2
+    - deps: debug@~2.1.0
+    - deps: mime-types@~2.0.2
+  * deps: serve-static@~1.7.0
+    - deps: send at 0.10.0
+
+2.26.6 / 2014-10-15
+===================
+
+  * deps: compression@~1.1.2
+    - deps: accepts@~1.1.2
+    - deps: compressible@~2.0.1
+  * deps: csurf@~1.6.2
+    - bump http-errors
+    - fix cookie name when using `cookie: true`
+  * deps: errorhandler@~1.2.2
+    - deps: accepts@~1.1.2
+
+2.26.5 / 2014-10-08
+===================
+
+  * Fix accepting non-object arguments to `logger`
+  * deps: serve-static@~1.6.4
+    - Fix redirect loop when index file serving disabled
+
+2.26.4 / 2014-10-02
+===================
+
+  * deps: morgan@~1.3.2
+    - Fix `req.ip` integration when `immediate: false`
+  * deps: type-is@~1.5.2
+    - deps: mime-types@~2.0.2
+
+2.26.3 / 2014-09-24
+===================
+
+  * deps: body-parser@~1.8.4
+    - fix content encoding to be case-insensitive
+  * deps: serve-favicon@~2.1.5
+    - deps: etag@~1.4.0
+  * deps: serve-static@~1.6.3
+    - deps: send at 0.9.3
+
+2.26.2 / 2014-09-19
+===================
+
+  * deps: body-parser@~1.8.3
+    - deps: qs at 2.2.4
+  * deps: qs at 2.2.4
+    - Fix issue with object keys starting with numbers truncated
+
+2.26.1 / 2014-09-15
+===================
+
+  * deps: body-parser@~1.8.2
+    - deps: depd at 0.4.5
+  * deps: depd at 0.4.5
+  * deps: express-session@~1.8.2
+    - Use `crc` instead of `buffer-crc32` for speed
+    - deps: depd at 0.4.5
+  * deps: morgan@~1.3.1
+    - Remove un-used `bytes` dependency
+    - deps: depd at 0.4.5
+  * deps: serve-favicon@~2.1.4
+    - Fix content headers being sent in 304 response
+    - deps: etag@~1.3.1
+  * deps: serve-static@~1.6.2
+    - deps: send at 0.9.2
+
 2.26.0 / 2014-09-08
 ===================
 
diff --git a/Readme.md b/Readme.md
index fa4b239..530423b 100644
--- a/Readme.md
+++ b/Readme.md
@@ -60,14 +60,14 @@ These middleware and libraries are officially supported by the Connect/Express t
   - [connect-timeout](https://github.com/expressjs/timeout) - previously `timeout`
   - [cookie-parser](https://github.com/expressjs/cookie-parser) - previously `cookieParser`
   - [cookie-session](https://github.com/expressjs/cookie-session) - previously `cookieSession`
-  - [csurf](https://github.com/expressjs/csurf) - previousy `csrf`
+  - [csurf](https://github.com/expressjs/csurf) - previously `csrf`
   - [errorhandler](https://github.com/expressjs/errorhandler) - previously `error-handler`
   - [express-session](https://github.com/expressjs/session) - previously `session`
   - [method-override](https://github.com/expressjs/method-override) - previously `method-override`
   - [morgan](https://github.com/expressjs/morgan) - previously `logger`
   - [response-time](https://github.com/expressjs/response-time) - previously `response-time`
   - [serve-favicon](https://github.com/expressjs/serve-favicon) - previously `favicon`
-  - [serve-index](https://github.com/expressjs/serve-index) - previousy `directory`
+  - [serve-index](https://github.com/expressjs/serve-index) - previously `directory`
   - [serve-static](https://github.com/expressjs/serve-static) - previously `static`
   - [vhost](https://github.com/expressjs/vhost) - previously `vhost`
 
diff --git a/lib/proto.js b/lib/proto.js
index bf18809..ab8d3a1 100644
--- a/lib/proto.js
+++ b/lib/proto.js
@@ -81,8 +81,8 @@ app.use = function(route, fn){
 
 app.handle = function(req, res, out) {
   var stack = this.stack
-    , search = 1 + req.url.indexOf('?')
-    , pathlength = search ? search - 1 : req.url.length
+    , searchIndex = req.url.indexOf('?')
+    , pathlength = searchIndex !== -1 ? searchIndex : req.url.length
     , fqdn = 1 + req.url.substr(0, pathlength).indexOf('://')
     , protohost = fqdn ? req.url.substr(0, req.url.indexOf('/', 2 + fqdn)) : ''
     , removed = ''
diff --git a/package.json b/package.json
index e1c4bfb..538279e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "connect",
   "description": "High performance middleware framework",
-  "version": "3.2.0",
+  "version": "3.3.0",
   "author": "TJ Holowaychuk <tj at vision-media.ca> (http://tjholowaychuk.com)",
   "contributors": [
     "Douglas Christopher Wilson <doug at somethingdoug.com>",
@@ -17,8 +17,8 @@
   ],
   "repository": "senchalabs/connect",
   "dependencies": {
-    "debug": "~2.0.0",
-    "finalhandler": "0.2.0",
+    "debug": "~2.1.0",
+    "finalhandler": "0.3.1",
     "parseurl": "~1.3.0",
     "utils-merge": "1.0.0"
   },
@@ -26,7 +26,7 @@
     "istanbul": "0.3.2",
     "mocha": "~1.21.4",
     "should": "~4.0.0",
-    "supertest": "~0.13.0"
+    "supertest": "~0.14.0"
   },
   "license": "MIT",
   "engines": {
diff --git a/test/fqdn.js b/test/fqdn.js
index ad3d1f4..c853ab5 100644
--- a/test/fqdn.js
+++ b/test/fqdn.js
@@ -1,4 +1,5 @@
 
+var assert = require('assert');
 var connect = require('..');
 var http = require('http');
 var request = require('supertest');
@@ -15,12 +16,9 @@ describe('app.use()', function(){
       res.end(req.url);
     });
 
-    app.handle({ method: 'GET', url: 'http://example.com/foo' }, {
-      end: function(str){
-        str.should.equal('http://example.com/foo');
-        done();
-      }
-    });
+    rawrequest(app)
+    .get('http://example.com/foo')
+    .expect(200, 'http://example.com/foo', done);
   });
 
   describe('with a connect app', function(){
@@ -29,12 +27,9 @@ describe('app.use()', function(){
         res.end(req.url);
       });
 
-      app.handle({ method: 'GET', url: '/proxy?url=http://example.com/blog/post/1' }, {
-        end: function(str){
-          str.should.equal('/?url=http://example.com/blog/post/1');
-          done();
-        }
-      });
+      rawrequest(app)
+      .get('/proxy?url=http://example.com/blog/post/1')
+      .expect(200, '/?url=http://example.com/blog/post/1', done);
     });
 
     it('should adjust FQDN req.url', function(done){
@@ -42,12 +37,9 @@ describe('app.use()', function(){
         res.end(req.url);
       });
 
-      app.handle({ method: 'GET', url: 'http://example.com/blog/post/1' }, {
-        end: function(str){
-          str.should.equal('http://example.com/post/1');
-          done();
-        }
-      });
+      rawrequest(app)
+      .get('http://example.com/blog/post/1')
+      .expect(200, 'http://example.com/post/1', done);
     });
 
     it('should adjust FQDN req.url with multiple handlers', function(done){
@@ -59,12 +51,9 @@ describe('app.use()', function(){
         res.end(req.url);
       });
 
-      app.handle({ method: 'GET', url: 'http://example.com/blog/post/1' }, {
-        end: function(str){
-          str.should.equal('http://example.com/post/1');
-          done();
-        }
-      });
+      rawrequest(app)
+      .get('http://example.com/blog/post/1')
+      .expect(200, 'http://example.com/post/1', done);
     });
 
     it('should adjust FQDN req.url with multiple routed handlers', function(done) {
@@ -75,12 +64,59 @@ describe('app.use()', function(){
         res.end(req.url);
       });
 
-      app.handle({ method: 'GET', url: 'http://example.com/blog/post/1' }, {
-        end: function(str){
-          str.should.equal('http://example.com/post/1');
-          done();
-        }
-      });
+      rawrequest(app)
+      .get('http://example.com/blog/post/1')
+      .expect(200, 'http://example.com/post/1', done);
     });
   });
 });
+
+function rawrequest(app) {
+  var _path;
+  var server = http.createServer(app);
+
+  function expect(status, body, callback) {
+    server.listen(function(){
+      var addr = this.address();
+      var hostname = addr.family === 'IPv6' ? '[::1]' : '127.0.0.1';
+      var port = addr.port;
+
+      var req = http.get({
+        host: hostname,
+        path: _path,
+        port: port
+      });
+      req.on('response', function(res){
+        var buf = '';
+
+        res.setEncoding('utf8');
+        res.on('data', function(s){ buf += s });
+        res.on('end', function(){
+          var err = null;
+
+          try {
+            assert.equal(res.statusCode, status);
+            assert.equal(buf, body);
+          } catch (e) {
+            err = e;
+          }
+
+          server.close();
+          callback(err);
+        });
+      });
+    });
+  }
+
+  function get(path) {
+    _path = path;
+
+    return {
+      expect: expect
+    };
+  }
+
+  return {
+    get: get
+  };
+}
diff --git a/test/server.js b/test/server.js
index 2b31fca..32f72ae 100644
--- a/test/server.js
+++ b/test/server.js
@@ -1,5 +1,7 @@
 
+var assert = require('assert');
 var connect = require('..');
+var http = require('http');
 var request = require('supertest');
 var should = require('should');
 
@@ -16,8 +18,6 @@ describe('app', function(){
   });
 
   it('should work as middleware', function(done){
-    var http = require('http');
-
     // custom server handler array
     var handlers = [connect(), function(req, res, next){
       res.writeHead(200, {'Content-Type': 'text/plain'});
@@ -66,14 +66,9 @@ describe('app', function(){
 
   describe('404 handler', function(){
     it('should escape the 404 response body', function(done){
-      app.handle({ method: 'GET', url: '/foo/<script>stuff</script>' }, {
-        setHeader: function(){},
-        end: function(str){
-          this.statusCode.should.equal(404);
-          str.should.equal('Cannot GET /foo/<script>stuff</script>\n');
-          done();
-        }
-      });
+      rawrequest(app)
+      .get('/foo/<script>stuff</script>')
+      .expect(404, 'Cannot GET /foo/<script>stuff</script>\n', done);
     });
 
     it('shoud not fire after headers sent', function(done){
@@ -168,3 +163,53 @@ describe('app', function(){
     });
   });
 });
+
+function rawrequest(app) {
+  var _path;
+  var server = http.createServer(app);
+
+  function expect(status, body, callback) {
+    server.listen(function(){
+      var addr = this.address();
+      var hostname = addr.family === 'IPv6' ? '[::1]' : '127.0.0.1';
+      var port = addr.port;
+
+      var req = http.get({
+        host: hostname,
+        path: _path,
+        port: port
+      });
+      req.on('response', function(res){
+        var buf = '';
+
+        res.setEncoding('utf8');
+        res.on('data', function(s){ buf += s });
+        res.on('end', function(){
+          var err = null;
+
+          try {
+            assert.equal(res.statusCode, status);
+            assert.equal(buf, body);
+          } catch (e) {
+            err = e;
+          }
+
+          server.close();
+          callback(err);
+        });
+      });
+    });
+  }
+
+  function get(path) {
+    _path = path;
+
+    return {
+      expect: expect
+    };
+  }
+
+  return {
+    get: get
+  };
+}

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



More information about the Pkg-javascript-commits mailing list