Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Standardize whitespace (consistent indendataion)

  • Loading branch information...
commit aad5387f843e090962815ae1eb9c43a33b4244ce 1 parent f863bc2
@fidian fidian authored
Showing with 61 additions and 59 deletions.
  1. +61 −59 cgi.js
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);
};
Please sign in to comment.
Something went wrong with that request. Please try again.