Commit Graph

3378 Commits

Author SHA1 Message Date
Ryan
854538d094 Missing HandleScope in GetMethod(). Thanks Brian. 2009-07-24 20:20:01 +02:00
Ryan
50c0d16208 Fix memory leak. It was only a missing HandleScope in Emit()!
This change also tries to optimize Emit by looping through the listeners in
C++. The javascript version of this function is still there and being used,
but only by javascript code. Not an ideal solution - there should only be
one implementation - however for now it seems to help.

This doesn't solve all of the memory leaks that we're experiencing, there
seems to be another subtle problem.
2009-07-24 15:11:18 +02:00
Ryan
78aaf8df67 Remove unused static object. 2009-07-24 01:15:21 +02:00
Ryan
646829262f Fix evnet_buf size calculation for V8::AdjustAmountOfExternalAllocatedMemory(). 2009-07-23 18:36:28 +02:00
Ryan
dd1750f573 Clean up little errors in events.js 2009-07-23 18:35:43 +02:00
Ryan
0462b5d1ec ObjectWrap: MakeWeak again after each Weak callback. 2009-07-23 18:35:03 +02:00
Ryan
b1588e78d9 Fix utf8 scripts, add test. Thanks Urban. 2009-07-20 21:22:19 +02:00
Ryan
e8a5d3d311 remove the callback from node.cat, node.fs.cat 2009-07-20 21:09:37 +02:00
Ryan
b07dc31e1b root_module should be a local variable 2009-07-20 18:30:15 +02:00
Ryan
2a695a9721 Array.prototype.encodeUtf8 renamed to node.encodeUtf8(array) 2009-07-20 18:19:13 +02:00
Ryan
e7bbda0b7f Attach connections on Macintosh too. 2009-07-20 12:52:03 +02:00
Ryan
eb10553634 Move node.inherit, node.path, node.cat to new file: util.js 2009-07-16 17:19:36 +02:00
Ryan
edbae656d6 Add IsNearDeath assertion to ObjectWrap destructor 2009-07-16 15:43:03 +02:00
Ryan
56c785ceae small clean ups to http.js 2009-07-16 11:23:37 +02:00
Ryan
0292dea847 Better error output for socket errors. Temporary. 2009-07-15 17:52:11 +02:00
Ryan
1b6bbc619d Bugfix: Server-side clients not attached between creation and on_connect.
Solution is to manually add Attach() to OnConnection.

For client side it seems there is no Detach() being called after NS
resolution? Otherwise I would have removed it. That was another bug.

Note: We don't want to modify evnet's behavior to have on_connect called
directly when the socket is accepted. evnet needs to support SSL, and
on_connect is supposed to signal that the SSL connection is established. The
point here is that being "connected" and being "attached" to the event loop
are two different things. SSL stuff may be transmitted when a socket is not
"connected" but it must always be attached.
2009-07-15 17:36:30 +02:00
Ryan
fc02221393 Remove unused variable from ~Connection 2009-07-15 17:36:30 +02:00
Ryan
ef09b2c65d large http.js refactor 2009-07-14 18:31:50 +02:00
Ryan
216e6204f0 http: Add IncomingMessage as abstract base class of ServerReq ClientRes 2009-07-14 12:03:47 +02:00
Ryan
2819e3bcb8 Replace some printf() in src/net with asserts 2009-07-13 16:38:55 +02:00
Ryan
f99fbc61e1 Add 'close' event to tcp.Server 2009-07-13 16:38:55 +02:00
Ryan
bf6a457f64 Use assert() for Unwrap checks instead of JS error. 2009-07-13 16:38:55 +02:00
Ryan
041af82b8c Bugfix: Sockets not properly reattached if reconnected during disconnect event.
The problem was that Connection::on_close was calling Detach() directly
after executing the "disconnect" event. Since we had a boolean attach count,
this was leaving sockets detached even if they had reattached in during the
event.

 * Added many asserts in http.cc and net.cc to ensure that sockets are
   connected when they should be.

 * Changed ObjectWrap to use a reference count instead of boolean attached_
   value.

 * Fixed similar bug in Timer.
