Move http library to /http.js
authorRyan Dahl <ry@tinyclouds.org>
Mon, 28 Sep 2009 10:36:36 +0000 (12:36 +0200)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 28 Sep 2009 10:36:36 +0000 (12:36 +0200)
23 files changed:
benchmark/http_simple.js
benchmark/process_loop.js
benchmark/run.js
benchmark/static_http_server.js
doc/api.html
doc/api.txt
doc/api.xml
doc/index.html
doc/node.1
lib/http.js [moved from src/http.js with 92% similarity]
src/node.cc
src/node.js
src/util.js
test/mjsunit/disabled/test-cat.js [moved from test/mjsunit/test-node-cat.js with 92% similarity]
test/mjsunit/test-http-cat.js
test/mjsunit/test-http-client-race.js
test/mjsunit/test-http-client-upload.js
test/mjsunit/test-http-malformed-request.js
test/mjsunit/test-http-proxy.js
test/mjsunit/test-http-server.js
test/mjsunit/test-http.js
test/mjsunit/test-multipart.js
wscript

index d1801e7..f334c01 100644 (file)
@@ -1,9 +1,15 @@
+libDir = node.path.join(node.path.dirname(__filename), "../lib");
+node.libraryPaths.unshift(libDir);
+
+include("/utils.js");
+http = require("/http.js");
+
 fixed = ""
 for (var i = 0; i < 20*1024; i++) {
   fixed += "C";
 }
 stored = {};
