0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/http_api.js

26 lines
525 B
JavaScript

function encode(data) {
var chunk = data.toString();
return chunk.length.toString(16) + "\r\n" + chunk + "\r\n";
}
var port = 8000;
var server = new HTTPServer("localhost", port);
server.onrequest = function (request) {
log("path: " + request.path);
log("query string: " + request.query_string);
request.respond("HTTP/1.1 200 OK\r\n");
request.respond("Content-Length: 0\r\n");
request.respond("\r\n");
request.respond(null);
};
log("Running at http://localhost:" + port + "/");
/*
server.close();
*/