2009-07-13 16:38:55 +02:00
Ryan
996d5ef5f1 Add res.client to ClientResponse 2009-07-13 16:38:54 +02:00
Ryan
c5ab0d5a80 Upgrade liboi, which is now called evnet. 2009-07-13 16:38:25 +02:00
Ryan
51e77c37b5 Do not call Detach() from Server::~Server. 2009-07-11 11:43:06 +02:00
Ryan
22c3a1e2a5 Templatize ObjectWrap::Unwrap. Remove NODE_UNWRAP macro. 2009-07-10 13:57:58 +02:00
Ryan
1fc4dce08b Simplify and cleanup ObjectWrap.
Simplify and inline ObjectWrap::Wrap

    Inline and clean up ObjectWrap::Unwrap

    Move ObjectWrap into its own file.

    Remove handle from ObjectWrap constructor. add obj->Wrap(handle)

    Simplify Attach/Detach in ObjectWrap

    Remove ObjectWrap::InformV8ofAllocation. (Too messy/complex.)
2009-07-10 13:38:53 +02:00
Joshaven Potter
4b9f26c51a validate js 2009-07-01 02:33:08 +02:00
Ryan
8047b912c0 Change 'new node.tcp.Connection' to 'node.tcp.createConnection' 2009-06-30 13:56:52 +02:00
Ryan
d56552dc66 Remove node.Process constructor from API 2009-06-30 13:46:35 +02:00
Ryan
e4ba665c87 Fix ref/unref problem. Was doing opposite of what I should. 2009-06-29 20:53:54 +02:00
Ryan
e7ad8ab4b0 Clean up some of the event handling code 2009-06-29 14:11:01 +02:00
Ryan
d428eff023 Snakecase events . 2009-06-29 13:18:30 +02:00
Ryan
c2bdc01870 Bad array index in AfterStat() 2009-06-29 13:17:49 +02:00
Ryan
e876d6629e Fix unused variable warnings. 2009-06-28 20:11:55 +02:00
Ryan
89320036a8 Timer::RepeatSetter wasn't getting the right value 2009-06-28 19:58:13 +02:00
Ryan
4787a41b84 Fix Process::MaybeShutdown's return type 2009-06-28 19:55:35 +02:00
Ryan
c9cb41cf80 Wrong number of arguments being passed to emit in AfterOpen 2009-06-28 19:34:54 +02:00
Ryan
65324866bc Implement Promises for file i/o 2009-06-28 19:08:27 +02:00
Ryan
7cd09874c6 Add Promise class 2009-06-28 19:08:27 +02:00
Ryan
ed926da691 Remove onEvent compatibility 2009-06-28 19:08:26 +02:00
Ryan
80bf451e6e Use EventEmitter for node.Process 2009-06-28 19:08:26 +02:00
Ryan
70fe920fb5 Use events for all HTTP messages.
This is a rather large refactor! Mostly for the better side. I've had to
remove some functionality like req.interrupt(). A lot of other work is left
messy or incomplete.
2009-06-28 19:08:26 +02:00
Ryan
20c0e1fdfb events for http.Server 2009-06-28 19:08:26 +02:00
Ryan
ed3d6a63d5 Further expand EventEmitter to TCP and HTTP
The constructor for TCP servers can no longer take a connection handler for
purely technical reasons. (The constructor for EventEmitter is implemented
in C++ but addListener is in javascript, and I don't want to make too many
C++ -> Javascript references.) Thus I introduce new constructor methods to
ease the creation of the servers:

  node.tcp.createServer()
  node.http.createServer()

These work almost the same as the old constructors.

In general we're working towards a future where no constructors are
publicly exposed or take arguments.

The HTTP events like "on_uri" are not yet using the event interface.
onMessage still is a constructor - but this will change soon.
2009-06-28 19:08:26 +02:00
Ryan
b4af3b9fb5 Timers on Events 2009-06-28 19:08:25 +02:00
Ryan
2ecd7ffe54 in the middle putting in event code. broken. 2009-06-28 19:08:25 +02:00
Ryan
5ab93502d0 Fix issue in 5b7fb10 2009-06-27 00:13:37 +02:00
Ryan
7363ccd273 bugfix: Properly exit a process.
This requires that onExit() is not called immediately upon receiving a
SIGCHLD. There could still be data in the pipez. So, instead just set a
flag and invoke the pipe watchers.

