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:
Aleric Inglewood
2014-07-12 18:29:44 +02:00
parent 3dd846b600
commit 74dff061ff
71 changed files with 721 additions and 752 deletions

View File

@@ -393,21 +393,21 @@ class LLInventoryModelFetchItemResponder : public LLInventoryModel::fetchInvento
{
public:
LLInventoryModelFetchItemResponder(const LLSD& request_sd) : LLInventoryModel::fetchInventoryResponder(request_sd) {};
/*virtual*/ void result(const LLSD& content);
/*virtual*/ void error(U32 status, const std::string& reason);
/*virtual*/ void httpSuccess(void);
/*virtual*/ void httpFailure(void);
/*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return inventoryModelFetchItemResponder_timeout; }
/*virtual*/ char const* getName(void) const { return "LLInventoryModelFetchItemResponder"; }
};
void LLInventoryModelFetchItemResponder::result( const LLSD& content )
void LLInventoryModelFetchItemResponder::httpSuccess(void)
{
LLInventoryModel::fetchInventoryResponder::result(content);
LLInventoryModel::fetchInventoryResponder::httpSuccess();
LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1);
}
void LLInventoryModelFetchItemResponder::error( U32 status, const std::string& reason )
void LLInventoryModelFetchItemResponder::httpFailure(void)
{
LLInventoryModel::fetchInventoryResponder::error(status, reason);
LLInventoryModel::fetchInventoryResponder::httpFailure();
LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1);
}
@@ -418,8 +418,8 @@ class LLInventoryModelFetchDescendentsResponder : public LLHTTPClient::Responder
mRequestSD(request_sd),
mRecursiveCatUUIDs(recursive_cats)
{};
/*virtual*/ void result(const LLSD& content);
/*virtual*/ void error(U32 status, const std::string& reason);
/*virtual*/ void httpSuccess(void);
/*virtual*/ void httpFailure(void);
/*virtual*/ AICapabilityType capability_type(void) const { return cap_inventory; }
/*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return inventoryModelFetchDescendentsResponder_timeout; }
/*virtual*/ char const* getName(void) const { return "LLInventoryModelFetchDescendentsResponder"; }
@@ -432,14 +432,14 @@ private:
};
// If we get back a normal response, handle it here.
void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
void LLInventoryModelFetchDescendentsResponder::httpSuccess(void)
{
LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
if (content.has("folders"))
if (mContent.has("folders"))
{
for(LLSD::array_const_iterator folder_it = content["folders"].beginArray();
folder_it != content["folders"].endArray();
for(LLSD::array_const_iterator folder_it = mContent["folders"].beginArray();
folder_it != mContent["folders"].endArray();
++folder_it)
{
LLSD folder_sd = *folder_it;
@@ -535,10 +535,10 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
}
}
if (content.has("bad_folders"))
if (mContent.has("bad_folders"))
{
for(LLSD::array_const_iterator folder_it = content["bad_folders"].beginArray();
folder_it != content["bad_folders"].endArray();
for(LLSD::array_const_iterator folder_it = mContent["bad_folders"].beginArray();
folder_it != mContent["bad_folders"].endArray();
++folder_it)
{
LLSD folder_sd = *folder_it;
@@ -561,16 +561,16 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
}
//If we get back an error (not found, etc...), handle it here
void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::string& reason)
void LLInventoryModelFetchDescendentsResponder::httpFailure(void)
{
LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
llinfos << "LLInventoryModelFetchDescendentsResponder::error "
<< status << ": " << reason << llendl;
<< mStatus << ": " << mReason << llendl;
fetcher->incrFetchCount(-1);
if (is_internal_http_error_that_warrants_a_retry(status)) // timed out
if (is_internal_http_error_that_warrants_a_retry(mStatus)) // timed out
{
for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
folder_it != mRequestSD["folders"].endArray();