|
@ -385,47 +385,36 @@ Handle<Value> JsHttpRequestProcessor::GetPath |
|
|
, const AccessorInfo& info |
|
|
, const AccessorInfo& info |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
// Extract the C++ request object from the JavaScript wrapper.
|
|
|
|
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
|
|
|
|
|
|
// Fetch the path.
|
|
|
|
|
|
const string& path = request->Path(); |
|
|
const string& path = request->Path(); |
|
|
|
|
|
|
|
|
// Wrap the result in a JavaScript string and return it.
|
|
|
|
|
|
return String::New(path.c_str(), path.length()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handle<Value> JsHttpRequestProcessor::GetReferrer |
|
|
|
|
|
( Local<String> name |
|
|
|
|
|
, const AccessorInfo& info |
|
|
|
|
|
) |
|
|
|
|
|
{ |
|
|
|
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
|
|
|
const string& path = request->Referrer(); |
|
|
|
|
|
return String::New(path.c_str(), path.length()); |
|
|
return String::New(path.c_str(), path.length()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Handle<Value> JsHttpRequestProcessor::GetMethod |
|
|
Handle<Value> JsHttpRequestProcessor::GetHost |
|
|
|
|
|
( Local<String> name |
|
|
( Local<String> name |
|
|
, const AccessorInfo& info |
|
|
, const AccessorInfo& info |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
const string& path = request->Host(); |
|
|
// TODO allocate these strings only once. reference global
|
|
|
return String::New(path.c_str(), path.length()); |
|
|
switch(request->parser_info.method) { |
|
|
} |
|
|
case ebb_request::EBB_COPY: return String::New("COPY"); |
|
|
|
|
|
case ebb_request::EBB_DELETE: return String::New("DELETE"); |
|
|
|
|
|
case ebb_request::EBB_GET: return String::New("GET"); |
|
|
Handle<Value> JsHttpRequestProcessor::GetUserAgent |
|
|
case ebb_request::EBB_HEAD: return String::New("HEAD"); |
|
|
( Local<String> name |
|
|
case ebb_request::EBB_LOCK: return String::New("LOCK"); |
|
|
, const AccessorInfo& info |
|
|
case ebb_request::EBB_MKCOL: return String::New("MKCOL"); |
|
|
) |
|
|
case ebb_request::EBB_MOVE: return String::New("MOVE"); |
|
|
{ |
|
|
case ebb_request::EBB_OPTIONS: return String::New("OPTIONS"); |
|
|
HttpRequest* request = UnwrapRequest(info.Holder()); |
|
|
case ebb_request::EBB_POST: return String::New("POST"); |
|
|
const string& path = request->UserAgent(); |
|
|
case ebb_request::EBB_PROPFIND: return String::New("PROPFIND"); |
|
|
return String::New(path.c_str(), path.length()); |
|
|
case ebb_request::EBB_PROPPATCH: return String::New("PROPPATCH"); |
|
|
|
|
|
case ebb_request::EBB_PUT: return String::New("PUT"); |
|
|
|
|
|
case ebb_request::EBB_TRACE: return String::New("TRACE"); |
|
|
|
|
|
case ebb_request::EBB_UNLOCK: return String::New("UNLOCK"); |
|
|
|
|
|
default: |
|
|
|
|
|
return Null(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -440,9 +429,7 @@ Handle<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate |
|
|
|
|
|
|
|
|
// Add accessors for each of the fields of the request.
|
|
|
// Add accessors for each of the fields of the request.
|
|
|
result->SetAccessor(String::NewSymbol("path"), GetPath); |
|
|
result->SetAccessor(String::NewSymbol("path"), GetPath); |
|
|
result->SetAccessor(String::NewSymbol("referrer"), GetReferrer); |
|
|
result->SetAccessor(String::NewSymbol("method"), GetMethod); |
|
|
result->SetAccessor(String::NewSymbol("host"), GetHost); |
|
|
|
|
|
result->SetAccessor(String::NewSymbol("userAgent"), GetUserAgent); |
|
|
|
|
|
|
|
|
|
|
|
// Again, return the result through the current handle scope.
|
|
|
// Again, return the result through the current handle scope.
|
|
|
return handle_scope.Close(result); |
|
|
return handle_scope.Close(result); |
|
|