Browse Source

Add ParseUri to the node namespace

v0.7.4-release
Ryan 16 years ago
parent
commit
3bc73ba967
  1. 8
      src/http.js
  2. 22
      website/node.html

8
src/http.js

@ -44,8 +44,8 @@ node.http.STATUS_CODES = { 100 : 'Continue'
MIT License MIT License
*/ */
function parseUri (str) { node.http.parseUri = function (str) {
var o = parseUri.options, var o = node.http.parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {}, uri = {},
i = 14; i = 14;
@ -61,7 +61,7 @@ function parseUri (str) {
return uri; return uri;
}; };
parseUri.options = { node.http.parseUri.options = {
strictMode: false, strictMode: false,
key: [ "source" key: [ "source"
, "protocol" , "protocol"
@ -296,7 +296,7 @@ node.http.Server = function (RequestHandler, options) {
this.onHeadersComplete = function () { this.onHeadersComplete = function () {
req.http_version = this.http_version; req.http_version = this.http_version;
req.method = this.method; req.method = this.method;
req.uri = parseUri(req.uri); req.uri = parseUri(req.uri); // TODO parse the URI lazily
res.should_keep_alive = this.should_keep_alive; res.should_keep_alive = this.should_keep_alive;

22
website/node.html

@ -181,8 +181,7 @@ simple side-effect free functions. The programmer does not need advanced
knowledge of POSIX to know that I/O is being performed because it looks knowledge of POSIX to know that I/O is being performed because it looks
differently. differently.
<p> Some find event programming cumbersome. <p> Some find event programming cumbersome. I find threaded programming
I find threaded programming
cumbersome&mdash;it's not a good abstraction of what is really happening. cumbersome&mdash;it's not a good abstraction of what is really happening.
Because of this bad abstraction it's confusing and difficult to get right. Because of this bad abstraction it's confusing and difficult to get right.
Threaded programs only look good in the simpliest and most trivial Threaded programs only look good in the simpliest and most trivial
@ -216,10 +215,10 @@ always have a capital first letter.
<p>Timers allow one to schedule execution of a function for a later time. <p>Timers allow one to schedule execution of a function for a later time.
<p>Timers in Node work as they do in the browser: <p>Timers in Node work as they do in the browser:
<code class="sh_javascript">setTimeout</code>, <code class="sh_javascript">setTimeout()</code>,
<code class="sh_javascript">setInterval</code>, <code class="sh_javascript">setInterval()</code>,
<code class="sh_javascript">clearTimeout</code>, <code class="sh_javascript">clearTimeout()</code>,
<code class="sh_javascript">clearInterval</code>. <code class="sh_javascript">clearInterval()</code>.
See <a See <a
href="https://developer.mozilla.org/en/DOM/window.setTimeout">Mozilla's href="https://developer.mozilla.org/en/DOM/window.setTimeout">Mozilla's
documentation</a> for more information. documentation</a> for more information.
@ -239,7 +238,7 @@ boundaries, and Keep-Alive connections.
<h4 id="http_server"><code class="sh_javascript">node.http.Server</code></h4> <h4 id="http_server"><code class="sh_javascript">node.http.Server</code></h4>
<dl> <dl>
<dt><code class="sh_javascript">var server = new node.http.Server(request_handler, options);</code></dt> <dt><code class="sh_javascript">new node.http.Server(request_handler, options);</code></dt>
<dd> <dd>
<p>Creates a new web server. <p>Creates a new web server.
@ -266,8 +265,7 @@ boundaries, and Keep-Alive connections.
<dt><code class="sh_javascript">server.close()</code> <dt><code class="sh_javascript">server.close()</code>
<dd> <dd>
<p>Stops the server. Requests currently in progress will not be <p>Stops the server from accepting new connections.
interrupted.
</dd> </dd>
</dl> </dl>
@ -284,9 +282,7 @@ class="sh_javascript">request_handler</code> callback.
<code class="sh_javascript">"DELETE"</code>.</dd> <code class="sh_javascript">"DELETE"</code>.</dd>
<dt><code class="sh_javascript">req.uri</code> <dt><code class="sh_javascript">req.uri</code>
<dd> URI object. Has many fields. <dd> URI object.
<dt><code>req.uri.toString()</code>
<dd> The original URI found in the status line.
<dt><code>req.uri.anchor</code> <dt><code>req.uri.anchor</code>
<dt><code>req.uri.query</code> <dt><code>req.uri.query</code>
<dt><code>req.uri.file</code> <dt><code>req.uri.file</code>
@ -301,6 +297,8 @@ class="sh_javascript">request_handler</code> callback.
<dt><code>req.uri.protocol</code> <dt><code>req.uri.protocol</code>
<dt><code>req.uri.source</code> <dt><code>req.uri.source</code>
<dt><code>req.uri.queryKey</code> <dt><code>req.uri.queryKey</code>
<dt><code>req.uri.toString()</code>
<dd> The original URI found in the status line.
<dt><code class="sh_javascript">req.headers</code> <dt><code class="sh_javascript">req.headers</code>
<dd>The request headers expressed as an array of 2-element arrays. Read only. <dd>The request headers expressed as an array of 2-element arrays. Read only.

Loading…
Cancel
Save