Nikhil Marathe avatar Nikhil Marathe committed 42e90e0

Modified nerve to work with latest Node v0.1.91

Comments (0)

Files changed (2)

deps/nerve/lib/http_state.js

 		idgen = require('./idgen'),
 		sessions = {};
 
-	process.mixin(http.IncomingMessage.prototype, {
-		get_cookie: function (name) {
-			var cookies = this.headers.cookie && this.headers.cookie.split(";"),
-				cookie, parts;
-			while ((cookie = (cookies && cookies.shift()))) {
-				parts = cookie.split("=");
-				if (parts[0].trim() === name) {
-					return parts[1];
-				}
-			}
-		},
-		get_or_create_session: function (req, res, options) {
-			var session_id = req.get_cookie("session_id");
-			if (!session_id) {
-				session_id = idgen.generate_id(22);
-				res.set_cookie("session_id", session_id);
-			}
-			sessions[session_id] = (sessions[session_id] || {
-				session: {session_id: session_id},
-				touch: function () {
-					this.expiration = (+ new Date()) + (options.duration || 30 * 60 * 1000);
-					return this;
-				}
-			}).touch();
-			return sessions[session_id].session;
-		}
-	});
+	http.IncomingMessage.prototype.get_cookie = function (name) {
+        var cookies = this.headers.cookie && this.headers.cookie.split(";"),
+            cookie, parts;
+        while ((cookie = (cookies && cookies.shift()))) {
+            parts = cookie.split("=");
+            if (parts[0].trim() === name) {
+                return parts[1];
+            }
+        }
+    }
 
-	process.mixin(http.ServerResponse.prototype, {
-		set_cookie: function (name, value) {
-			this.cookies = this.cookies || [];
-			this.cookies.push(name + "=" + value + "; path=/;");
-		}
-	});
+    http.IncomingMessage.prototype.get_or_create_session = function (req, res, options) {
+        var session_id = req.get_cookie("session_id");
+        if (!session_id) {
+            session_id = idgen.generate_id(22);
+            res.set_cookie("session_id", session_id);
+        }
+        sessions[session_id] = (sessions[session_id] || {
+            session: {session_id: session_id},
+            touch: function () {
+                this.expiration = (+ new Date()) + (options.duration || 30 * 60 * 1000);
+                return this;
+            }
+        }).touch();
+        return sessions[session_id].session;
+    }
+
+	http.ServerResponse.prototype.set_cookie = function (name, value) {
+        this.cookies = this.cookies || [];
+        this.cookies.push(name + "=" + value + "; path=/;");
+    }
 
 	function cleanup_sessions() {
 		for (var session_id in sessions) {

deps/nerve/lib/nerve.js

 		fs = require('fs'),
 		mime = require('./mime');
 
-	process.mixin(http.ServerResponse.prototype, {
-		respond: function (response_data) {
+	http.ServerResponse.prototype.respond = function (response_data) {
 			var headers = {
 				'Content-Type': 'text/html',
 				'Content-Length': (response_data.content && response_data.content.length) || response_data.length || 0
 					headers[name] = response_data.headers[name];
 				}
 			}
-			this.writeHeader(response_data.status_code || 200, headers);
+			this.writeHead(response_data.status_code || 200, headers);
 			this.write(response_data.content || response_data, 'binary');
-			this.close();
+			this.end();
 		}
-	});
 	
 	function match_request(matcher, req) {
 		if (typeof matcher === 'string') {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.