Sometimes one will not receive an EOF from pipes because the process was
killed by a SIGTERM, or something. If SIGCHLD has been recved but we are
getting EAGAIN, the pipez need to be closed too.
2009-06-24 13:44:12 +02:00
Ryan
0e67b34c27 Fix thread pool unref issue.
Tests were silently failing since f56309d...

Since the eio_watcher is now not counted in the list of active watchers, we
need to explicitly tell the ev_loop not to exit when entering the thread
pool.
2009-06-23 11:27:18 +02:00
Ryan
0ff62b2ea0 Move oi_buf creation to node.cc 2009-06-22 19:48:02 +02:00
Ryan
f56309deee Remove eio_warmup. Use ev_ref instead. 2009-06-22 19:32:42 +02:00
Ryan
dce072a67e lint 2009-06-22 13:12:47 +02:00
Ryan
00d9b886c1 Remove unnecessary Detach 2009-06-21 23:28:12 +02:00
Urban Hafner
ea290e727d Finished remote module loading 2009-06-21 16:59:11 +02:00
Urban Hafner
ad15067ea0 Tests and implementation of node.cat() 2009-06-21 16:40:08 +02:00
Urban Hafner
c192a1b5df Update to use the new parseUri() 2009-06-21 16:28:58 +02:00
Urban Hafner
6550e8cfa0 Remove empty parts of the parsed URI. 2009-06-21 16:28:23 +02:00
Urban Hafner
3a44efea69 Merge branch 'master' of git://github.com/ry/node 2009-06-21 16:10:20 +02:00
Ryan
0f76d3e6d8 define signal constants 2009-06-21 13:50:13 +02:00
Ryan
e39923a3d7 Add process.kill(sig = SIGTERM) 2009-06-21 13:41:03 +02:00
Ryan
2fd4958698 Add pid accessor 2009-06-21 13:29:15 +02:00
Ryan
a78ea510a2 Add onExit callback 2009-06-21 13:18:00 +02:00
Ryan
03c5772ce4 Get stdin/stdout working. Add process->Close(). 2009-06-21 13:10:00 +02:00
Ryan
83cb156b6f skelton of node.Process 2009-06-20 16:55:40 +02:00
Ryan
25d14bd001 Bug: Add HTTPConnection->size() and HTTPServer->size()
Need this for proper garbage collection.
2009-06-20 15:17:54 +02:00
Urban Hafner
fc63f840b0 Merge branch 'master' of git://github.com/ry/node 2009-06-19 09:03:24 +02:00
Ryan
7ec90dbfd0 Clean up debug code in net.cc 2009-06-18 15:35:02 +02:00
Ryan
2b557c467f Namespace trimming: remove node.constants 2009-06-18 14:58:17 +02:00
Ryan
e30e4415ee Fixes for ipv6 2009-06-18 14:34:49 +02:00
Urban Hafner
5ad5d89e3f Merge branch 'master' of git://github.com/ry/node 2009-06-18 09:27:12 +02:00
Ryan
27b268b8c1 Clean ups 2009-06-17 15:05:44 +02:00
Ryan
b3b6f8c02e Accept ports represented as strings 2009-06-17 10:16:48 +02:00
Urban Hafner
ce85f84d15 Implementation of node.http.cat 2009-06-17 08:52:47 +02:00
Ryan
d77f757745 Fix test-http-client-race bug 2009-06-16 20:53:15 +02:00
Ryan
193283bc38 Fix memleak: freeaddrinfo() after Server resolve address. 2009-06-16 17:47:59 +02:00
Ryan
225637a15c Resolve should default to IPv4 address. 2009-06-16 17:43:40 +02:00
Ryan
3b05cf260e Add "opening" readyState for the resolve period. 2009-06-16 15:50:52 +02:00
Ryan
7cce31d4e4 Add global print() function. 2009-06-15 16:57:10 +02:00
Ryan
870b5db46c Bugfix+Refactor: accessing HTTP connection remoteAddress 2009-06-15 15:29:32 +02:00
Ryan
dcf5e72036 Fiddle with remoteAddress 2009-06-15 14:35:02 +02:00
Ryan
6697cd0725 small superficial clean-ups 2009-06-13 16:47:09 +02:00
Ryan
916b9ca715 Add Request objects on the HTTP server can be interrupted. 2009-06-12 17:37:43 +02:00
Ryan
825d7a8be8 Remove unused HTTPConnection destructor 2009-06-12 17:30:37 +02:00
Ryan
3a0de007aa onBodyComplete was not getting called in HTTP server 2009-06-12 15:26:06 +02:00
Ryan
f657a6324a Fix comment/test for Mac getaddinfo() bug.
Note: the test case was broken because on Macintosh the client connects
synchronously. This is undesirable but ok for now.
2009-06-11 11:42:43 +02:00
Ryan
6bfcfa7d74 remove unnecessary pthread header 2009-06-10 19:05:54 +02:00
Ryan
080fa54a85 fix for issue 3; but now experiencing segfault on linux 2009-06-10 18:29:59 +02:00
Ryan
0d780fe6b8 Free pointer with delete, since created with new 2009-06-10 15:24:14 +02:00
Ryan
2641582399 Extra header to work with freebsd 2009-06-09 17:47:42 +02:00
Ryan
88c04e74c9 Add HTTP proxy test. Fix bug in http.Server.
was not properly inheriting http.Server from http.LowLevelServer.
2009-06-09 14:10:53 +02:00
Ryan
ddac43f4ba Allow for absolute paths to specify root module 2009-06-09 10:06:04 +02:00
Ryan
8c146dfa0b Don't use AI_NUMERICSERV. Doesn't work on mac. 2009-06-08 23:56:09 +02:00
Ryan
8b49cef10b Modify the tests to use onExit hook.
No need to rely on stdout output now.
onExit callbacks should print stack trace from onExit failure
2009-06-08 19:10:36 +02:00
Ryan
f6a7fe2657 Implement onExit() hook for modules.
onExit() is similar to the onLoad() callback. onExit() is called on each
module just before the process exits. This can be used to check state in
unit tests, but not to perform I/O. The process will forcibly exit as soon
as all of the onExit callbacks are made.
2009-06-08 16:17:33 +02:00
Ryan
b6fe4aec50 Module system refactor
There is one major API change in the refactor: filename extensions are now
required when requiring or including modules.

