From 68aa2f60904a45e60187ec80b1285553c24cd87e Mon Sep 17 00:00:00 2001 From: stephen Date: Wed, 21 May 2014 13:10:25 -0500 Subject: [PATCH 1/6] end response after writing string data --- jsgi-node.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jsgi-node.js b/jsgi-node.js index e89c0cb..c2c2921 100644 --- a/jsgi-node.js +++ b/jsgi-node.js @@ -160,6 +160,7 @@ function Response( response, stream ) { try { if ( typeof data.body === "string" ) { response.write(data.body); + response.end(); } else if ( typeof data.body.forEach !== "function" ) { throw new Error("The body does not have a forEach function"); From 9698652c40ff9b218c9aebce594058eb60e387ef Mon Sep 17 00:00:00 2001 From: Duncan Smith Date: Sun, 14 Sep 2014 19:56:20 -0500 Subject: [PATCH 2/6] Change name for Bogart compat --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f19e84..b69ef6c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "jsgi-node", + "name": "jsgi", "version": "0.3.0", "directories": { "lib": "." }, "main": "./jsgi-node", From 6b14d7323cfb57e1e9a7545d55c82af497e7ae86 Mon Sep 17 00:00:00 2001 From: nrstott Date: Sun, 25 Sep 2016 13:40:38 -0400 Subject: [PATCH 3/6] Make _env unique to each request --- jsgi-node.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jsgi-node.js b/jsgi-node.js index c2c2921..12b3cc5 100644 --- a/jsgi-node.js +++ b/jsgi-node.js @@ -37,6 +37,7 @@ var function Request( request ) { var url = request.url; var questionIndex = url.indexOf("?"); + this._env = {}; this.method = request.method; this.nodeRequest = request; this.headers = request.headers; From be18665a294eabe1dfc9cec1244bda46a354a8eb Mon Sep 17 00:00:00 2001 From: nrstott Date: Sun, 25 Sep 2016 13:41:13 -0400 Subject: [PATCH 4/6] v1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b69ef6c..88c2110 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgi", - "version": "0.3.0", + "version": "1.0.0", "directories": { "lib": "." }, "main": "./jsgi-node", "description": "JSGI middleware server for NodeJS", From ac18f22e28f2649076750a8ba1b7952de6395b88 Mon Sep 17 00:00:00 2001 From: Martin Murphy Date: Tue, 31 Jan 2017 12:51:26 -0600 Subject: [PATCH 5/6] Support for scheme and bugfix on port --- jsgi-node.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/jsgi-node.js b/jsgi-node.js index 12b3cc5..c6bd1e1 100644 --- a/jsgi-node.js +++ b/jsgi-node.js @@ -1,7 +1,7 @@ /* JSGI 0.3 Adapter for Node -To use provide a JSGI application (can be application stack) to the start +To use provide a JSGI application (can be application stack) to the start function: require("jsgi-node").start(function(request){ @@ -14,7 +14,7 @@ function: }); }); -This adapter should conform to the JSGI 0.3 (with promises) for full +This adapter should conform to the JSGI 0.3 (with promises) for full asynchronous support. For example: var fs = require("promised-io/fs"); @@ -52,7 +52,7 @@ function Request( request ) { if(this.method != "GET"){ // optimize GET this.body = new Input( request ); } - + } Request.prototype = { @@ -71,14 +71,17 @@ Request.prototype = { return this._env || (this._env = {}); }, scriptName: "", - scheme:"http", + get scheme(){ + return this.nodeRequest.connection.encrypted ? "https" : "http"; + }, get host(){ var host = this.headers.host; return host ? host.split(":")[0] : ""; }, get port(){ var host = this.headers.host; - return host ? (host.split(":")[1] || 80) : 80; + var isSsl = !!this.nodeRequest.connection.encrypted; + return host ? (host.split(":")[1] || (isSsl ? 443 : 80)) : 80; }, get remoteAddr(){ return this.nodeRequest.connection.remoteAddress; @@ -90,11 +93,11 @@ Request.prototype = { function Input( request ) { - var + var inputBuffer = [], waitingForLength = Infinity; function callback(data){ - inputBuffer.push(data); + inputBuffer.push(data); } var deferred = defer(); request @@ -104,7 +107,7 @@ function Input( request ) { .addListener( "end", function() { deferred.resolve(); }); - + this.forEach = function (each) { if (this.encoding) { request.setBodyEncoding( this.encoding ); @@ -210,7 +213,7 @@ function Response( response, stream ) { }catch(e3){ sys.puts(e3.stack); } - } + } } } @@ -228,7 +231,7 @@ function Listener( app ) { jsgiResponse = app( request ) } catch( error ) { jsgiResponse = { status:500, headers:{}, body:[error.stack] }; - } + } respond( jsgiResponse ); }); } @@ -240,10 +243,10 @@ start.start = start; function start( app, options ) { app = new Listener( app ); options = options || {}; - + var port = options.port || 8080, http; - + if ( options.ssl ) { http = require( "https" ).createServer( options.ssl, app ).listen( port ); } else { @@ -251,6 +254,6 @@ function start( app, options ) { } sys.puts( "Server running on port " + port ); - return http; + return http; }; module.exports = start; From 2b869fd6d03bc13de6b35c56725ab276afd03f0c Mon Sep 17 00:00:00 2001 From: nrstott Date: Tue, 31 Jan 2017 14:04:09 -0500 Subject: [PATCH 6/6] bump to v1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88c2110..674c70a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsgi", - "version": "1.0.0", + "version": "1.0.1", "directories": { "lib": "." }, "main": "./jsgi-node", "description": "JSGI middleware server for NodeJS",