Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated response methods sendHeader to writeHead and close to end

(for node v0.3+)
Corrected server port second in the second output message (nitpick, sorry)
  • Loading branch information...
commit 6644c076793138adf9f0baa67094cc429c138a3d 1 parent 21af5cd
sai authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 example/example.js
View
12 example/example.js
@@ -32,21 +32,21 @@ var webServer = http.createServer(function(request, response) {
sys.puts("Loading "+filename);
path.exists(filename, function(exists) {
if(!exists) {
- response.sendHeader(404);
+ response.writeHead(404);
response.write("404 Not Found\n");
- response.close();
+ response.end();
return;
}
fs.readFile(filename, "binary", function(err, file) {
if(err) {
- response.sendHeader(500);
+ response.writeHead(500);
response.write(err + "\n");
- response.close();
+ response.end();
return;
}
- response.sendHeader(200);
+ response.writeHead(200);
response.write(file, "binary");
response.end();
});
@@ -80,4 +80,4 @@ socket.on('connection', function(client){
});
-sys.puts("WebSocket server running at http://localhost:8080/");
+sys.puts("WebSocket server running at http://localhost:"+WEB_SERVER_PORT+"/");
Please sign in to comment.
Something went wrong with that request. Please try again.