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

@@ -116,20 +116,20 @@ namespace
{
}
/*virtual*/ void error(U32 status, const std::string& reason)
/*virtual*/ void httpFailure(void)
{
// don't spam when agent communication disconnected already
if (status != 410)
if (mStatus != 410)
{
LL_WARNS("Messaging") << "error status " << status
LL_WARNS("Messaging") << "error status " << mStatus
<< " for message " << mMessageName
<< " reason " << reason << llendl;
<< " reason " << mReason << llendl;
}
// TODO: Map status in to useful error code.
// TODO: Map mStatus in to useful error code.
if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_TCP_TIMEOUT);
}
/*virtual*/ void result(const LLSD& content)
/*virtual*/ void httpSuccess(void)
{
if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_NOERR);
}