-node.http.createServer(function (req, res) {
+http.createServer(function (req, res) {
   var commands = req.uri.path.split("/");
   var command = commands[1];
   var body = "";
index 67b9edd..ec971f0 100644 (file)
@@ -1,3 +1,6 @@
+libDir = node.path.join(node.path.dirname(__filename), "../lib");
+node.libraryPaths.unshift(libDir);
+include("/utils.js");
 function next (i) {
   if (i <= 0) return;
 
index a8a4d17..d9c2668 100644 (file)
@@ -1,3 +1,6 @@
+libDir = node.path.join(node.path.dirname(__filename), "../lib");
+node.libraryPaths.unshift(libDir);
+include("/utils.js");
 var benchmarks = [ "static_http_server.js" 
                  , "timers.js"
                  , "process_loop.js"
index ef465a8..3ce0499 100644 (file)
@@ -1,3 +1,6 @@
+libDir = node.path.join(node.path.dirname(__filename), "../lib");
+node.libraryPaths.unshift(libDir);
+http = require("/http.js");
 var concurrency = 30;
 var port = 8000;
 var n = 700;
@@ -11,7 +14,7 @@ for (var i = 0; i < bytes; i++) {
   body += "C";
 }
 
-var server = node.http.createServer(function (req, res) {
+var server = http.createServer(function (req, res) {
   res.sendHeader(200, {
     "Content-Type": "text/plain",
     "Content-Length": body.length
@@ -35,7 +38,7 @@ function responseListener (res) {
 }
 
 for (var i = 0; i < concurrency; i++) {
-  var client = node.http.createClient(port);
+  var client = http.createClient(port);
   client.id = i;
   client.get("/").finish(responseListener);
   requests++;
index fe7d4c1..d564939 100644 (file)
@@ -37,7 +37,8 @@ World":</p></div>
 <div class="listingblock">\r
 <div class="content">\r
 <pre><tt>include("/utils.js");\r
-node.http.createServer(function (request, response) {\r
+include("/http.js");\r
+createServer(function (request, response) {\r
   response.sendHeader(200, {"Content-Type": "text/plain"});\r
   response.sendBody("Hello World\n");\r
   response.finish();\r
@@ -940,6 +941,8 @@ on error: no parameters.
 </dd>\r
 </dl></div>\r
 <h3 id="_http">HTTP</h3><div style="clear:left"></div>\r
+<div class="paragraph"><p>To use the HTTP server and client one must <tt>require("/http.js")</tt> or\r
+<tt>include("/http.js")</tt>.</p></div>\r
 <div class="paragraph"><p>The HTTP interfaces in Node are designed to support many features\r
 of the protocol which have been traditionally difficult to use.\r
 In particular, large, possibly chunk-encoded, messages. The interface is\r
@@ -948,11 +951,11 @@ user is able to stream data.</p></div>
 <div class="paragraph"><p>HTTP message headers are represented by an object like this</p></div>\r
 <div class="listingblock">\r
 <div class="content">\r
-<pre><tt>  { "Content-Length": "123"\r
-  , "Content-Type": "text/plain"\r
-  , "Connection": "keep-alive"\r
-  , "Accept": "*/*"\r
-  }</tt></pre>\r
+<pre><tt>{ "Content-Length": "123"\r
+, "Content-Type": "text/plain"\r
+, "Connection": "keep-alive"\r
+, "Accept": "*/*"\r
+}</tt></pre>\r
 </div></div>\r
 <div class="paragraph"><p>In order to support the full spectrum of possible HTTP applications, Node&#8217;s\r
 HTTP API is very low-level. It deals with connection handling and message\r
@@ -960,7 +963,7 @@ 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\r
 does not, and will never, provide API to access or manipulate Cookies or\r
 multi-part bodies.  <em>This is left to the user.</em></p></div>\r
-<h4 id="_tt_node_http_server_tt"><tt>node.http.Server</tt></h4>\r
+<h4 id="_tt_http_server_tt"><tt>http.Server</tt></h4>\r
 <div class="tableblock">\r
 <table rules="all"\r
 width="100%"\r
@@ -980,14 +983,14 @@ cellspacing="0" cellpadding="4">
 <tr>\r
 <td align="left" valign="top"><p class="table"><tt>"request"</tt></p></td>\r
 <td align="left" valign="top"><p class="table"><tt>request, response</tt></p></td>\r
-<td align="left" valign="top"><p class="table"><tt>request</tt> is an instance of <tt>node.http.ServerRequest</tt><br />\r
-<tt>response</tt> is an instance of <tt>node.http.ServerResponse</tt></p></td>\r
+<td align="left" valign="top"><p class="table"><tt>request</tt> is an instance of <tt>http.ServerRequest</tt><br />\r
+<tt>response</tt> is an instance of <tt>http.ServerResponse</tt></p></td>\r
 </tr>\r
 <tr>\r
 <td align="left" valign="top"><p class="table"><tt>"connection"</tt></p></td>\r
 <td align="left" valign="top"><p class="table"><tt>connection</tt></p></td>\r
 <td align="left" valign="top"><p class="table">When a new TCP connection is established.\r
-<tt>connection</tt> is an object of type <tt>node.http.Connection</tt>. Usually users will not\r
+<tt>connection</tt> is an object of type <tt>http.Connection</tt>. Usually users will not\r
 want to access this event. The <tt>connection</tt> can also be accessed at\r
 <tt>request.connection</tt>.</p></td>\r
 </tr>\r
@@ -1004,7 +1007,7 @@ want to access this event. The <tt>connection</tt> can also be accessed at
 </div>\r
 <div class="dlist"><dl>\r
 <dt class="hdlist1">\r
-<tt>node.http.createServer(request_listener, options);</tt> \r
+<tt>http.createServer(request_listener, options);</tt> \r
 </dt>\r
 <dd>\r
 <p>\r
@@ -1035,7 +1038,7 @@ Stops the server from accepting new connections.
 </p>\r
 </dd>\r
 </dl></div>\r
-<h4 id="_tt_node_http_serverrequest_tt"><tt>node.http.ServerRequest</tt></h4>\r
+<h4 id="_tt_http_serverrequest_tt"><tt>http.ServerRequest</tt></h4>\r
 <div class="paragraph"><p>This object is created internally by a HTTP server&#8212;not by\r
 the user&#8212;and passed as the first argument to a <tt>"request"</tt> listener.</p></div>\r
 <div class="tableblock">\r
@@ -1156,11 +1159,11 @@ Resumes a paused request.
 </dt>\r
 <dd>\r
 <p>\r
-The <tt>node.http.Connection</tt> object.\r
+The <tt>http.Connection</tt> object.\r
 </p>\r
 </dd>\r
 </dl></div>\r
-<h4 id="_tt_node_http_serverresponse_tt"><tt>node.http.ServerResponse</tt></h4>\r
+<h4 id="_tt_http_serverresponse_tt"><tt>http.ServerResponse</tt></h4>\r
 <div class="paragraph"><p>This object is created internally by a HTTP server&#8212;not by the user. It is\r
 passed as the second parameter to the <tt>"request"</tt> event.</p></div>\r
 <div class="dlist"><dl>\r
@@ -1216,7 +1219,7 @@ response.
 </p>\r
 </dd>\r
 </dl></div>\r
-<h4 id="_tt_node_http_client_tt"><tt>node.http.Client</tt></h4>\r
+<h4 id="_tt_http_client_tt"><tt>http.Client</tt></h4>\r
 <div class="paragraph"><p>An HTTP client is constructed with a server address as its\r
 argument, the returned handle is then used to issue one or more\r
 requests.  Depending on the server connected to, the client might\r
@@ -1225,7 +1228,7 @@ connection. <em>Currently the implementation does not pipeline requests.</em></p
 <div class="paragraph"><p>Example of connecting to <tt>google.com</tt></p></div>\r
 <div class="listingblock">\r
 <div class="content">\r
-<pre><tt>var google = node.http.createClient(80, "google.com");\r
+<pre><tt>var google = http.createClient(80, "google.com");\r
 var request = google.get("/");\r
 request.finish(function (response) {\r
   puts("STATUS: " + response.statusCode);\r
@@ -1238,7 +1241,7 @@ request.finish(function (response) {
 </div></div>\r
 <div class="dlist"><dl>\r
 <dt class="hdlist1">\r
-<tt>node.http.createClient(port, host)</tt> \r
+<tt>http.createClient(port, host)</tt> \r
 </dt>\r
 <dd>\r
 <p>\r
@@ -1252,7 +1255,7 @@ connection is not established until a request is issued.
 </dt>\r
 <dd>\r
 <p>\r
-Issues a request; if necessary establishes connection. Returns a <tt>node.http.ClientRequest</tt> instance.\r
+Issues a request; if necessary establishes connection. Returns a <tt>http.ClientRequest</tt> instance.\r
 </p>\r
 <div class="paragraph"><p><tt>request_headers</tt> is optional.\r
 Additional request headers might be added internally\r
@@ -1275,9 +1278,9 @@ for the user to stream a body to the server with
 </div>\r
 </dd>\r
 </dl></div>\r
-<h4 id="_tt_node_http_clientrequest_tt"><tt>node.http.ClientRequest</tt></h4>\r
+<h4 id="_tt_http_clientrequest_tt"><tt>http.ClientRequest</tt></h4>\r
 <div class="paragraph"><p>This object is created internally and returned from the request methods of a\r
-<tt>node.http.Client</tt>. It represents an <em>in-progress</em> request whose header has\r
+<tt>http.Client</tt>. It represents an <em>in-progress</em> request whose header has\r
 already been sent.</p></div>\r
 <div class="tableblock">\r
 <table rules="all"\r
@@ -1301,7 +1304,7 @@ cellspacing="0" cellpadding="4">
 <td align="left" valign="top"><p class="table">Emitted when a response is received to this request. Typically the user will\r
 set a listener to this via the <tt>request.finish()</tt> method.<br />\r
 This event is emitted only once.<br />\r
-The <tt>response</tt> argument will be an instance of <tt>node.http.ClientResponse</tt>.</p></td>\r
+The <tt>response</tt> argument will be an instance of <tt>http.ClientResponse</tt>.</p></td>\r
 </tr>\r
 </tbody>\r
 </table>\r
@@ -1338,7 +1341,7 @@ chunked, this will send the terminating <tt>"0\r\n\r\n"</tt>.
 <div class="paragraph"><p>The parameter <tt>responseListener</tt> is a callback which\r
 will be executed when the response headers have been received.\r
 The <tt>responseListener</tt> callback is executed with one\r
-argument which is an instance of <tt>node.http.ClientResponse</tt>.</p></div>\r
+argument which is an instance of <tt>http.ClientResponse</tt>.</p></div>\r
 <div class="paragraph"><p>In the <tt>responseListener</tt> callback, one can add more listeners to the\r
 response, in particular listening for the <tt>"body"</tt> event. Note that\r
 the <tt>responseListener</tt> is called before any part of the body is receieved,\r
@@ -1365,7 +1368,7 @@ request.finish(function (response) {
 </div></div>\r
 </dd>\r
 </dl></div>\r
-<h4 id="_tt_node_http_clientresponse_tt"><tt>node.http.ClientResponse</tt></h4>\r
+<h4 id="_tt_http_clientresponse_tt"><tt>http.ClientResponse</tt></h4>\r
 <div class="paragraph"><p>This object is created internally and passed to the <tt>"response"</tt> event.</p></div>\r
 <div class="tableblock">\r
 <table rules="all"\r
@@ -1456,7 +1459,7 @@ After emitted no other events will be emitted on the response.</p></td>
 </dt>\r
 <dd>\r
 <p>\r
-  A reference to the <tt>node.http.Client</tt> that this response belongs to.\r
+  A reference to the <tt>http.Client</tt> that this response belongs to.\r
 </p>\r
 </dd>\r
 </dl></div>\r
@@ -1943,7 +1946,7 @@ init (Handle&lt;Object&gt; target)
 <div id="footer">\r
 <div id="footer-text">\r
 Version 0.1.12<br />\r
-Last updated 2009-09-28 12:04:19 CEST\r
+Last updated 2009-09-28 12:23:06 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 3f858c4..cd7f178 100644 (file)
@@ -17,7 +17,8 @@ World":
 
 ----------------------------------------
 include("/utils.js");
-node.http.createServer(function (request, response) {
+include("/http.js");
+createServer(function (request, response) {
   response.sendHeader(200, {"Content-Type": "text/plain"});
   response.sendBody("Hello World\n");
   response.finish();
@@ -568,6 +569,9 @@ Objects returned from +node.fs.stat()+ are of this type.
 
 === HTTP
 
+To use the HTTP server and client one must +require("/http.js")+ or
++include("/http.js")+.
+
 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
@@ -577,11 +581,11 @@ user is able to stream data.
 HTTP message headers are represented by an object like this
 
 ----------------------------------------
-  { "Content-Length": "123"
-  , "Content-Type": "text/plain"
-  , "Connection": "keep-alive"
-  , "Accept": "*/*"
-  }
+{ "Content-Length": "123"
+, "Content-Type": "text/plain"
+, "Connection": "keep-alive"
+, "Accept": "*/*"
+}
 ----------------------------------------
 
 In order to support the full spectrum of possible HTTP applications, Node's
@@ -592,20 +596,20 @@ does not, and will never, provide API to access or manipulate Cookies or
 multi-part bodies.  _This is left to the user._
 
 
-==== +node.http.Server+
+==== +http.Server+
 
 [cols="1,2,10",options="header"]
 |=========================================================
 |Event           | Parameters   | Notes
 
 |+"request"+     | +request, response+ |
-+request+ is an instance of +node.http.ServerRequest+
++request+ is an instance of +http.ServerRequest+
 +
-+response+ is an instance of +node.http.ServerResponse+
++response+ is an instance of +http.ServerResponse+
 
 |+"connection"+  | +connection+ |
 When a new TCP connection is established.
-+connection+ is an object of type +node.http.Connection+. Usually users will not
++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+.
 
@@ -616,7 +620,7 @@ want to access this event. The +connection+ can also be accessed at
 
 |=========================================================
 
-+node.http.createServer(request_listener, options);+ ::
++http.createServer(request_listener, options);+ ::
 Returns a new web server object.
 +
 The +options+ argument is optional. The
@@ -636,7 +640,7 @@ Stops the server from accepting new connections.
 
 
 
-==== +node.http.ServerRequest+
+==== +http.ServerRequest+
 
 This object is created internally by a HTTP server--not by
 the user--and passed as the first argument to a +"request"+ listener.
@@ -712,10 +716,10 @@ Resumes a paused request.
 
 
 +request.connection+ ::
-The +node.http.Connection+ object.
+The +http.Connection+ object.
 
 
-==== +node.http.ServerResponse+
+==== +http.ServerResponse+
 
 This object is created internally by a HTTP server--not by the user. It is
 passed as the second parameter to the +"request"+ event.
@@ -766,7 +770,7 @@ response.
 
 
 
-==== +node.http.Client+
+==== +http.Client+
 
 An HTTP client is constructed with a server address as its
 argument, the returned handle is then used to issue one or more
@@ -777,7 +781,7 @@ connection. _Currently the implementation does not pipeline requests._
 Example of connecting to +google.com+
 
 ----------------------------------------
-var google = node.http.createClient(80, "google.com");
+var google = http.createClient(80, "google.com");
 var request = google.get("/");
 request.finish(function (response) {
   puts("STATUS: " + response.statusCode);
@@ -789,7 +793,7 @@ request.finish(function (response) {
 });
 ----------------------------------------
 
-+node.http.createClient(port, host)+ ::
++http.createClient(port, host)+ ::
 
 Constructs a new HTTP client. +port+ and
 +host+ refer to the server to be connected to. A
@@ -797,7 +801,7 @@ connection is not established until a request is issued.
 
 +client.get(path, request_headers)+, +client.head(path, request_headers)+, +client.post(path, request_headers)+, +client.del(path, request_headers)+, +client.put(path, request_headers)+ ::
 
-Issues a request; if necessary establishes connection. Returns a +node.http.ClientRequest+ instance.
+Issues a request; if necessary establishes connection. Returns a +http.ClientRequest+ instance.
 +
 +request_headers+ is optional.
 Additional request headers might be added internally
@@ -815,10 +819,10 @@ for the user to stream a body to the server with
 +request.sendBody()+.)
 
 
-==== +node.http.ClientRequest+
+==== +http.ClientRequest+
 
 This object is created internally and returned from the request methods of a
-+node.http.Client+. It represents an _in-progress_ request whose header has
++http.Client+. It represents an _in-progress_ request whose header has
 already been sent.
 
 [cols="1,2,10",options="header"]
@@ -830,7 +834,7 @@ 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+.
+The +response+ argument will be an instance of +http.ClientResponse+.
 |=========================================================
 
 
@@ -861,7 +865,7 @@ chunked, this will send the terminating +"0\r\n\r\n"+.
 The parameter +responseListener+ is a callback which
 will be executed when the response headers have been received.
 The +responseListener+ callback is executed with one
-argument which is an instance of +node.http.ClientResponse+.
+argument which is an instance of +http.ClientResponse+.
 +
 In the +responseListener+ callback, one can add more listeners to the
 response, in particular listening for the +"body"+ event. Note that
@@ -891,7 +895,7 @@ request.finish(function (response) {
 
 
 
-==== +node.http.ClientResponse+
+==== +http.ClientResponse+
 
 This object is created internally and passed to the +"response"+ event.
 
@@ -932,7 +936,7 @@ After emitted no other events will be emitted on the response.
   Resumes a paused response.
 
 +response.client+ ::
-  A reference to the +node.http.Client+ that this response belongs to.
+  A reference to the +http.Client+ that this response belongs to.
 
 
 
index 470c079..c6ccf14 100644 (file)
@@ -13,7 +13,8 @@
 <simpara>An example of a web server written with Node which responds with "Hello\r
 World":</simpara>\r
 <screen>include("/utils.js");\r
-node.http.createServer(function (request, response) {\r
+include("/http.js");\r
+createServer(function (request, response) {\r
   response.sendHeader(200, {"Content-Type": "text/plain"});\r
   response.sendBody("Hello World\n");\r
   response.finish();\r
@@ -988,25 +989,27 @@ on error: no parameters.
 </refsect2>\r
 <refsect2 id="_http">\r
 <title>HTTP</title>\r
+<simpara>To use the HTTP server and client one must <literal>require("/http.js")</literal> or\r
+<literal>include("/http.js")</literal>.</simpara>\r
 <simpara>The HTTP interfaces in Node are designed to support many features\r
 of the protocol which have been traditionally difficult to use.\r
 In particular, large, possibly chunk-encoded, messages. The interface is\r
 careful to never buffer entire requests or responses&#8212;the\r
 user is able to stream data.</simpara>\r
 <simpara>HTTP message headers are represented by an object like this</simpara>\r
-<screen>  { "Content-Length": "123"\r
-  , "Content-Type": "text/plain"\r
-  , "Connection": "keep-alive"\r
-  , "Accept": "*/*"\r
-  }</screen>\r
+<screen>{ "Content-Length": "123"\r
+, "Content-Type": "text/plain"\r
+, "Connection": "keep-alive"\r
+, "Accept": "*/*"\r
+}</screen>\r
 <simpara>In order to support the full spectrum of possible HTTP applications, Node&#8217;s\r
 HTTP API is very low-level. It deals with connection handling and message\r
 parsing only. It parses a message into headers and body but it does not\r
 parse the actual headers or the body.  That means, for example, that Node\r
 does not, and will never, provide API to access or manipulate Cookies or\r
 multi-part bodies.  <emphasis>This is left to the user.</emphasis></simpara>\r
-<refsect3 id="_literal_node_http_server_literal">\r
-<title><literal>node.http.Server</literal></title>\r
+<refsect3 id="_literal_http_server_literal">\r
+<title><literal>http.Server</literal></title>\r
 <informaltable\r
 frame="all"\r
 rowsep="1" colsep="1"\r
@@ -1026,14 +1029,14 @@ rowsep="1" colsep="1"
 <row>\r
 <entry align="left" valign="top"><simpara><literal>"request"</literal></simpara></entry>\r
 <entry align="left" valign="top"><simpara><literal>request, response</literal></simpara></entry>\r
-<entry align="left" valign="top"><simpara><literal>request</literal> is an instance of <literal>node.http.ServerRequest</literal><?asciidoc-br?>\r
-<literal>response</literal> is an instance of <literal>node.http.ServerResponse</literal></simpara></entry>\r
+<entry align="left" valign="top"><simpara><literal>request</literal> is an instance of <literal>http.ServerRequest</literal><?asciidoc-br?>\r
+<literal>response</literal> is an instance of <literal>http.ServerResponse</literal></simpara></entry>\r
 </row>\r
 <row>\r
 <entry align="left" valign="top"><simpara><literal>"connection"</literal></simpara></entry>\r
 <entry align="left" valign="top"><simpara><literal>connection</literal></simpara></entry>\r
 <entry align="left" valign="top"><simpara>When a new TCP connection is established.\r
-<literal>connection</literal> is an object of type <literal>node.http.Connection</literal>. Usually users will not\r
+<literal>connection</literal> is an object of type <literal>http.Connection</literal>. Usually users will not\r
 want to access this event. The <literal>connection</literal> can also be accessed at\r
 <literal>request.connection</literal>.</simpara></entry>\r
 </row>\r
@@ -1051,7 +1054,7 @@ want to access this event. The <literal>connection</literal> can also be accesse
 <variablelist>\r
 <varlistentry>\r
 <term>\r
-<literal>node.http.createServer(request_listener, options);</literal> \r
+<literal>http.createServer(request_listener, options);</literal> \r
 </term>\r
 <listitem>\r
 <simpara>\r
@@ -1088,8 +1091,8 @@ Stops the server from accepting new connections.
 </varlistentry>\r
 </variablelist>\r
 </refsect3>\r
-<refsect3 id="_literal_node_http_serverrequest_literal">\r
-<title><literal>node.http.ServerRequest</literal></title>\r
+<refsect3 id="_literal_http_serverrequest_literal">\r
+<title><literal>http.ServerRequest</literal></title>\r
 <simpara>This object is created internally by a HTTP server&#8212;not by\r
 the user&#8212;and passed as the first argument to a <literal>"request"</literal> listener.</simpara>\r
 <informaltable\r
@@ -1219,14 +1222,14 @@ Resumes a paused request.
 </term>\r
 <listitem>\r
 <simpara>\r
-The <literal>node.http.Connection</literal> object.\r
+The <literal>http.Connection</literal> object.\r
 </simpara>\r
 </listitem>\r
 </varlistentry>\r
 </variablelist>\r
 </refsect3>\r
-<refsect3 id="_literal_node_http_serverresponse_literal">\r
-<title><literal>node.http.ServerResponse</literal></title>\r
+<refsect3 id="_literal_http_serverresponse_literal">\r
+<title><literal>http.ServerResponse</literal></title>\r
 <simpara>This object is created internally by a HTTP server&#8212;not by the user. It is\r
 passed as the second parameter to the <literal>"request"</literal> event.</simpara>\r
 <variablelist>\r
@@ -1286,15 +1289,15 @@ response.
 </varlistentry>\r
 </variablelist>\r
 </refsect3>\r
-<refsect3 id="_literal_node_http_client_literal">\r
-<title><literal>node.http.Client</literal></title>\r
+<refsect3 id="_literal_http_client_literal">\r
+<title><literal>http.Client</literal></title>\r
 <simpara>An HTTP client is constructed with a server address as its\r
 argument, the returned handle is then used to issue one or more\r
 requests.  Depending on the server connected to, the client might\r
 pipeline the requests or reestablish the connection after each\r
 connection. <emphasis>Currently the implementation does not pipeline requests.</emphasis></simpara>\r
 <simpara>Example of connecting to <literal>google.com</literal></simpara>\r
-<screen>var google = node.http.createClient(80, "google.com");\r
+<screen>var google = http.createClient(80, "google.com");\r
 var request = google.get("/");\r
 request.finish(function (response) {\r
   puts("STATUS: " + response.statusCode);\r
@@ -1307,7 +1310,7 @@ request.finish(function (response) {
 <variablelist>\r
 <varlistentry>\r
 <term>\r
-<literal>node.http.createClient(port, host)</literal> \r
+<literal>http.createClient(port, host)</literal> \r
 </term>\r
 <listitem>\r
 <simpara>\r
@@ -1323,7 +1326,7 @@ connection is not established until a request is issued.
 </term>\r
 <listitem>\r
 <simpara>\r
-Issues a request; if necessary establishes connection. Returns a <literal>node.http.ClientRequest</literal> instance.\r
+Issues a request; if necessary establishes connection. Returns a <literal>http.ClientRequest</literal> instance.\r
 </simpara>\r
 <simpara><literal>request_headers</literal> is optional.\r
 Additional request headers might be added internally\r
@@ -1341,10 +1344,10 @@ for the user to stream a body to the server with
 </varlistentry>\r
 </variablelist>\r
 </refsect3>\r
-<refsect3 id="_literal_node_http_clientrequest_literal">\r
-<title><literal>node.http.ClientRequest</literal></title>\r
+<refsect3 id="_literal_http_clientrequest_literal">\r
+<title><literal>http.ClientRequest</literal></title>\r
 <simpara>This object is created internally and returned from the request methods of a\r
-<literal>node.http.Client</literal>. It represents an <emphasis>in-progress</emphasis> request whose header has\r
+<literal>http.Client</literal>. It represents an <emphasis>in-progress</emphasis> request whose header has\r
 already been sent.</simpara>\r
 <informaltable\r
 frame="all"\r
@@ -1368,7 +1371,7 @@ rowsep="1" colsep="1"
 <entry align="left" valign="top"><simpara>Emitted when a response is received to this request. Typically the user will\r
 set a listener to this via the <literal>request.finish()</literal> method.<?asciidoc-br?>\r
 This event is emitted only once.<?asciidoc-br?>\r
-The <literal>response</literal> argument will be an instance of <literal>node.http.ClientResponse</literal>.</simpara></entry>\r
+The <literal>response</literal> argument will be an instance of <literal>http.ClientResponse</literal>.</simpara></entry>\r
 </row>\r
 </tbody>\r
 </tgroup>\r
@@ -1408,7 +1411,7 @@ chunked, this will send the terminating <literal>"0\r\n\r\n"</literal>.
 <simpara>The parameter <literal>responseListener</literal> is a callback which\r
 will be executed when the response headers have been received.\r
 The <literal>responseListener</literal> callback is executed with one\r
-argument which is an instance of <literal>node.http.ClientResponse</literal>.</simpara>\r
+argument which is an instance of <literal>http.ClientResponse</literal>.</simpara>\r
 <simpara>In the <literal>responseListener</literal> callback, one can add more listeners to the\r
 response, in particular listening for the <literal>"body"</literal> event. Note that\r
 the <literal>responseListener</literal> is called before any part of the body is receieved,\r
@@ -1434,8 +1437,8 @@ request.finish(function (response) {
 </varlistentry>\r
 </variablelist>\r
 </refsect3>\r
-<refsect3 id="_literal_node_http_clientresponse_literal">\r
-<title><literal>node.http.ClientResponse</literal></title>\r
+<refsect3 id="_literal_http_clientresponse_literal">\r
+<title><literal>http.ClientResponse</literal></title>\r
 <simpara>This object is created internally and passed to the <literal>"response"</literal> event.</simpara>\r
 <informaltable\r
 frame="all"\r
@@ -1539,7 +1542,7 @@ After emitted no other events will be emitted on the response.</simpara></entry>
 </term>\r
 <listitem>\r
 <simpara>\r
-  A reference to the <literal>node.http.Client</literal> that this response belongs to.\r
+  A reference to the <literal>http.Client</literal> that this response belongs to.\r
 </simpara>\r
 </listitem>\r
 </varlistentry>\r
index dbce7af..88094f3 100644 (file)
       </p>
 
       <pre>
-utils = require("/utils.js");
-server = node.http.createServer(function (req, res) {
+include("/utils.js");
+include("/http.js");
+createServer(function (req, res) {
   setTimeout(function () {
     res.sendHeader(200, {"Content-Type": "text/plain"});
     res.sendBody("Hello World");
     res.finish();
   }, 2000);
-});
-server.listen(8000);
-utils.puts("Server running at http://127.0.0.1:8000/");</pre>
+}).listen(8000);
+puts("Server running at http://127.0.0.1:8000/");</pre>
 </pre>
 
       <p>
index b369443..75b9811 100644 (file)
@@ -19,7 +19,8 @@ An example of a web server written with Node which responds with "Hello World":
 .RS 4
 .nf
 include("/utils\.js");
-node\.http\.createServer(function (request, response) {
+include("/http\.js");
+createServer(function (request, response) {
   response\.sendHeader(200, {"Content\-Type": "text/plain"});
   response\.sendBody("Hello World\en");
   response\.finish();
@@ -819,6 +820,8 @@ stats\.isFile(), stats\.isDirectory(), stats\.isBlockDevice(), stats\.isCharacte
 .RE
 .RE
 .SS "HTTP"
+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\.
 .sp
 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
 .RS 4
 .nf
-  { "Content\-Length": "123"
-  , "Content\-Type": "text/plain"
-  , "Connection": "keep\-alive"
-  , "Accept": "*/*"
-  }
+{ "Content\-Length": "123"
+, "Content\-Type": "text/plain"
+, "Connection": "keep\-alive"
+, "Accept": "*/*"
+}
 .fi
 .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
@@ -840,7 +843,7 @@ In order to support the full spectrum of possible HTTP applications, Node\(cqs H
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.Server
+http.Server
 .RS
 .TS
 allbox tab(:);
@@ -863,7 +866,7 @@ T}:T{
 request, response
 .sp
 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
 T}
 T{
@@ -873,7 +876,7 @@ T}:T{
 connection
 .sp
 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
 T}
 T{
@@ -888,7 +891,7 @@ Emitted when the server closes\. errorno is an integer which indicates what, if
 T}
 .TE
 .PP
-node\.http\.createServer(request_listener, options);
+http\.createServer(request_listener, options);
 .RS 4
 Returns a new web server object\.
 .sp
@@ -922,7 +925,7 @@ Stops the server from accepting new connections\.
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.ServerRequest
+http.ServerRequest
 .RS
 This object is created internally by a HTTP server\(emnot by the user\(emand passed as the first argument to a "request" listener\.
 .sp
@@ -1047,7 +1050,7 @@ Resumes a paused request\.
 request\.connection
 .RS 4
 The
-node\.http\.Connection
+http\.Connection
 object\.
 .RE
 .RE
@@ -1056,7 +1059,7 @@ object\.
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.ServerResponse
+http.ServerResponse
 .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\.
 .PP
@@ -1116,7 +1119,7 @@ response\.finish(), MUST be called on each response\.
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.Client
+http.Client
 .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
 .sp
@@ -1125,7 +1128,7 @@ Example of connecting to google\.com
 .sp
 .RS 4
 .nf
-var google = node\.http\.createClient(80, "google\.com");
+var google = http\.createClient(80, "google\.com");
 var request = google\.get("/");
 request\.finish(function (response) {
   puts("STATUS: " + response\.statusCode);
@@ -1138,7 +1141,7 @@ request\.finish(function (response) {
 .fi
 .RE
 .PP
-node\.http\.createClient(port, host)
+http\.createClient(port, host)
 .RS 4
 Constructs a new HTTP client\.
 port
@@ -1150,7 +1153,7 @@ refer to the server to be connected to\. A connection is not established until a
 client\.get(path, request_headers), client\.head(path, request_headers), client\.post(path, request_headers), client\.del(path, request_headers), client\.put(path, request_headers)
 .RS 4
 Issues a request; if necessary establishes connection\. Returns a
-node\.http\.ClientRequest
+http\.ClientRequest
 instance\.
 .sp
 request_headers
@@ -1179,9 +1182,9 @@ request\.sendBody()\.)
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.ClientRequest
+http.ClientRequest
 .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
 .TS
 allbox tab(:);
@@ -1202,7 +1205,7 @@ T}:T{
 response
 .sp
 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
 T}
 .TE
@@ -1237,7 +1240,7 @@ responseListener
 is a callback which will be executed when the response headers have been received\. The
 responseListener
 callback is executed with one argument which is an instance of
-node\.http\.ClientResponse\.
+http\.ClientResponse\.
 .sp
 In the
 responseListener
@@ -1277,7 +1280,7 @@ request\.finish(function (response) {
 .nr an-no-space-flag 1
 .nr an-break-flag 1
 .br
-node.http.ClientResponse
+http.ClientResponse
 .RS
 This object is created internally and passed to the "response" event\.
 .sp
@@ -1356,7 +1359,7 @@ Resumes a paused response\.
 response\.client
 .RS 4
 A reference to the
-node\.http\.Client
+http\.Client
 that this response belongs to\.
 .RE
 .RE
similarity index 92%
rename from src/http.js
rename to lib/http.js
index 736fb1b..78a224a 100644 (file)
@@ -1,6 +1,7 @@
-(function () {
-CRLF = "\r\n";
-node.http.STATUS_CODES = {
+var utils = require("/utils.js");
+
+var CRLF = "\r\n";
+var STATUS_CODES = {
   100 : 'Continue',
   101 : 'Switching Protocols',
   200 : 'OK',
@@ -50,8 +51,8 @@ function decode (s) {
   return decodeURIComponent(s.replace(/\+/g, ' '));
 }
 
-node.http.parseUri = function (str) {
-  var o   = node.http.parseUri.options,
+exports.parseUri = function (str) {
+  var o   = exports.parseUri.options,
       m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
       uri = {},
       i   = 14;
@@ -79,7 +80,7 @@ node.http.parseUri = function (str) {
   return uri;
 };
 
-node.http.parseUri.options = {
+exports.parseUri.options = {
   strictMode: false,
   key: [
     "source",
@@ -296,7 +297,7 @@ function ServerResponse () {
 node.inherits(ServerResponse, OutgoingMessage);
 
 ServerResponse.prototype.sendHeader = function (statusCode, headers) {
-  var reason = node.http.STATUS_CODES[statusCode] || "unknown";
+  var reason = STATUS_CODES[statusCode] || "unknown";
   var status_line = "HTTP/1.1 " + statusCode.toString() + " " + reason + CRLF;
   this.sendHeaderLines(status_line, headers);
 };
@@ -371,7 +372,7 @@ function createIncomingMessageStream (connection, incoming_listener) {
     if (info.method) {
       // server only
       incoming.method = info.method;
-      incoming.uri = node.http.parseUri(incoming.uri); // TODO parse the URI lazily?
+      incoming.uri = exports.parseUri(incoming.uri); // TODO parse the URI lazily?
     } else {
       // client only
       incoming.statusCode = info.statusCode;
@@ -419,7 +420,7 @@ function flushMessageQueue (connection, queue) {
 }
 
 
-node.http.createServer = function (requestListener, options) {
+exports.createServer = function (requestListener, options) {
   var server = new node.http.Server();
   //server.setOptions(options);
   server.addListener("request", requestListener);
@@ -459,7 +460,7 @@ function connectionListener (connection) {
 }
 
 
-node.http.createClient = function (port, host) {
+exports.createClient = function (port, host) {
   var client = new node.http.Client();
 
   var requests = [];
@@ -467,11 +468,11 @@ node.http.createClient = function (port, host) {
   client._pushRequest = function (req) {
     req.addListener("flush", function () {
       if (client.readyState == "closed") {
-        //node.debug("HTTP CLIENT request flush. reconnect.  readyState = " + client.readyState);
+        //utils.debug("HTTP CLIENT request flush. reconnect.  readyState = " + client.readyState);
         client.connect(port, host); // reconnect
         return;
       }
-      //node.debug("client flush  readyState = " + client.readyState);
+      //utils.debug("client flush  readyState = " + client.readyState);
       if (req == requests[0]) flushMessageQueue(client, [req]);
     });
     requests.push(req);
@@ -482,7 +483,7 @@ node.http.createClient = function (port, host) {
   });
 
   client.addListener("eof", function () {
-    //node.debug("client got eof closing. readyState = " + client.readyState);
+    //utils.debug("client got eof closing. readyState = " + client.readyState);
     client.close();
   });
 
@@ -492,20 +493,20 @@ node.http.createClient = function (port, host) {
       return;
     }
 
-    //node.debug("HTTP CLIENT onClose. readyState = " + client.readyState);
+    //utils.debug("HTTP CLIENT onClose. readyState = " + client.readyState);
 
     // If there are more requests to handle, reconnect.
     if (requests.length > 0 && client.readyState != "opening") {
-      //node.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
+      //utils.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
       client.connect(port, host); // reconnect
     }
   });
 
   createIncomingMessageStream(client, function (res) {
-   //node.debug("incoming response!");
+   //utils.debug("incoming response!");
 
     res.addListener("complete", function ( ) {
-      //node.debug("request complete disconnecting. readyState = " + client.readyState);
+      //utils.debug("request complete disconnecting. readyState = " + client.readyState);
       client.close();
     });
 
@@ -547,13 +548,13 @@ node.http.Client.prototype.put = function (uri, headers) {
 };
 
 
-node.http.cat = function (url, encoding) {
+exports.cat = function (url, encoding) {
   var promise = new node.Promise();
 
   encoding = encoding || "utf8";
 
-  var uri = node.http.parseUri(url);
-  var client = node.http.createClient(uri.port || 80, uri.host);
+  var uri = exports.parseUri(url);
+  var client = exports.createClient(uri.port || 80, uri.host);
   var req = client.get(uri.path || "/");
 
   client.addListener("error", function () {
@@ -576,5 +577,3 @@ node.http.cat = function (url, encoding) {
 
   return promise;
 };
-
-})(); // anonymous namespace
index 5432447..e1eabe4 100644 (file)
@@ -402,7 +402,6 @@ static Local<Object> Load(int argc, char *argv[]) {
 
   ExecuteNativeJS("util.js", native_util);
   ExecuteNativeJS("events.js", native_events);
-  ExecuteNativeJS("http.js", native_http);
   ExecuteNativeJS("file.js", native_file);
   ExecuteNativeJS("node.js", native_node);
 
index 1f5dfee..f78de6b 100644 (file)
@@ -19,6 +19,14 @@ node.exec = function () {
   throw new Error("node.exec() has moved. Use include('/utils.js') to bring it back.");
 }
 
+node.http.createServer = function () {
+  throw new Error("node.http.createServer() has moved. Use require('/http.js') to access it.");
+}
+
+node.http.createClient = function () {
+  throw new Error("node.http.createClient() has moved. Use require('/http.js') to access it.");
+}
+
 node.tcp.createConnection = function (port, host) {
   var connection = new node.tcp.Connection();
   connection.connect(port, host);
index 930e65b..0a477bb 100644 (file)
@@ -25,8 +25,12 @@ node.assert = function (x, msg) {
 
 node.cat = function(location, encoding) {
   var url_re = new RegExp("^http:\/\/");
-  var f = url_re.exec(location) ? node.http.cat : node.fs.cat;
-  return f(location, encoding);
+  if (url_re.exec(location)) {
+    throw new Error("node.cat for http urls is temporarally disabled.");
+  }
+  //var f = url_re.exec(location) ? node.http.cat : node.fs.cat;
+  //return f(location, encoding);
+  return node.fs.cat(location, encoding);
 };
 
 node.path = new function () {
similarity index 92%
rename from test/mjsunit/test-node-cat.js
rename to test/mjsunit/disabled/test-cat.js
index 384cfe2..c3bc3fb 100644 (file)
@@ -1,10 +1,11 @@
 include("common.js");
+http = require("/http.js");
 PORT = 8888;
 
 puts("hello world");
 
 var body = "exports.A = function() { return 'A';}";
-var server = node.http.createServer(function (req, res) {
+var server = http.createServer(function (req, res) {
     puts("req?");
   res.sendHeader(200, {
     "Content-Length": body.length,
index c0c0b62..4e12265 100644 (file)
@@ -1,8 +1,9 @@
 include("common.js");
+http = require("/http.js");
 PORT = 8888;
 
 var body = "exports.A = function() { return 'A';}";
-var server = node.http.createServer(function (req, res) {
+var server = http.createServer(function (req, res) {
   puts("got request");
   res.sendHeader(200, [
     ["Content-Length", body.length],
@@ -16,19 +17,20 @@ server.listen(PORT);
 var got_good_server_content = false;
 var bad_server_got_error = false;
 
-node.http.cat("http://localhost:"+PORT+"/", "utf8").addCallback(function (content) {
+http.cat("http://localhost:"+PORT+"/", "utf8").addCallback(function (content) {
   puts("got response");
   got_good_server_content = true;
   assertEquals(body, content);
   server.close();
 });
 
-node.http.cat("http://localhost:12312/", "utf8").addErrback(function () {
+http.cat("http://localhost:12312/", "utf8").addErrback(function () {
   puts("got error (this should happen)");
   bad_server_got_error = true;
 });
 
 process.addListener("exit", function () {
+  puts("exit");
   assertTrue(got_good_server_content);
   assertTrue(bad_server_got_error);
 });
index 5936158..8087d7e 100644 (file)
@@ -1,10 +1,11 @@
 include("common.js");
+http = require("/http.js");
 PORT = 8888;
 
 var body1_s = "1111111111111111";
 var body2_s = "22222";
 
-var server = node.http.createServer(function (req, res) {
+var server = http.createServer(function (req, res) {
   var body = req.uri.path === "/1" ? body1_s : body2_s;
   res.sendHeader(200, { "Content-Type": "text/plain"
                       , "Content-Length": body.length
@@ -14,7 +15,7 @@ var server = node.http.createServer(function (req, res) {
 });
 server.listen(PORT);
 
-var client = node.http.createClient(PORT);
+var client = http.createClient(PORT);
 
 var body1 = "";
 var body2 = "";
index bfd716c..6e95f11 100644 (file)
@@ -1,11 +1,12 @@
 include("common.js");
+http = require("/http.js");
 var PORT = 18032;
 
 var sent_body = "";
 var server_req_complete = false;
 var client_res_complete = false;
 
-var server = node.http.createServer(function(req, res) {
+var server = http.createServer(function(req, res) {
   assertEquals("POST", req.method);
   req.setBodyEncoding("utf8");
 
@@ -24,7 +25,7 @@ var server = node.http.createServer(function(req, res) {
 });
 server.listen(PORT);
 
-var client = node.http.createClient(PORT);
+var client = http.createClient(PORT);
 var req = client.post('/');
 
 req.sendBody('1\n');
index 68a6ea1..158ee3b 100644 (file)
@@ -1,4 +1,5 @@
 include("common.js");
+http = require("/http.js");
 
 // Make sure no exceptions are thrown when receiving malformed HTTP
 // requests.
@@ -7,7 +8,7 @@ port = 9999;
 nrequests_completed = 0;
 nrequests_expected = 1;
 
-var s = node.http.createServer(function (req, res) {
+var s = http.createServer(function (req, res) {
   puts("req: " + JSON.stringify(req.uri));
 
   res.sendHeader(200, {"Content-Type": "text/plain"});
index 04743d9..f902661 100644 (file)
@@ -1,9 +1,10 @@
 include("common.js");
+http = require("/http.js");
 
 var PROXY_PORT = 8869;
 var BACKEND_PORT = 8870;
 
-var backend = node.http.createServer(function (req, res) {
+var backend = http.createServer(function (req, res) {
   // debug("backend");
   res.sendHeader(200, {"content-type": "text/plain"});
   res.sendBody("hello world\n");
@@ -12,8 +13,8 @@ var backend = node.http.createServer(function (req, res) {
 // debug("listen backend")
 backend.listen(BACKEND_PORT);
 
-var proxy_client = node.http.createClient(BACKEND_PORT);
-var proxy = node.http.createServer(function (req, res) {
+var proxy_client = http.createClient(BACKEND_PORT);
+var proxy = http.createServer(function (req, res) {
   debug("proxy req headers: " + JSON.stringify(req.headers));
   var proxy_req = proxy_client.get(req.uri.path);
   proxy_req.finish(function(proxy_res) {
@@ -32,7 +33,7 @@ proxy.listen(PROXY_PORT);
 
 var body = "";
 
-var client = node.http.createClient(PROXY_PORT);
+var client = http.createClient(PROXY_PORT);
 var req = client.get("/test");
 // debug("client req")
 req.finish(function (res) {
index 251f083..82bb217 100644 (file)
@@ -1,4 +1,5 @@
 include("common.js");
+http = require("/http.js");
 
 var port = 8222;
 
@@ -7,7 +8,7 @@ var requests_sent = 0;
 var server_response = "";
 var client_got_eof = false;
 
-node.http.createServer(function (req, res) {
+http.createServer(function (req, res) {
   res.id = request_number;
   req.id = request_number++;
 
index a2e339e..c8d5b27 100644 (file)
@@ -1,4 +1,5 @@
 include("common.js");
+http = require("/http.js");
 PORT = 8888;
 
 var responses_sent = 0;
@@ -6,7 +7,7 @@ var responses_recvd = 0;
 var body0 = "";
 var body1 = "";
 
-node.http.createServer(function (req, res) {
+http.createServer(function (req, res) {
   if (responses_sent == 0) {
     assertEquals("GET", req.method);
     assertEquals("/hello", req.uri.path);
@@ -35,7 +36,7 @@ node.http.createServer(function (req, res) {
   //assertEquals("127.0.0.1", res.connection.remoteAddress);
 }).listen(PORT);
 
-var client = node.http.createClient(PORT);
+var client = http.createClient(PORT);
 var req = client.get("/hello", {"Accept": "*/*", "Foo": "bar"});
 req.finish(function (res) {
   assertEquals(200, res.statusCode);
index 33a74f7..c8ba90c 100644 (file)
@@ -1,4 +1,5 @@
 include("common.js");
+http = require("/http.js");
 
 var multipart = require('/multipart.js');
 var port = 8222;
@@ -6,7 +7,7 @@ var parts_reveived = 0;
 var parts_complete = 0;
 var parts = {};
 
-var server = node.http.createServer(function(req, res) {
+var server = http.createServer(function(req, res) {
   var stream = new multipart.Stream(req);
 
   stream.addListener('part', function(part) {
diff --git a/wscript b/wscript
index 4129088..4740b22 100644 (file)
--- a/wscript
+++ b/wscript
@@ -241,7 +241,6 @@ def build(bld):
     source = """
       src/util.js
       src/events.js
-      src/http.js
       src/file.js
       src/node.js
     """,