To use the HTTP server and client one must require("/http\.js") or include("/http\.js")\.
.sp
The HTTP interfaces in Node are designed to support many features of the protocol which have been traditionally difficult to use\. In particular, large, possibly chunk\-encoded, messages\. The interface is careful to never buffer entire requests or responses\(emthe user is able to stream data\.
The HTTP interfaces in Node are designed to support many features of the protocol which have been traditionally difficult to use\. In particular, large, possibly chunk\-encoded, messages\. The interface is careful to never buffer entire requests or responses\(emthe user is able to stream data\.
.sp
.sp
HTTP message headers are represented by an object like this
HTTP message headers are represented by an object like this
@ -826,11 +829,11 @@ HTTP message headers are represented by an object like this
.sp
.sp
.RS4
.RS4
.nf
.nf
{ "Content\-Length": "123"
{ "Content\-Length": "123"
, "Content\-Type": "text/plain"
, "Content\-Type": "text/plain"
, "Connection": "keep\-alive"
, "Connection": "keep\-alive"
, "Accept": "*/*"
, "Accept": "*/*"
}
}
.fi
.fi
.RE
.RE
In order to support the full spectrum of possible HTTP applications, Node\(cqs 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\.\fIThis is left to the user\.\fR
In order to support the full spectrum of possible HTTP applications, Node\(cqs 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\.\fIThis is left to the user\.\fR
@ -840,7 +843,7 @@ In order to support the full spectrum of possible HTTP applications, Node\(cqs H
.nran-no-space-flag1
.nran-no-space-flag1
.nran-break-flag1
.nran-break-flag1
.br
.br
node.http.Server
http.Server
.RS
.RS
.TS
.TS
allbox tab(:);
allbox tab(:);
@ -863,7 +866,7 @@ T}:T{
request, response
request, response
.sp
.sp
T}:T{
T}:T{
request is an instance of node\.http\.ServerRequest response is an instance of node\.http\.ServerResponse
request is an instance of http\.ServerRequest response is an instance of http\.ServerResponse
.sp
.sp
T}
T}
T{
T{
@ -873,7 +876,7 @@ T}:T{
connection
connection
.sp
.sp
T}:T{
T}:T{
When a new TCP connection is established\. connection is an object of type node\.http\.Connection\. Usually users will not want to access this event\. The connection can also be accessed at request\.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\.
.sp
.sp
T}
T}
T{
T{
@ -888,7 +891,7 @@ Emitted when the server closes\. errorno is an integer which indicates what, if
@ -922,7 +925,7 @@ Stops the server from accepting new connections\.
.nran-no-space-flag1
.nran-no-space-flag1
.nran-break-flag1
.nran-break-flag1
.br
.br
node.http.ServerRequest
http.ServerRequest
.RS
.RS
This object is created internally by a HTTP server\(emnot by the user\(emand passed as the first argument to a "request" listener\.
This object is created internally by a HTTP server\(emnot by the user\(emand passed as the first argument to a "request" listener\.
.sp
.sp
@ -1047,7 +1050,7 @@ Resumes a paused request\.
request\.connection
request\.connection
.RS4
.RS4
The
The
node\.http\.Connection
http\.Connection
object\.
object\.
.RE
.RE
.RE
.RE
@ -1056,7 +1059,7 @@ object\.
.nran-no-space-flag1
.nran-no-space-flag1
.nran-break-flag1
.nran-break-flag1
.br
.br
node.http.ServerResponse
http.ServerResponse
.RS
.RS
This object is created internally by a HTTP server\(emnot by the user\. It is passed as the second parameter to the "request" event\.
This object is created internally by a HTTP server\(emnot by the user\. It is passed as the second parameter to the "request" event\.
.PP
.PP
@ -1116,7 +1119,7 @@ response\.finish(), MUST be called on each response\.
.nran-no-space-flag1
.nran-no-space-flag1
.nran-break-flag1
.nran-break-flag1
.br
.br
node.http.Client
http.Client
.RS
.RS
An HTTP client is constructed with a server address as its argument, the returned handle is then used to issue one or more requests\. Depending on the server connected to, the client might pipeline the requests or reestablish the connection after each connection\.\fICurrently the implementation does not pipeline requests\.\fR
An HTTP client is constructed with a server address as its argument, the returned handle is then used to issue one or more requests\. Depending on the server connected to, the client might pipeline the requests or reestablish the connection after each connection\.\fICurrently the implementation does not pipeline requests\.\fR
.sp
.sp
@ -1125,7 +1128,7 @@ Example of connecting to google\.com
.sp
.sp
.RS4
.RS4
.nf
.nf
var google = node\.http\.createClient(80, "google\.com");
var google = http\.createClient(80, "google\.com");
Issues a request; if necessary establishes connection\. Returns a
Issues a request; if necessary establishes connection\. Returns a
node\.http\.ClientRequest
http\.ClientRequest
instance\.
instance\.
.sp
.sp
request_headers
request_headers
@ -1179,9 +1182,9 @@ request\.sendBody()\.)
.nran-no-space-flag1
.nran-no-space-flag1
.nran-break-flag1
.nran-break-flag1
.br
.br
node.http.ClientRequest
http.ClientRequest
.RS
.RS
This object is created internally and returned from the request methods of a node\.http\.Client\. It represents an \fIin\-progress\fR request whose header has already been sent\.
This object is created internally and returned from the request methods of a http\.Client\. It represents an \fIin\-progress\fR request whose header has already been sent\.
.sp
.sp
.TS
.TS
allbox tab(:);
allbox tab(:);
@ -1202,7 +1205,7 @@ T}:T{
response
response
.sp
.sp
T}:T{
T}:T{
Emitted when a response is received to this request\. Typically the user will set a listener to this via the request\.finish() method\. This event is emitted only once\. The response argument will be an instance of node\.http\.ClientResponse\.
Emitted when a response is received to this request\. Typically the user will set a listener to this via the request\.finish() method\. This event is emitted only once\. The response argument will be an instance of http\.ClientResponse\.
.sp
.sp
T}
T}
.TE
.TE
@ -1237,7 +1240,7 @@ responseListener
is a callback which will be executed when the response headers have been received\. The
is a callback which will be executed when the response headers have been received\. The
responseListener
responseListener
callback is executed with one argument which is an instance of
callback is executed with one argument which is an instance of