Added extra test to test-module-loading.js.
2009-06-08 15:34:15 +02:00
Ryan
887f056923 Do not assume transfer-encoding: chunked as default on requests.
If users do not send transfer-encoding or content-length headers, then I
will not add any additional. Content-Length: 0 is assumed if there aren't
other headers and chunked encoding is rare.
2009-06-06 23:57:15 +02:00
Ryan
5558bc4e6e Add connection.remoteAddress for server-side node.tcp.Connections. 2009-06-05 20:15:54 +02:00
Ryan
6e4e228665 Don't use AI_PASSIVE in getaddrinfo() for client connections. 2009-06-05 15:10:46 +02:00
Ryan
c226f81768 Fix HTTP client output bug. 2009-06-04 15:44:38 +02:00
Ryan
c457b829e2 If http.Client has an error, do not continue to reconnect. 2009-06-04 12:39:19 +02:00
Ryan
8cfdd326a8 Add "had_error" argument to the "onDisconnect" in node.tcp.Client
This is a boolean value which allows one to detect if the socket was closed
due to errors. There is not yet a way to look up the actual error code.
2009-06-04 12:33:19 +02:00
Ryan
8bf2a2fa55 Rename req.uri.queryKey to req.uri.params. More familar to rails users. 2009-06-01 20:59:33 +02:00
Ryan
ed283dc280 Fix bug: catting non-existent files 2009-06-01 12:56:28 +02:00
Ryan
aceb1987ed Remove complex string appending in http's send() method.
That seems to churn the garbage collector like mad.
Before: http://s3.amazonaws.com/four.livejournal/20090529/timeseries6.png
After:  http://s3.amazonaws.com/four.livejournal/20090529/timeseries11.png
Got a nice tight side profile for this benchmark now:
http://s3.amazonaws.com/four.livejournal/20090529/hist10.png
2009-05-29 17:05:03 +02:00
Ryan
247c9d2210 Remove unnecessary AdjustAmountOfExternalAllocatedMemory from node.http. 2009-05-29 13:58:52 +02:00
Ryan
34a6f10695 Fix ::exit() compile issues.
Thanks Matthias!
2009-05-28 14:47:16 +02:00
Ryan
11b2e5dcc4 Remove file access flags that arn't present in macintosh. 2009-05-26 20:35:42 +02:00
Ryan
b260a9108b Add errno constants. Move all constants to node.constants namespace. 2009-05-26 19:48:49 +02:00
Ryan
3bdd042a6e Rename fatal_exception to FatalException 2009-05-26 18:18:17 +02:00
Ryan
c4e53c7ceb Have connection.setEncoding use node::ParseEncoding 2009-05-26 18:14:32 +02:00
Ryan
e8f177aa2d Clean up outgoing encoding API. Generally: send(chunk, encoding). 2009-05-26 17:48:59 +02:00
Ryan
c326614c8d More docs. Add rmdir and unlink. 2009-05-26 12:11:31 +02:00
Ryan
a9f29cd18d File I/O documentation. Remove necessity of class="sh_javascript". 2009-05-26 11:39:40 +02:00
Ryan
2fe090b7f6 Add node.fs prefix to some constants. oops. 2009-05-26 03:37:18 +02:00
Ryan
d1b0ce6d37 Large refactor of file code.
All the c++ code is now reduced to simple wrappers. The node.fs.File object
is defined entirely in javascript now. As is the actionQueue methods.

