Instead we're going to just get a single callback for the URI. This can be
parsed additionally in javascript using parseuri:
http://blog.stevenlevithan.com/archives/parseuri
I haven't added that yet, but it will come soon.
Encoding UTF-16 (the native string representation) to UTF-8 is rather
expensive, however just chopping off the second bit to convert UTF-16 to
ASCII is rather fast. I've noticed major performance issues with
String::WriteUtf8 and thus I'm going to explicitly separate in the API.
Still need interfaces to this for the web server.
This is sloppy: after each ObjectWrap allocation the user needs to
call ObjectWrap::InformV8ofAllocation(). In addition each class deriving
from ObjectWrap needs to implement the virtual method size() which should
return the size of the derived class. If I was better at C++ I could
possibly make this less ugly. For now this is how it is.
Memory usage looks much better after this commit.
Instead servers are passed a function which gets called on connection (like
in the original design) which has one argument, the connecting socket. The
user sets up callbacks on that. It's pretty much how I had it originally.
Encoding is now set via v8 getter/setter and can be changed dynamically.
The timeout for all sockets is fixed at 60 seconds for now. Need to fix
that.
The LowLevelServer is a direct interface to the parser given people access
to things like partially received headers. This could be used to implement
an extremely optimized server which acts before parsing is complete.
Most people will be using node.http.Server which is still rather low-level
compared to other http interfaces, but does take care of some details for
you.
Connections were being garbage collected while they were still in progress
since the object would leave scope. This commit adds ObjectWrap::Attach()
and ObjectWrap::Detach() to tell v8 that an object is currently on the event
loop and will be needed in the future.
Other changes to oi_socket.c and net.cc are to fix bugs encountered while
running the HTTP server.
For server-side sockets, no longer pass the server object to the
js constructor. This is set later with SetAcceptor.
I think the change is a bit strage and convoluted but it allows one give
protocol /classes/ to the c++ constructors instead of protocol instances.
This is nice because derived classes (like HTTP) don't need to copy the
protocol instanciation code.