Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tutorial review

  • Loading branch information...
commit ae372d3b49d19ef58052148e4ea77f0ab60b0268 1 parent 015646b
@bjouhier bjouhier authored
View
7 tutorial/tuto1-hello._js
@@ -2,8 +2,9 @@
var streams = require('streamline/lib/streams/server/streams');
streams.createHttpServer(function(request, response, _) {
- response.writeHead(200, {'Content-Type': 'text/plain'});
+ response.writeHead(200, {
+ 'Content-Type': 'text/plain; charset=utf8'
+ });
response.end("Hello world!");
-
}).listen(_, 1337);
-console.log('Server running at http://127.0.0.1:1337/');
+console.log('Server running at http://127.0.0.1:1337/');
View
2  tutorial/tuto2-form._js
@@ -14,7 +14,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
View
2  tutorial/tuto3-google._js
@@ -14,7 +14,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
View
2  tutorial/tuto4-catch._js
@@ -14,7 +14,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
View
11 tutorial/tuto5-files._js
@@ -15,7 +15,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
@@ -55,13 +55,14 @@ function fileSearch(_, q) {
function doDir(_, dir) {
fs.readdir(dir, _).forEach_(_, function(_, file) {
- var stat = fs.stat(dir + '/' + file, _);
+ var f = dir + '/' + file;
+ var stat = fs.stat(f, _);
if (stat.isFile()) {
- fs.readFile(dir + '/' + file, 'utf8', _).split('\n').forEach(function(line, i) {
- if (line.indexOf(q) >= 0) results += '<br/>' + dir + '/' + file + ':' + i + ':' + line;
+ fs.readFile(f, 'utf8', _).split('\n').forEach(function(line, i) {
+ if (line.indexOf(q) >= 0) results += '<br/>' + f + ':' + i + ':' + line;
});
} else if (stat.isDirectory()) {
- doDir(_, dir + '/' + file);
+ doDir(_, f);
}
});
}
View
11 tutorial/tuto6-mongo._js
@@ -14,7 +14,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
@@ -58,13 +58,14 @@ function fileSearch(_, q) {
function doDir(_, dir) {
fs.readdir(dir, _).forEach_(_, function(_, file) {
- var stat = fs.stat(dir + '/' + file, _);
+ var f = dir + '/' + file;
+ var stat = fs.stat(f, _);
if (stat.isFile()) {
- fs.readFile(dir + '/' + file, 'utf8', _).split('\n').forEach(function(line, i) {
- if (line.indexOf(q) >= 0) results += '<br/>' + dir + '/' + file + ':' + i + ':' + line;
+ fs.readFile(f, 'utf8', _).split('\n').forEach(function(line, i) {
+ if (line.indexOf(q) >= 0) results += '<br/>' + f + ':' + i + ':' + line;
});
} else if (stat.isDirectory()) {
- doDir(_, dir + '/' + file);
+ doDir(_, f);
}
});
}
View
11 tutorial/tuto7-parallel._js
@@ -14,7 +14,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
@@ -66,16 +66,17 @@ function fileSearch(_, q) {
function doDir(_, dir) {
fs.readdir(dir, _).forEach_(_, -1, function(_, file) {
- var stat = fs.stat(dir + '/' + file, _);
+ var f = dir + '/' + file;
+ var stat = fs.stat(f, _);
if (stat.isFile()) {
// use the funnel to limit the number of open files
filesFunnel(_, function(_) {
- fs.readFile(dir + '/' + file, 'utf8', _).split('\n').forEach(function(line, i) {
- if (line.indexOf(q) >= 0) results += '<br/>' + dir + '/' + file + ':' + i + ':' + line;
+ fs.readFile(f, 'utf8', _).split('\n').forEach(function(line, i) {
+ if (line.indexOf(q) >= 0) results += '<br/>' + f + ':' + i + ':' + line;
});
});
} else if (stat.isDirectory()) {
- doDir(_, dir + '/' + file);
+ doDir(_, f);
}
});
}
View
6 tutorial/tutorial.md
@@ -12,7 +12,9 @@ Let us start with streamline's version of node's hello world:
var streams = require('streamline/lib/streams/server/streams');
streams.createHttpServer(function(request, response, _) {
- response.writeHead(200, {'Content-Type': 'text/plain'});
+ response.writeHead(200, {
+ 'Content-Type': 'text/plain; charset=utf8'
+ });
response.end("Hello world!");
}).listen(_, 1337);
@@ -56,7 +58,7 @@ streams.createHttpServer(function(request, response, _) {
var query = qs.parse(url.parse(request.url).query),
t0 = new Date();
response.writeHead(200, {
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html; charset=utf8'
});
response.write(_, begPage.replace('{q}', query.q || ''));
response.write(_, search(_, query.q));
Please sign in to comment.
Something went wrong with that request. Please try again.