This makes the boundaries much cleaner. There is still some thought that
needs to go into how exactly the API should behave but this simplification
is a first step.
2009-05-26 03:30:51 +02:00
Ryan
3eb4819db1 Add docs. Rename exit() to node.exit(). 2009-05-25 13:38:36 +02:00
Ryan
5c2389fada Remove error codes from file on_completion callbacks. Use file.onError.
The error codes still remain for the two general file system operations:
rename and stat.

Additionally I've removed the actionQueue for file system operations. They
are sent directly into the thread pool.
2009-05-25 13:17:35 +02:00
Ryan
58c13e5192 Namespace File stuff in node.fs 2009-05-21 12:49:41 +02:00
Ryan
6244f77822 Beginnings of file i/o docs. Finish up timers. 2009-05-21 12:33:57 +02:00
Ryan
cb3a11d72a Camel case status_code and http_version. 2009-05-20 16:06:08 +02:00
Ryan
81b39a04cd Add setBodyEncoding to http client responses. 2009-05-20 13:00:20 +02:00
Ryan
a1aecc9378 HTTP Server: Close 1.0 connections properly. 2009-05-20 10:28:10 +02:00
Ryan
0ef5c99973 Add http.ServerRequest.setBodyEncoding. Needs test still. 2009-05-20 10:17:07 +02:00
Ryan
1b54e3d87d Change encoding setter/getter to setEncoding function. 2009-05-20 10:02:02 +02:00
Ryan
82e773630b HTTP Client: add fix to allow TCP connection to reconnect. 2009-05-19 21:53:26 +02:00
Ryan
b445514898 Remove debugging statement. 2009-05-19 20:40:56 +02:00
Ryan
6a172d7119 Fix a bug in HTTP server when receiving half-closes. 2009-05-19 20:24:37 +02:00
Ryan
a5d5056327 Bug fix: need to return readyState symbol from scope. 2009-05-19 16:19:47 +02:00
Ryan
536eceaa2d Debugging http. Add simple test. (Does not pass.) 2009-05-19 14:50:09 +02:00
Ryan
3700568322 Add request method. (How could that be missing still?) 2009-05-19 14:46:07 +02:00
Ryan
87e6578aa9 Simple HTTP client is working a bit. 2009-05-19 13:12:46 +02:00
Ryan
3bc73ba967 Add ParseUri to the node namespace 2009-05-19 00:01:11 +02:00
Ryan
edc38b4134 Use parseUri() for req.uri. Update docs. 2009-05-18 19:33:05 +02:00
Ryan
9c70bf356b HTTP Server: check the ready state of the connection before each send. 2009-05-18 14:02:50 +02:00
Ryan
310eed03e0 Clean up readyState handling. Add test. 2009-05-18 13:53:39 +02:00
Ryan
69ab87ca53 Fix crash in oi_socket; add ready state reader to Connection objects. 2009-05-18 13:38:15 +02:00
Ryan
478e45a32f Change request handler to take two parameters: req, res.
This is more semantic, albeit unnecessary, usage. I think users will
be able to remember the API more easily.
2009-05-18 12:44:01 +02:00
Ryan
9a63d8ec28 Remove v8 prefix from function template callbacks. 2009-05-16 12:54:44 +02:00
Ryan
175223d5d7 Remove HTTP parser callbacks for fragment, query_string, path.
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.
2009-05-16 12:53:24 +02:00
Ryan
91bd3124ad Add sendUtf8 method to socket objects.
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.
2009-05-16 12:44:49 +02:00
Ryan
2cb81113ec Slightly better buffer allocation. (Probably not worth it.) 2009-05-15 22:41:36 +02:00
Ryan
fb96f07ece Commit partial work in http.js. Comment out V8::Dispose(); in node.cc 2009-05-15 18:11:49 +02:00
Ryan
baed9d514d Inform V8 of external allocations.
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.
2009-05-15 16:28:10 +02:00
Ryan
81691c7dc5 Fixes to get HTTP working with new TCP API. 2009-05-15 01:47:17 +02:00
Ryan
589d8af5d4 Wrap NewInstance with TryCatch. (Was still missing the error.) 2009-05-15 01:36:51 +02:00
Ryan
febbf75302 Wrap calls in TryCatch; Check return values after UNWRAP.
This is to avoid a segfault when you don't use the API correctly.
2009-05-15 01:12:46 +02:00
Ryan
73fb24f48d Relatively large update to TCP API. No more "protocol".
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.
2009-05-14 23:47:21 +02:00
Ryan
31ba3cde17 Rename TCP classes to sit in node hierarchy. 2009-05-14 20:34:14 +02:00
Ryan
de6036669d Add p() like in Ruby. 2009-05-14 18:37:53 +02:00
Ryan
427e3f5dcb Introduce NODE_SET_PROTOTYPE_METHOD which properly sets the signature. 2009-05-14 13:16:45 +02:00
Ryan
8d00691f78 Was not properly passing the host parameter to Acceptor::Listen. 2009-05-13 23:44:05 +02:00
Ryan
740139408d Fix memory leak in timer. 2009-05-13 23:35:36 +02:00
Ryan
3212b31ea1 Rename main.js to node.js. 2009-05-13 21:43:24 +02:00
Ryan
f6c955b7f4 Move Timer class into node namespace. 2009-05-13 21:42:18 +02:00
Ryan
4d39a3586c Path, URI, Fragment, etc were not getting passed to RequestHandler. 2009-05-12 11:39:42 +02:00
Ryan
15c1e0b007 Random clean-ups to the web server. 2009-05-12 03:46:04 +02:00
Ryan
7869ed6681 Add keep-alive handling. 2009-05-11 23:38:41 +02:00
Ryan
918c71856a Add status code reasons to server API. 2009-05-11 19:08:29 +02:00
Ryan
421b955888 change the http server response api slightly 2009-05-11 18:54:52 +02:00
Ryan
55d840ea96 Add profile window around socket on_read. 2009-05-11 17:16:14 +02:00
Ryan
43531093a3 don't die on EPIPE 2009-05-07 16:32:36 +02:00
Ryan
ba17940551 Add accessor File#encoding 2009-05-07 16:15:07 +02:00
Ryan
103a8800c7 Binary HTTP bodies for both requests and responses. 2009-05-07 12:15:01 +02:00
Ryan
62a1465332 get chunked responses working 2009-05-06 19:08:38 +02:00
Ryan
9f2938b713 node.http.Server was not getting req.path, etc. 2009-05-06 15:03:13 +02:00
Ryan
a80591aff6 Create node.http.Server and node.http.LowLevelServer
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.
2009-05-06 14:54:28 +02:00
Ryan
0bb12be660 link to google profiler 2009-05-05 21:16:19 +02:00
Ryan
ae7c6314ca Various fixes to make the web server not give off so many errors. 2009-05-05 19:39:08 +02:00
Ryan
cfd61622ae Reference counting. Network bugs.
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.
2009-05-05 18:15:59 +02:00
Ryan
30450388d6 update oi_socket - modify node code to match 2009-05-05 12:52:18 +02:00
Ryan
2e5b85a13b Some fixes to allow HTTPServer to begin listening.
Just tested it and it is accepting connections and parsing! Will add units
soon.
2009-05-04 17:38:17 +02:00
Ryan
9c3770d999 Implement HTTPServer (untested!)
Mostly this is setting up the proper interface to be able to create the HTTP
server.
2009-05-04 17:19:04 +02:00
Ryan
b763ee0ad4 Make onError work for TCPConnection. 2009-05-04 16:36:57 +02:00
Ryan
6149c6c49a Fix HTTPConnection javascript inheritance. 2009-05-04 16:23:30 +02:00
Ryan
38726e7272 various clean ups; HTTPConnection (js side) inherits from TCPConnection 2009-05-04 15:39:36 +02:00
Ryan
09c2ae5c3e Slight change in tcp connection constructor
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.
2009-05-04 12:08:13 +02:00
Ryan
4860f1c92c add onMessageComplete and onBody handlers. 2009-05-03 21:37:10 +02:00
Ryan
be6b3acf0e extract headers, status_code, path, http version from http messages.
still a work in progress.
2009-05-03 21:06:20 +02:00
Ryan
5a071ad72f Begin refactor of http.cc. Remove libebb add http_parser.
And most of http.cc was deleted.
2009-05-03 14:09:16 +02:00
Ryan
bb6057d9ad rename Connection.disconnect -> Connection.close 2009-05-03 01:11:39 +02:00
Ryan
13062832d8 cleanup: rename some of the callbacks 2009-05-03 01:06:21 +02:00
Ryan
1713386580 add Connection::SendEOF. modify test accordingly. 2009-05-03 01:01:42 +02:00
Ryan
15d24d8002 Major refactor of network code
Here I massively change both the external and internal API of the TCP
sockets and servers.

