module http

Chargement: var http = require('http')

Création d'un serveur:

var httpPort = 8000; // normal server like apache run on port 80
var httpServer = http.createServer(function(request, response) {


// response.writeHead(httpCode, headers); 
//   httpCode = 200, 404
//   headers = { 'Content-Type' : 'text/html', ... }

// response.write('text to write');

// response.end();

return;
});
httpServer.listen(httpPort);
http.ServerRequest
       .url: '/',  // can be '/' or '/index' or '/favicon.ico' or '/test/test?param=bla&action=test...
       .method : 'GET',
       .headers
               .host:'localhost:8000'
               ['user-agent']
               .accept
               ['accept-language']
               ['accept-encoding':'gzip, deflate']
               .connection:'keep-alive'
       .socket
              ._handle
                      .writeQueueSize
                      .socket
                      .onread = function() {}
              ._pendingWriteReqs,
              ._flags,
              ._connectQueueSize,
              .destroyed,
              .errorEmitted,
              .bytesRead,
              .bytesWritten,
              .allowHalfOpen,
              .writable,
              .readable,
              .server
                     .connections,
                     .allowHalfOpen
                     ._handle
                     ._events
                     .httpAllowHalfOpen
              .ondrain = function() {}
              ._idleTimeout,
              ._idleNext { _idleNext, _idlePref, ontimeout = function() {} }
              ._idlePrev { _idleNext, _idlePref, ontimeout = function() {} }
              ._idleStart,
              ._events { timeout = {}, error = function() {}, close = {} }
              .ondata = function() {}
              .onend = function() {}
              .httpMessage
                          .output: []
                          .outputEncodings: []
                          .writable
                          ._last
                          .chunkedEncoding
                          .shouldKeepAlive
                          .useChuckedEncodingByDefault
                          ._hasBody
                          ._trailer
                          .finished
                          .socket
                          .connection
                          ._events : {}

       .complete: false
       .httpVersion : '1.1'
       .httpVersionMajor: 1,
       .httpVersionMinor: 1,
       .trailers,
       .readable,
       .statusCode: null,
       .upgrade: false
       .connection,
        ...
       .client
         ...

http.Server
           .listen(port)

http
    .createServer: function() {}
    .createClient: function() {}
    .get: function() {},
    .request: function() {},
    .STATUS_CODES: {'100':'Continue' ... to '510':'Not Extended'},
    .parsers: { name: 'parsers', constructor: , max: 1000, list: [] },
    .IncomingMessage,
    .OutgouingMessage,
    .ServerResponse,
    .Agent,
    .globalAgent,
    .ClientRequest,
    .Server: function() {}
    ._connectionListener: function() {}
    .Client:

http.ServerResponse
        .writeHead()
        .write()
        .end()
        .output: [],
        .outputEncodings: [],
        .writable: true,
        ._last : false,
        .chunckedEncoding: true,
        .shouldKeepAlive: true,
        .useChunkedEncodingByDefault: true,
        ._hasBody: true,
        ._trailer: '',
        .finished: true,
        .socket: null,
        .connection: null,
        ._events { finish: function() {}),
        .statusCode: 200,
        ._header: 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n...'
        ._headerSent: true,

Hyperliens...