GET /status?name=ryan HTTP/1.1\r\n -Accept: */*\r\n +Accept: text/plain\r\n \r\n
From 1ae69a68a474f886d6fe39ebe176ff251f718c53 Mon Sep 17 00:00:00 2001
From: Ryan Dahl Many objects in Node emit events: a TCP server emits an event each time
there is a connection, a child process emits an event when it exits. All
objects which emit events are are instances of node.EventEmitter. Events are represented by a snakecased string. Here are some examples:
-"connection", "receive", "message_begin". Events are represented by a camel-cased string. Here are some examples:
+"connection", "receive", "messageBegin". Functions can be then be attached to objects, to be executed when an event
is emitted. These functions are called listeners. Some asynchronous file operations return an EventEmitter called a
@@ -588,8 +588,8 @@ cellspacing="0" cellpadding="4">
"output" data Each time the child process sends data to its stdout, this event is
-emitted. data is a string. Each time the child process
+ sends data to its stdout, this event is
+ emitted. data is a string. + If the child
+ process closes its stdout stream (a common
+ thing to do on exit), this event will be emitted
+ with data === null. "error" data Identical to the "output" event except for stderr instead of stdout. Identical to the "output" event except for
+ stderr instead of stdout. "exit" code This event is emitted after the child process ends. code is the final exit
-code of the process. One can be assured that after this event is emitted
-that the "output" and "error" callbacks will no longer be made. This event is emitted after the child process
+ ends. code is the final exit code of the
+ process. One can be assured that after this
+ event is emitted that the "output" and
+ "error" callbacks will no longer be made. In order to support the full spectrum of possible HTTP applications, Node’s
HTTP API is very low-level. It deals with connection handling and message
parsing only. It parses a message into headers and body but it does not
-parse the actual headers or the body. That means, for example, that Node
-does not, and will never, provide API to access or manipulate Cookies or
-multi-part bodies. This is left to the user.
-
@@ -597,22 +597,27 @@ cellspacing="0" cellpadding="4">
Event
-Parameters
+ Event
+ Parameters
Notes
-
+
-If the child process closes its stdout stream (a common thing to do on
-exit), this event will be emitted with data === null.
-
+
@@ -999,9 +1004,7 @@ user is able to stream data.
-
+
Event | -Parameters | +Parameters | Notes |
---|---|---|---|
"request" |
request, response |
-request is an instance of http.ServerRequest |
+request is an instance of http.ServerRequest
+ |
"connection" |
connection |
When a new TCP connection is established. -connection is an object of type http.Connection. Usually users will not -want to access this event. The connection can also be accessed at -request.connection. |
+ connection is an object of type
+ http.Connection. Usually users
+ will not want to access this event.
+ The connection can also be
+ accessed at request.connection.
|
"close" |
errorno |
Emitted when the server closes. errorno - is an integer which indicates what, if any, - error caused the server to close. If no - error occured errorno will be 0. |
+ is an integer which indicates what, if any,
+ error caused the server to close. If no
+ error occured errorno will be 0.
"body"
chunk
Emitted when a piece of the message body is received. Example: A chunk of -the body is given as the single argument. The transfer-encoding has been -decoded. The body chunk is a String. The body encoding is set -with request.setBodyEncoding().
Emitted when a piece of the + message body is received. Example: A chunk + of the body is given as the single + argument. The transfer-encoding has been + decoded. The body chunk is a String. The + body encoding is set with + request.setBodyEncoding().
"complete"
Emitted exactly once for each message. No arguments. -After emitted no other events will be emitted on the request.
(none)
Emitted exactly once for each message. + No arguments. After emitted no other + events will be emitted on the request.
GET /status?name=ryan HTTP/1.1\r\n -Accept: */*\r\n +Accept: text/plain\r\n \r\n
Then request.uri will be
In particular, note that request.uri.protocol is undefined. This is because there was no URI protocol given in the actual HTTP Request.
request.uri.anchor, request.uri.query, request.uri.file, request.uri.directory, request.uri.path, request.uri.relative, request.uri.port, request.uri.host, request.uri.password, request.uri.user, request.uri.authority, request.uri.protocol, request.uri.params, request.uri.toString(), request.uri.source
Here is what’s available: request.uri.anchor, request.uri.query, +request.uri.file, request.uri.directory, request.uri.path, +request.uri.relative, request.uri.port, request.uri.host, +request.uri.password, request.uri.user, request.uri.authority, +request.uri.protocol, request.uri.params, request.uri.toString(), +request.uri.source