MIT license + npm package.json #3

Merged
merged 3 commits into from Aug 5, 2012
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2010 Brian McKenna
+
+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.
View
120 cgi.js
@@ -1,73 +1,75 @@
var sys = require('sys'),
- http = require('http');
+http = require('http');
var Request = function() {
- this.method = process.env['REQUEST_METHOD'];
- this.headers = {
- 'host': process.env['HTTP_HOST'],
- 'user-agent': process.env['HTTP_USER_AGENT']
- };
- this.url = process.env['REQUEST_URI'];
+ this.method = process.env['REQUEST_METHOD'];
+ this.headers = {
+ 'host': process.env['HTTP_HOST'],
+ 'user-agent': process.env['HTTP_USER_AGENT']
+ };
+ this.url = process.env['REQUEST_URI'];
};
var Response = function() {
- var body = false;
-
- this.writeHead = function() {
- var status = arguments[0];
- var reason = arguments[1];
- var headers = arguments[2];
-
- if(typeof reason != 'string') {
- headers = reason;
- reason = http.STATUS_CODES[arguments[0]] || 'unknown';
- }
-
- sys.puts('Status: ' + status + ' ' + reason);
-
- var field, value;
- var keys = Object.keys(headers);
- var isArray = (headers instanceof Array);
- for (var i = 0, l = keys.length; i < l; i++) {
- var key = keys[i];
- if (isArray) {
- field = headers[key][0];
- value = headers[key][1];
- } else {
- field = key;
- value = headers[key];
- }
-
- sys.puts(field + ": " + value);
- }
- };
-
- this.write = function(message) {
- if(!body) {
- body = true;
- sys.puts("");
- }
-
- if(message) sys.print(message);
- };
-
- this.flush = function() {
- };
-
- this.end = function() {
- this.write.apply(this, arguments);
- };
+ var body = false;
+
+ this.writeHead = function() {
+ var status = arguments[0];
+ var reason = arguments[1];
+ var headers = arguments[2];
+
+ if (typeof reason != 'string') {
+ headers = reason;
+ reason = http.STATUS_CODES[arguments[0]] || 'unknown';
+ }
+
+ sys.puts('Status: ' + status + ' ' + reason);
+
+ var field, value;
+ var keys = Object.keys(headers);
+ var isArray = (headers instanceof Array);
+
+ for (var i = 0, l = keys.length; i < l; i++) {
+ var key = keys[i];
+
+ if (isArray) {
+ field = headers[key][0];
+ value = headers[key][1];
+ } else {
+ field = key;
+ value = headers[key];
+ }
+
+ sys.puts(field + ": " + value);
+ }
+ };
+
+ this.write = function(message) {
+ if (!body) {
+ body = true;
+ sys.puts("");
+ }
+
+ if (message) sys.print(message);
+ };
+
+ this.flush = function() {
+ };
+
+ this.end = function() {
+ this.write.apply(this, arguments);
+ };
};
var Server = function(listener, options) {
- var request = new Request();
- var response = new Response();
+ var request = new Request();
+ var response = new Response();
- this.listen = function() {
- listener(request, response);
- };
+ this.listen = function() {
+ listener(request, response);
+ };
};
exports.createServer = function(listener, options) {
- return new Server(listener, options);
+ return new Server(listener, options);
};
View
26 package.json
@@ -0,0 +1,26 @@
+{
+ "name": "node-cgi",
+ "version": "0.1.1",
+ "author": "Brian McKenna <brian@brianmckenna.org>",
+ "description": "CGI adapter for node.js for servers that must use CGI",
+ "homepage": "http://brianmckenna.org/blog/nodejs_via_cgi",
+ "contributors": [
+ "Brian McKenna <brian@brianmckenna.org> (http://brianmckenna.org/)",
+ "Tyler Akins <fidian@rumkin.com> (http://rumkin.com/)"
+ ],
+ "main": "./cgi.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/pufuwozu/node-cgi.git"
+ },
+ "keywords": [
+ "cgi"
+ ],
+ "dependencies": {},
+ "devDependencies": {},
+ "license": "MIT",
+ "engines": {
+ "node": "~0.6",
+ "npm": "~1"
+ }
+}
4 readme.md
@@ -29,3 +29,7 @@ Copy `cgi.js` to the same directory and make the actual CGI script (`server.cgi`
server.listen();
As you can see, using the `cgi` library is very similar to the `http` library in node.js
+
+## License
+
+The `cgi.js` library is released under an MIT license. See `LICENSE` for the full text of the license.