Support for new LL Responder API.
This adds mStatus, mReason and mContent to ResponderBase and fills those in instead of passing it to member functions. The added danger here is that now code can accidently try to access these variables while they didn't already get a correct value. Affected members of ResponderBase (that now have less arguments): decode_llsd_body, decode_raw_body, completedHeaders, completed -> httpCompleted, result -> httpSuccess, errorWithContent and error -> httpFailure. New API: ResponderBase::setResult ResponderBase::getStatus() ResponderBase::getReason() ResponderBase::getContent() ResponderBase::getResponseHeaders() (returns AIHTTPReceivedHeaders though, not LLSD) ResponderBase::dumpResponse() ResponderWithCompleted::completeResult ResponderWithResult::failureResult (previously pubErrorWithContent) ResponderWithResult::successResult (previously pubResult) Not implemented: getHTTPMethod() - use getName() instead which returns the class name of the responder. completedHeaders() is still called as usual, although you can ignore it (not implement in a derived responder) and call getResponseHeaders() instead, provided you implement needsHeaders() and have it return true. However, classes derived from ResponderHeadersOnly do not have completedHeaders(), so they still must implement completedHeaders(), and then call getResponseHeaders() or just access mReceivedHeaders directly, as usual.
This commit is contained in:
@@ -738,28 +738,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ void error(U32 statusNum, const std::string& reason)
|
||||
/*virtual*/ void httpFailure(void)
|
||||
{
|
||||
llwarns
|
||||
<< "Transport error requesting object cost "
|
||||
<< "HTTP status: " << statusNum << ", reason: "
|
||||
<< reason << "." << llendl;
|
||||
<< "HTTP status: " << mStatus << ", reason: "
|
||||
<< mReason << "." << llendl;
|
||||
|
||||
// TODO*: Error message to user
|
||||
// For now just clear the request from the pending list
|
||||
clear_object_list_pending_requests();
|
||||
}
|
||||
|
||||
/*virtual*/ void result(const LLSD& content)
|
||||
/*virtual*/ void httpSuccess(void)
|
||||
{
|
||||
if ( !content.isMap() || content.has("error") )
|
||||
if ( !mContent.isMap() || mContent.has("error") )
|
||||
{
|
||||
// Improper response or the request had an error,
|
||||
// show an error to the user?
|
||||
llwarns
|
||||
<< "Application level error when fetching object "
|
||||
<< "cost. Message: " << content["error"]["message"].asString()
|
||||
<< ", identifier: " << content["error"]["identifier"].asString()
|
||||
<< "cost. Message: " << mContent["error"]["message"].asString()
|
||||
<< ", identifier: " << mContent["error"]["identifier"].asString()
|
||||
<< llendl;
|
||||
|
||||
// TODO*: Adaptively adjust request size if the
|
||||
@@ -780,15 +780,15 @@ public:
|
||||
LLUUID object_id = iter->asUUID();
|
||||
|
||||
// Check to see if the request contains data for the object
|
||||
if ( content.has(iter->asString()) )
|
||||
if ( mContent.has(iter->asString()) )
|
||||
{
|
||||
F32 link_cost =
|
||||
content[iter->asString()]["linked_set_resource_cost"].asReal();
|
||||
mContent[iter->asString()]["linked_set_resource_cost"].asReal();
|
||||
F32 object_cost =
|
||||
content[iter->asString()]["resource_cost"].asReal();
|
||||
mContent[iter->asString()]["resource_cost"].asReal();
|
||||
|
||||
F32 physics_cost = content[iter->asString()]["physics_cost"].asReal();
|
||||
F32 link_physics_cost = content[iter->asString()]["linked_set_physics_cost"].asReal();
|
||||
F32 physics_cost = mContent[iter->asString()]["physics_cost"].asReal();
|
||||
F32 link_physics_cost = mContent[iter->asString()]["linked_set_physics_cost"].asReal();
|
||||
|
||||
gObjectList.updateObjectCost(object_id, object_cost, link_cost, physics_cost, link_physics_cost);
|
||||
}
|
||||
@@ -829,28 +829,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ void error(U32 statusNum, const std::string& reason)
|
||||
/*virtual*/ void httpFailure(void)
|
||||
{
|
||||
llwarns
|
||||
<< "Transport error requesting object physics flags "
|
||||
<< "HTTP status: " << statusNum << ", reason: "
|
||||
<< reason << "." << llendl;
|
||||
<< "HTTP status: " << mStatus << ", reason: "
|
||||
<< mReason << "." << llendl;
|
||||
|
||||
// TODO*: Error message to user
|
||||
// For now just clear the request from the pending list
|
||||
clear_object_list_pending_requests();
|
||||
}
|
||||
|
||||
/*virtual*/ void result(const LLSD& content)
|
||||
/*virtual*/ void httpSuccess(void)
|
||||
{
|
||||
if ( !content.isMap() || content.has("error") )
|
||||
if ( !mContent.isMap() || mContent.has("error") )
|
||||
{
|
||||
// Improper response or the request had an error,
|
||||
// show an error to the user?
|
||||
llwarns
|
||||
<< "Application level error when fetching object "
|
||||
<< "physics flags. Message: " << content["error"]["message"].asString()
|
||||
<< ", identifier: " << content["error"]["identifier"].asString()
|
||||
<< "physics flags. Message: " << mContent["error"]["message"].asString()
|
||||
<< ", identifier: " << mContent["error"]["identifier"].asString()
|
||||
<< llendl;
|
||||
|
||||
// TODO*: Adaptively adjust request size if the
|
||||
@@ -871,9 +871,9 @@ public:
|
||||
LLUUID object_id = iter->asUUID();
|
||||
|
||||
// Check to see if the request contains data for the object
|
||||
if ( content.has(iter->asString()) )
|
||||
if ( mContent.has(iter->asString()) )
|
||||
{
|
||||
const LLSD& data = content[iter->asString()];
|
||||
const LLSD& data = mContent[iter->asString()];
|
||||
|
||||
S32 shape_type = data["PhysicsShapeType"].asInteger();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user