diff --git a/test-http_simple.js b/benchmark/http_simple.js
similarity index 100%
rename from test-http_simple.js
rename to benchmark/http_simple.js
diff --git a/benchmark/http_simple.rb b/benchmark/http_simple.rb
new file mode 100644
index 0000000000..ee33f57f1d
--- /dev/null
+++ b/benchmark/http_simple.rb
@@ -0,0 +1,95 @@
+DIR = File.dirname(__FILE__)
+
+def fib(n)
+ return 1 if n <= 1
+ fib(n-1) + fib(n-2)
+end
+
+def wait(seconds)
+ n = (seconds / 0.01).to_i
+ n.times do
+ sleep(0.01)
+ #File.read(DIR + '/yahoo.html')
+ end
+end
+
+class SimpleApp
+ @@responses = {}
+
+ def initialize
+ @count = 0
+ end
+
+ def deferred?(env)
+ false
+ end
+
+ def call(env)
+ path = env['PATH_INFO'] || env['REQUEST_URI']
+ commands = path.split('/')
+
+ @count += 1
+ if commands.include?('periodical_activity') and @count % 10 != 1
+ return [200, {'Content-Type'=>'text/plain'}, "quick response!\r\n"]
+ end
+
+ if commands.include?('fibonacci')
+ n = commands.last.to_i
+ raise "fibonacci called with n <= 0" if n <= 0
+ body = (1..n).to_a.map { |i| fib(i).to_s }.join(' ')
+ status = 200
+
+ elsif commands.include?('wait')
+ n = commands.last.to_f
+ raise "wait called with n <= 0" if n <= 0
+ wait(n)
+ body = "waited about #{n} seconds"
+ status = 200
+
+ elsif commands.include?('bytes')
+ n = commands.last.to_i
+ raise "bytes called with n <= 0" if n <= 0
+ body = @@responses[n] || "C"*n
+ status = 200
+
+ elsif commands.include?('fixed')
+ n = 20 * 1024;
+ body = @@responses[n] || "C"*n
+ status = 200
+
+ elsif commands.include?('test_post_length')
+ input_body = ""
+ while chunk = env['rack.input'].read(512)
+ input_body << chunk
+ end
+ if env['CONTENT_LENGTH'].to_i == input_body.length
+ body = "Content-Length matches input length"
+ status = 200
+ else
+ body = "Content-Length doesn't matches input length!
+ content_length = #{env['CONTENT_LENGTH'].to_i}
+ input_body.length = #{input_body.length}"
+ status = 500
+ end
+ else
+ status = 404
+ body = "Undefined url"
+ end
+
+ body += "\r\n"
+ headers = {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }
+ [status, headers, [body]]
+ end
+end
+
+
+if $0 == __FILE__
+ #require DIR + '/../lib/ebb'
+ require 'rubygems'
+ require 'rack'
+ require 'thin'
+ require 'ebb'
+# Rack::Handler::Mongrel.run(SimpleApp.new, :Port => 8000)
+ Thin::Server.start("0.0.0.0", 8000, SimpleApp.new)
+# Ebb::start_server(SimpleApp.new, :port => 8000)
+end
diff --git a/src/file.js b/src/file.js
index a087be4ad9..b4b99fefde 100644
--- a/src/file.js
+++ b/src/file.js
@@ -12,7 +12,7 @@ node.fs.cat = function (path, encoding, callback) {
callback(-1);
};
- var content = (encoding == node.constants.UTF8 ? "" : []);
+ var content = (encoding == node.UTF8 ? "" : []);
var pos = 0;
var chunkSize = 16*1024;
@@ -41,9 +41,9 @@ node.fs.File = function (options) {
options = options || {};
if (options.encoding === "utf8") {
- self.encoding = node.constants.UTF8;
+ self.encoding = node.UTF8;
} else {
- self.encoding = node.constants.RAW;
+ self.encoding = node.RAW;
}
//node.debug("encoding: opts=" + options.encoding + " self=" + self.encoding);
@@ -104,22 +104,22 @@ node.fs.File = function (options) {
var flags;
switch (mode) {
case "r":
- flags = node.constants.O_RDONLY;
+ flags = node.O_RDONLY;
break;
case "r+":
- flags = node.constants.O_RDWR;
+ flags = node.O_RDWR;
break;
case "w":
- flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_WRONLY;
+ flags = node.O_CREAT | node.O_TRUNC | node.O_WRONLY;
break;
case "w+":
- flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_RDWR;
+ flags = node.O_CREAT | node.O_TRUNC | node.O_RDWR;
break;
case "a":
- flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_WRONLY;
+ flags = node.O_APPEND | node.O_CREAT | node.O_WRONLY;
break;
case "a+":
- flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_RDWR;
+ flags = node.O_APPEND | node.O_CREAT | node.O_RDWR;
break;
default:
throw "Unknown mode";
@@ -173,9 +173,9 @@ node.fs.File = function (options) {
};
};
-stdout = new node.fs.File({ fd: node.constants.STDOUT_FILENO });
-stderr = new node.fs.File({ fd: node.constants.STDERR_FILENO });
-stdin = new node.fs.File({ fd: node.constants.STDIN_FILENO });
+stdout = new node.fs.File({ fd: node.STDOUT_FILENO });
+stderr = new node.fs.File({ fd: node.STDERR_FILENO });
+stdin = new node.fs.File({ fd: node.STDIN_FILENO });
puts = stdout.puts;
print = stdout.print;
diff --git a/src/net.cc b/src/net.cc
index 8148937c18..dc57992977 100644
--- a/src/net.cc
+++ b/src/net.cc
@@ -42,14 +42,14 @@ using namespace node;
#define CLOSED_SYMBOL String::NewSymbol("closed")
static const struct addrinfo server_tcp_hints =
-/* ai_flags */ { AI_PASSIVE | AI_ADDRCONFIG
+/* ai_flags */ { AI_PASSIVE
/* ai_family */ , AF_UNSPEC
/* ai_socktype */ , SOCK_STREAM
, 0
};
static const struct addrinfo client_tcp_hints =
-/* ai_flags */ { AI_ADDRCONFIG
+/* ai_flags */ { 0
/* ai_family */ , AF_UNSPEC
/* ai_socktype */ , SOCK_STREAM
, 0
@@ -243,7 +243,8 @@ Connection::Resolve (eio_req *req)
{
Connection *connection = static_cast (req->data);
struct addrinfo *address = NULL;
- req->result = getaddrinfo(connection->host_, connection->port_, &client_tcp_hints, &address);
+ req->result = getaddrinfo(connection->host_, connection->port_,
+ &client_tcp_hints, &address);
req->ptr2 = address;
free(connection->host_);
@@ -264,29 +265,11 @@ AddressDefaultToIPv4 (struct addrinfo *address_list)
{
struct addrinfo *address = NULL;
-/*
- char ip4[INET_ADDRSTRLEN], ip6[INET6_ADDRSTRLEN];
- for (address = address_list; address != NULL; address = address->ai_next) {
- if (address->ai_family == AF_INET) {
- struct sockaddr_in *sa = reinterpret_cast(address->ai_addr);
- inet_ntop(AF_INET, &(sa->sin_addr), ip4, INET_ADDRSTRLEN);
- printf("%s\n", ip4);
-
- } else if (address->ai_family == AF_INET6) {
- struct sockaddr_in6 *sa6 = reinterpret_cast(address->ai_addr);
- inet_ntop(AF_INET6, &(sa6->sin6_addr), ip6, INET6_ADDRSTRLEN);
- printf("%s\n", ip6);
- }
- }
-*/
-
for (address = address_list; address != NULL; address = address->ai_next) {
if (address->ai_addr->sa_family == AF_INET) break;
}
- if (address == NULL) address = address_list;
-
- return address;
+ return address == NULL ? address_list : address;
}
int
@@ -591,21 +574,21 @@ static void
SetRemoteAddress (Local
- encoding
is either node.constants.UTF8
- or node.constants.RAW
.
+ encoding
is either node.UTF8
+ or node.RAW
.
diff --git a/website/index.html b/website/index.html
index de0eaff468..d8e6faa6e8 100644
--- a/website/index.html
+++ b/website/index.html
@@ -154,6 +154,10 @@ Server running at http://127.0.0.1:8000/
git repo
+ -
+ 2009.06.18
+ node-0.0.5.tar.gz
+
-
2009.06.13
node-0.0.4.tar.gz
diff --git a/wscript b/wscript
index 2b40f64395..8d49a88118 100644
--- a/wscript
+++ b/wscript
@@ -8,7 +8,7 @@ from logging import fatal
import js2c
-VERSION='0.0.4'
+VERSION='0.0.5'
APPNAME='node'
srcdir = '.'