From ea728d35ef45882e2d8756d8a44da38fc971ee24 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 5 Mar 2009 14:45:11 +0100 Subject: [PATCH] add some information about http request objects --- node_http.cc | 5 +++-- spec/index.html | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/node_http.cc b/node_http.cc index f530976ac0..ccf615c901 100644 --- a/node_http.cc +++ b/node_http.cc @@ -19,6 +19,7 @@ static Persistent query_string_str; static Persistent fragment_str; static Persistent method_str; static Persistent http_version_str; +static Persistent headers_str; static Persistent on_request_str; static Persistent 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::New(result); @@ -555,6 +555,7 @@ Init_http (Handle target) fragment_str = Persistent::New( String::NewSymbol("fragment") ); method_str = Persistent::New( String::NewSymbol("method") ); http_version_str = Persistent::New( String::NewSymbol("http_version") ); + headers_str = Persistent::New( String::NewSymbol("headers") ); on_request_str = Persistent::New( String::NewSymbol("onRequest") ); on_body_str = Persistent::New( String::NewSymbol("onBody") ); diff --git a/spec/index.html b/spec/index.html index 50772e4177..b8819993d9 100644 --- a/spec/index.html +++ b/spec/index.html @@ -47,6 +47,9 @@
  • 1.2 Execution context
  • 2 HTTP Server +
  • 3 TCP Client
  • 4 Timers @@ -96,6 +99,28 @@ interface HTTPServer { void close(); // yet not implemented }; +

    2.1 Request object

    +
    interface HTTPRequest  {
    +  readonly attribute String path;
    +  readonly attribute String uri;
    +  readonly attribute String query_string;
    +  readonly attribute String fragment;
    +  readonly attribute String method;
    +  readonly attribute String http_version;
    +
    +  readonly attribute Object headers;
    +
    +    attribute Function onBody;
    +
    +  void respond(in String data);
    +};
    + +

    A request object is what is passed to HTTPServer.onRequest. + it represents a single HTTP request. Clients might preform HTTP + pipelining (Keep-Alive) and send multiple requests per TCP + connection—this does not affect this interface. + +

    3 TCP Client

    [Constructor(in String host, in String port)]
     interface TCPClient  {