diff --git a/website/node.html b/website/node.html index c7464ac1145..b2b50c0595d 100644 --- a/website/node.html +++ b/website/node.html @@ -17,6 +17,8 @@ body { top: 2em; left: 0; width: 10em; + font-size: 14pt; + line-height: 120%; } #toc ol { list-style: none; @@ -28,7 +30,7 @@ body { margin: 0; padding: 0; } -#toc a { color: #777; } +#toc a { color: #aaa; } h1, h2, h3, h4 { color: #B0C4DE; @@ -84,12 +86,22 @@ a:hover { text-decoration: underline; }
  • Timers
  • File System I/O
  • TCP +
      +
    1. Server +
    2. Connection +
  • HTTP
    1. Server -
    2. ServerRequest -
    3. ServerResponse +
        +
      1. Request +
      2. Response +
    4. Client +
        +
      1. Request +
      2. Response +
  • Modules @@ -119,7 +131,7 @@ puts("Server running at http://127.0.0.1:8000/"); Node is an evented sandbox where users cannot execute blocking I/O. This is already natural for Javascript programmers, as the DOM is almost entirely -asynchronous and allows for effieceny. The goal is to provide an easy way to create +asynchronous. The goal is to provide an easy way to create efficient network applications. @@ -146,7 +158,7 @@ make make install -

    Application Programming Interface

    +

    API

    Conventions: Callbacks are object members which are prefixed with on. All methods and members are camel cased. Constructors @@ -279,7 +291,6 @@ req.onBody = function (chunk) {

    Set the encoding for the request body. Either "utf8" or "raw". Defaults to raw. - TODO

    node.http.ServerResponse

    @@ -366,6 +377,84 @@ normally are without bodies but HTTP does not forbid it, so neither do we.) +

    node.http.ClientRequest

    + +

    This object created internally and returned from the request methods of a +node.http.Client. It represents an in-progress request +whose header has already been sent. + +

    +
    req.sendBody(chunk, encoding)
    +
    Sends a sucessive peice of the body. By calling this method many times, +the user can stream a request body to a server—in that case it is +suggested to use the ["Transfer-Encoding", +"chunked"] header line when creating the request. + +

    The chunk argument should be an array of integers or a string. + +

    The encoding argument is optional and only applies when + chunk is a string. The encoding argument should be either + "utf8" or "ascii". By default the body uses ASCII + encoding, as it is faster. + +

    TODO + +

    req.finish(response_handler)
    + +
    Finishes sending the request. If any parts of the body are + unsent, it will flush them to the socket. If the request is chunked, this + will send the terminating "0\r\n\r\n". + +

    The parameter response_handler is a user-supplied callback which will + be executed exactly once when the server response headers have been received. + The response_handler callback is executed with one argument: a + ClientResponse object. +

    + +

    node.http.ClientResponse

    + +

    This object is created internally and passed to the +response_handler callback (is given to the client in +req.finish function). The response object appears exactly as the +header is completely received but before any part of the response body has been +read. + +

    +
    res.status_code
    +
    The 3-digit HTTP response status code. (E.G. 404.)
    + +
    res.http_version
    +
    The HTTP version of the connected-to server. Probably either + "1.1" or + "1.0". +
    + +
    res.headers
    +
    The response headers. An Array of 2-element arrays.
    + +
    res.onBody
    +
    Callback. Should be set by the user to be informed of when a piece + of the message body is received. + A chunk of the body is given as the single argument. The transfer-encoding + has been removed. + +

    The body chunk is either a String in the case of UTF-8 + encoding or an array of numbers in the case of raw encoding. The body + encoding is set with res.setBodyEncoding(). + +

    res.onBodyComplete
    +
    Callback. Made exactly once for each message. No arguments. After + onBodyComplete is executed + onBody will no longer be called. +
    + +
    res.setBodyEncoding(encoding)
    +
    + Set the encoding for the response body. Either "utf8" or + "raw". Defaults to raw. +
    +
    +

    Modules

    Node has a simple module loading system. In Node, files and modules are diff --git a/website/sh_vim-dark.css b/website/sh_vim-dark.css index 7f3291da90c..6b7a1c95f53 100644 --- a/website/sh_vim-dark.css +++ b/website/sh_vim-dark.css @@ -12,7 +12,8 @@ font-style: italic; } -.sh_sourceCode .sh_string, .sh_sourceCode .sh_regexp, .sh_sourceCode .sh_number +.sh_sourceCode .sh_string, .sh_sourceCode .sh_regexp, .sh_sourceCode .sh_number, +.sh_sourceCode .sh_specialchar { color: #B0C4DE; }