From: Ryan Date: Tue, 19 May 2009 12:46:07 +0000 (+0200) Subject: Add request method. (How could that be missing still?) X-Git-Tag: v0.0.1~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=370056832227f7329fedb48f78990873a6fa9967;p=platform%2Fupstream%2Fnodejs.git Add request method. (How could that be missing still?) --- diff --git a/src/http.cc b/src/http.cc index 203c05f..be0f478 100644 --- a/src/http.cc +++ b/src/http.cc @@ -21,6 +21,7 @@ #define ON_BODY_SYMBOL String::NewSymbol("onBody") #define ON_MESSAGE_COMPLETE_SYMBOL String::NewSymbol("onMessageComplete") +#define METHOD_SYMBOL String::NewSymbol("method") #define STATUS_CODE_SYMBOL String::NewSymbol("status_code") #define HTTP_VERSION_SYMBOL String::NewSymbol("http_version") #define SHOULD_KEEP_ALIVE_SYMBOL String::NewSymbol("should_keep_alive") @@ -135,6 +136,28 @@ DEFINE_PARSER_CALLBACK(on_uri, ON_URI_SYMBOL) DEFINE_PARSER_CALLBACK(on_header_field, ON_HEADER_FIELD_SYMBOL) DEFINE_PARSER_CALLBACK(on_header_value, ON_HEADER_VALUE_SYMBOL) +static Local +GetMethod (int method) +{ + switch (method) { + case HTTP_COPY: return String::NewSymbol("COPY"); + case HTTP_DELETE: return String::NewSymbol("DELETE"); + case HTTP_GET: return String::NewSymbol("GET"); + case HTTP_HEAD: return String::NewSymbol("HEAD"); + case HTTP_LOCK: return String::NewSymbol("LOCK"); + case HTTP_MKCOL: return String::NewSymbol("MKCOL"); + case HTTP_MOVE: return String::NewSymbol("MOVE"); + case HTTP_OPTIONS: return String::NewSymbol("OPTIONS"); + case HTTP_POST: return String::NewSymbol("POST"); + case HTTP_PROPFIND: return String::NewSymbol("PROPFIND"); + case HTTP_PROPPATCH: return String::NewSymbol("PROPPATCH"); + case HTTP_PUT: return String::NewSymbol("PUT"); + case HTTP_TRACE: return String::NewSymbol("TRACE"); + case HTTP_UNLOCK: return String::NewSymbol("UNLOCK"); + } + return Local(); +} + int HTTPConnection::on_headers_complete (http_parser *parser) { @@ -145,6 +168,9 @@ HTTPConnection::on_headers_complete (http_parser *parser) connection->handle_->GetHiddenValue(MESSAGE_HANDLER_SYMBOL); Local message_handler = message_handler_v->ToObject(); + // METHOD + message_handler->Set(METHOD_SYMBOL, GetMethod(connection->parser_.method)); + // STATUS message_handler->Set(STATUS_CODE_SYMBOL, Integer::New(connection->parser_.status_code));