This change introduces the concept of a protocol object like is found in
Twisted Python. I believe this allows for a much cleaner description of how
a socket behaves. What was once a single object "client" or "connection" is
now represented by two objects: a "connection" and a "protocol".

Well - I don't want to ramble too much because neither API is yet public or
documented.  Look the diff of test/test-pingpong.js to see how things have
changed.
2009-05-02 16:34:24 +02:00
Ryan
fd392d0a50 Remove if (pointer == NULL) after allocations with new.
I'm still learning C++.
2009-04-29 14:05:25 +02:00
Ryan
cbd342a12d Publicize Socket and Server for eventual cooperation with HttpServer.
Also changed Init_net() to Socket::Initialize() and Server::Initialize().
Seems more object oriented, but I'm unsure how this will play when I want
load modules dynamically with dlopen(). I'll sit with it for a while and
see how it feels.
2009-04-29 14:00:22 +02:00
Ryan
0f5170339c remove process.{cc,h} process.exit() now exit()
the process object might return in the future but for now it is going away.
2009-04-29 11:09:32 +02:00
Ryan
f213a27657 Refactor setTimeout to be a Timer object.
Timer now uses ObjectWrap. setTimeout, setInterval are now implemented in
javascript.
2009-04-29 11:00:46 +02:00
Ryan
064c8f0252 Use ObjectWrap base class for File, Socket, Server. 2009-04-29 01:07:19 +02:00
Ryan
cf1c58063e Create a node namespace
Part of general reorganization.
2009-04-28 23:09:56 +02:00
Ryan
90fc8d3622 Update liboi. Use EV_MULTIPLICITY=0.
This might need to be changed in the future if ev is needed in thread pools
or extension libraries. However for now it makes sense to just use a single
loop.
2009-04-28 22:37:03 +02:00
Ryan
0ea7577a72 sign error on file position argument 2009-04-23 15:07:54 +02:00
Ryan
8a8e9df72e wasn't sending pos arg for puts() 2009-04-23 14:22:57 +02:00
Ryan
0b1e3240be add position arguments to File#read and File#write 2009-04-23 12:10:57 +02:00
Ryan
63ec0454d2 add echo test. remove debug printfs 2009-04-22 15:52:23 +02:00
Ryan
d996b59d9c fix some errors/memleaks 2009-04-22 15:48:29 +02:00
Ryan
48b4ac4a8d implment server.close 2009-04-22 14:09:17 +02:00
Ryan
c986b99ddc throw error when given a bad arguement to socket.write 2009-04-22 14:01:45 +02:00
Ryan
3095861199 bug fix: recving raw data was incorrect. 2009-04-22 13:59:28 +02:00
Ryan
5f902a61e1 tcp server is accepting connections now.
(experiencing a problem with writing rawEncoding on the sockets. will fix in next commit.)
2009-04-22 13:52:30 +02:00
Ryan
822d7fa27e add framework for tcp server. change eio stacksize to 16kb. 2009-04-22 10:29:45 +02:00
Ryan
140a032894 oops. call onConnect callback not onRead callback after connecting 2009-04-21 23:36:01 +02:00
Ryan
1542fc6a0b add async dns for Socket 2009-04-21 23:13:13 +02:00
Ryan
707f244291 begin clean up of Socket 2009-04-21 19:56:30 +02:00
Ryan
d105d88625 on_load -> onLoad 2009-04-21 16:30:47 +02:00
Ryan
5d57fa5060 clean up timers a bit 2009-04-21 16:24:56 +02:00
Ryan
47fad676b4 Rename JS_ to NODE_ for method macros. add marcos to timers.cc 2009-04-21 15:55:11 +02:00
Ryan
a0f2b8a0c5 remove debug messages from module loading. 2009-04-21 14:38:55 +02:00
Ryan
408526a1c1 debugging/improving the module framework 2009-04-21 13:52:21 +02:00
Ryan
64117d9c94 small cleanups to the require structure 2009-04-20 18:44:30 +02:00
Ryan
93f7f0dca0 reimplement module loading
still missing several important features and its mostly untested but the script
test/test-test.js is working and thats enough for now.
2009-04-20 02:55:08 +02:00
Ryan
c2decd720f add File.cat 2009-04-20 02:54:36 +02:00
Ryan
67af958f81 rename a few files to remove node_ prefix 2009-04-18 15:37:53 +02:00
Ryan
102c6399ac rename NewFile to File::New 2009-04-18 14:34:56 +02:00
Ryan
e7dd20dc6e add File.stat File.exists File.strerror 2009-04-18 10:58:41 +02:00
Ryan
5207226da3 fix a bug with eio polling. 2009-04-18 02:01:23 +02:00
Ryan
dd691decd2 file system methods to be queued. 2009-04-17 18:54:29 +02:00
Ryan
c8e20fbf81 add file.read only. raw encoding right now. 2009-04-16 21:05:41 +02:00
Ryan
12d31dd0b7 file operations are queued. 2009-04-16 20:09:55 +02:00
Ryan
e303d950d9 add stdout stderr global file objects. remove node.blocking.print 2009-04-16 13:58:10 +02:00
Ryan
c0b90ca763 only store fd in javascript (not in c++) 2009-04-16 13:42:34 +02:00
Ryan
470c6342cc Change symantics of file.open. Now takes a callback argument. 2009-04-16 13:20:35 +02:00
Ryan
7e1350f6e4 add file.write() 2009-04-16 11:37:44 +02:00
Ryan
e8ce6ef790 add file open/close 2009-04-15 21:23:10 +02:00
Ryan
63a9cd3897 everything is changed. i've waited much too long to commit.
this is awful. i'm sorry for being so messy.
2009-04-15 10:08:28 +02:00
Ryan
0e9e927fcb enable support for the thread pool 2009-04-04 16:53:43 +02:00
Ryan
1a126ed11c use the WAF build system 2009-04-04 14:50:15 +02:00