Browse Source

add some information about http request objects

v0.7.4-release
Ryan 16 years ago
parent
commit
ea728d35ef
  1. 5
      node_http.cc
  2. 25
      spec/index.html

5
node_http.cc

@ -19,6 +19,7 @@ static Persistent<String> query_string_str;
static Persistent<String> fragment_str;
static Persistent<String> method_str;
static Persistent<String> http_version_str;
static Persistent<String> headers_str;
static Persistent<String> on_request_str;
static Persistent<String> on_body_str;
@ -416,8 +417,7 @@ HttpRequest::CreateJSObject ()
field_iterator++;
value_iterator++;
}
result->Set(String::NewSymbol("headers"), headers);
result->Set(headers_str, headers);
js_object = Persistent<Object>::New(result);
@ -555,6 +555,7 @@ Init_http (Handle<Object> target)
fragment_str = Persistent<String>::New( String::NewSymbol("fragment") );
method_str = Persistent<String>::New( String::NewSymbol("method") );
http_version_str = Persistent<String>::New( String::NewSymbol("http_version") );
headers_str = Persistent<String>::New( String::NewSymbol("headers") );
on_request_str = Persistent<String>::New( String::NewSymbol("onRequest") );
on_body_str = Persistent<String>::New( String::NewSymbol("onBody") );

25
spec/index.html

@ -47,6 +47,9 @@
<li><a href="index.html#execution-context"><span class=secno>1.2 </span>Execution context</a>
</ul>
<li><a href="index.html#http_server"><span class=secno>2 </span>HTTP Server</a>
<ul class=toc>
<li><a href="index.html#http_request"><span class=secno>2.1 </span>Request object</a>
</ul>
<li><a href="index.html#tcp_client"><span class=secno>3 </span>TCP Client</a>
<li><a href="index.html#timers"><span class=secno>4 </span>Timers</a>
</ul>
@ -96,6 +99,28 @@ interface <dfn id=httpserver>HTTPServer</dfn> {
void close(); // yet not implemented
};</pre>
<h3 id=http_request><span class=secno>2.1 </span>Request object</h3>
<pre class=idl>interface <dfn id=httprequest>HTTPRequest</dfn> {
readonly attribute String <a href="index.html#path">path</a>;
readonly attribute String <a href="index.html#uri">uri</a>;
readonly attribute String <a href="index.html#query_string">query_string</a>;
readonly attribute String <a href="index.html#fragment">fragment</a>;
readonly attribute String <a href="index.html#method">method</a>;
readonly attribute String <a href="index.html#http_version">http_version</a>;
readonly attribute Object <a href="index.html#headers">headers</a>;
attribute Function <a href="index.html#onBody">onBody</a>;
void respond(in String data);
};</pre>
<p> A request object is what is passed to <code>HTTPServer.onRequest</code>.
it represents a single HTTP request. Clients might preform HTTP
pipelining (Keep-Alive) and send multiple requests per TCP
connection&mdash;this does not affect this interface.
<h2 id=tcp_client><span class=secno>3 </span>TCP Client</h2>
<pre class=idl>[Constructor(in String host, in String port)]
interface <dfn id=tcpclient>TCPClient</dfn> {

Loading…
Cancel
Save