diff options
Diffstat (limited to 'indra')
| -rwxr-xr-x | indra/llcorehttp/httphandler.h | 5 | ||||
| -rw-r--r-- | indra/llmessage/llhttpsdhandler.cpp | 16 | ||||
| -rw-r--r-- | indra/llmessage/llhttpsdhandler.h | 15 | ||||
| -rwxr-xr-x | indra/newview/CMakeLists.txt | 4 | ||||
| -rwxr-xr-x | indra/newview/llmediadataclient.cpp | 378 | ||||
| -rwxr-xr-x | indra/newview/llmediadataclient.h | 80 | 
6 files changed, 262 insertions, 236 deletions
| diff --git a/indra/llcorehttp/httphandler.h b/indra/llcorehttp/httphandler.h index 740e986dec..7bc9096703 100755 --- a/indra/llcorehttp/httphandler.h +++ b/indra/llcorehttp/httphandler.h @@ -53,8 +53,9 @@ class HttpResponse;  /// that is rarely a good idea.  Queued requests and replies keep  /// a naked pointer to the handler and this can result in a  /// dangling pointer if lifetimes aren't managed correctly. - -class HttpHandler +/// +/// *TODO: public std::enable_shared_from_this<HttpHandler> +class HttpHandler   {  public:  	virtual ~HttpHandler() diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 159d03b176..d99bdd3f66 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -36,7 +36,8 @@  #include "llcorehttputil.h"  //======================================================================== -LLHttpSDHandler::LLHttpSDHandler() +LLHttpSDHandler::LLHttpSDHandler(bool selfDelete): +    mSelfDelete(selfDelete)  {  } @@ -77,26 +78,27 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons  	// The handler must destroy itself when it is done.   	// *TODO: I'm not fond of this pattern. A class shooting itself in the head   	// outside of a smart pointer always makes me nervous. -	delete this; +    if (mSelfDelete) +    	delete this;  }  //======================================================================== -LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &caps) : -	LLHttpSDHandler(), -	mCaps(caps) +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &name, bool selfDelete): +	LLHttpSDHandler(selfDelete), +	mName(name)  {  }  void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)  { -	LL_DEBUGS() << mCaps << " Success." << LL_ENDL; +	LL_DEBUGS() << mName << " Success." << LL_ENDL;  }  void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)  {  	LL_WARNS()  		<< "\n--------------------------------------------------------------------------\n" -		<< mCaps << " Error[" << status.toULong() << "] cannot access cap with url '"  +		<< mName << " Error[" << status.toULong() << "] cannot access cap with url '"   		<< response->getRequestURL() << "' because " << status.toString()  		<< "\n--------------------------------------------------------------------------"  		<< LL_ENDL; diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index 7c28dbcab6..814d1c22b5 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -36,32 +36,37 @@  ///   // *TODO: This class self deletes at the end of onCompleted method.  This is   // less than ideal and should be revisited. -class LLHttpSDHandler : public LLCore::HttpHandler +class LLHttpSDHandler : public LLCore::HttpHandler //, +//    public std::enable_shared_from_this<LLHttpSDHandler>  {  public: -	LLHttpSDHandler();  	virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);  protected: +    LLHttpSDHandler(bool selfDelete = true); +  	virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0;  	virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; +private: +    bool mSelfDelete; +  };  /// A trivial implementation of LLHttpSDHandler. This success and failure  -/// methods log the action taken, the URI accessed and the status code retuned  +/// methods log the action taken, the URI accessed and the status code returned   /// in the response.  class LLHttpSDGenericHandler : public LLHttpSDHandler  {  public:  -	LLHttpSDGenericHandler(const std::string &action); +	LLHttpSDGenericHandler(const std::string &name, bool selfDelete = true);  protected:  	virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content);  	virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);  private: -	std::string mCaps; +	std::string mName;  };  #endif
\ No newline at end of file diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3858383e39..13436ecb16 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2218,7 +2218,7 @@ if (LL_TESTS)    SET(viewer_TEST_SOURCE_FILES      llagentaccess.cpp      lldateutil.cpp -    llmediadataclient.cpp +#    llmediadataclient.cpp      lllogininstance.cpp      llremoteparcelrequest.cpp      lltranslate.cpp @@ -2251,7 +2251,7 @@ if (LL_TESTS)    set_source_files_properties(      llmediadataclient.cpp      PROPERTIES -    LL_TEST_ADDITIONAL_LIBRARIES "${CURL_LIBRARIES}" +    LL_TEST_ADDITIONAL_LIBRARIES "${test_libs}"    )    set_source_files_properties( diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 2fb9e60b29..2a53e3fe78 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -40,6 +40,7 @@  #include "llmediaentry.h"  #include "lltextureentry.h"  #include "llviewerregion.h" +#include "llcorehttputil.h"  //  // When making a request @@ -145,18 +146,20 @@ void remove_matching_requests(T &c, const LLUUID &id, LLMediaDataClient::Request  //  ////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, -									 F32 retry_timer_delay, -									 U32 max_retries, -									 U32 max_sorted_queue_size, -									 U32 max_round_robin_queue_size) -	: mQueueTimerDelay(queue_timer_delay), -	  mRetryTimerDelay(retry_timer_delay), -	  mMaxNumRetries(max_retries), -	  mMaxSortedQueueSize(max_sorted_queue_size), -	  mMaxRoundRobinQueueSize(max_round_robin_queue_size), -	  mQueueTimerIsRunning(false) +LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, F32 retry_timer_delay,   +        U32 max_retries, U32 max_sorted_queue_size, U32 max_round_robin_queue_size): +    mQueueTimerDelay(queue_timer_delay), +    mRetryTimerDelay(retry_timer_delay), +    mMaxNumRetries(max_retries), +    mMaxSortedQueueSize(max_sorted_queue_size), +    mMaxRoundRobinQueueSize(max_round_robin_queue_size), +    mQueueTimerIsRunning(false), +    mHttpRequest(new LLCore::HttpRequest()), +    mHttpHeaders(new LLCore::HttpHeaders(), false), +    mHttpOpts(new LLCore::HttpOptions(), false), +    mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID)  { +    // *TODO: Look up real Policy ID  }  LLMediaDataClient::~LLMediaDataClient() @@ -207,18 +210,19 @@ void LLMediaDataClient::stopQueueTimer()  bool LLMediaDataClient::processQueueTimer()  { -	if(isEmpty()) +    if (isDoneProcessing())  		return true;  	LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() started, queue size is:	  " << mQueue.size() << LL_ENDL;  	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() started, SORTED queue is:	  " << mQueue << LL_ENDL;  	serviceQueue(); -	 +    serviceHttp(); +  	LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() finished, queue size is:	  " << mQueue.size() << LL_ENDL;  	LL_DEBUGS("LLMediaDataClientQueue") << "QueueTimer::tick() finished, SORTED queue is:	  " << mQueue << LL_ENDL; -	return isEmpty(); +    return isDoneProcessing();  }  LLMediaDataClient::request_ptr_t LLMediaDataClient::dequeue() @@ -283,6 +287,12 @@ void LLMediaDataClient::stopTrackingRequest(request_ptr_t request)  	}  } +bool LLMediaDataClient::isDoneProcessing() const +{ +    return (isEmpty() && mUnQueuedRequests.empty()); +} + +  void LLMediaDataClient::serviceQueue()  {	  	// Peel one off of the items from the queue and execute it @@ -317,7 +327,18 @@ void LLMediaDataClient::serviceQueue()  		trackRequest(request);  		// and make the post -		LLHTTPClient::post(url, sd_payload, request->createResponder()); +        LLHttpSDHandler *handler = request->createHandler(); +        LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, 0, +            url, sd_payload, mHttpOpts, mHttpHeaders, handler); + +        if (handle == LLCORE_HTTP_HANDLE_INVALID) +        { +            // *TODO: Change this metaphore to use boost::shared_ptr<> for handlers.  Requires change in LLCore::HTTP +            delete handler; +            LLCore::HttpStatus status = mHttpRequest->getStatus(); +            LL_WARNS("LLMediaDataClient") << "'" << url << "' request POST failed. Reason " +                << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; +        }  	}  	else   	{ @@ -332,13 +353,17 @@ void LLMediaDataClient::serviceQueue()  		}  		else  		{ -			// This request has exceeded its maxumim retry count.  It will be dropped. +			// This request has exceeded its maximum retry count.  It will be dropped.  			LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " << mMaxNumRetries << " tries, dropping request." << LL_ENDL;   		}  	}  } +void LLMediaDataClient::serviceHttp() +{ +    mHttpRequest->update(0); +}  // dump the queue  std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::request_queue_t &q) @@ -551,79 +576,67 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r)  	<< " #retries=" << r.getRetryCount();  	return s;  } -			 -////////////////////////////////////////////////////////////////////////////////////// -// -// LLMediaDataClient::Responder -// -////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::Responder::Responder(const request_ptr_t &request) -: mRequest(request) +//======================================================================== + +LLMediaDataClient::Handler::Handler(const request_ptr_t &request): +    mRequest(request)  {  } -/*virtual*/ -void LLMediaDataClient::Responder::httpFailure() + +void LLMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)  { -	mRequest->stopTracking(); +    mRequest->stopTracking(); -	if(mRequest->isDead()) -	{ -		LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; -		return; -	} -	 -	if (getStatus() == HTTP_SERVICE_UNAVAILABLE) -	{ -		F32 retry_timeout; -#if 0 -		// *TODO: Honor server Retry-After header. -		if (!hasResponseHeader(HTTP_IN_HEADER_RETRY_AFTER) -			|| !getSecondsUntilRetryAfter(getResponseHeader(HTTP_IN_HEADER_RETRY_AFTER), retry_timeout)) -#endif -		{ -			retry_timeout = mRequest->getRetryTimerDelay(); -		} -		 -		mRequest->incRetryCount(); -		 -		if (mRequest->getRetryCount() < mRequest->getMaxNumRetries())  -		{ -			LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; -			 -			// Start timer (instances are automagically tracked by -			// InstanceTracker<> and LLEventTimer) -			new RetryTimer(F32(retry_timeout/*secs*/), mRequest); -		} -		else  -		{ -			LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count "  -				<< mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; -		} -	} -	// *TODO: Redirect on 3xx status codes. -	else  -	{ -		LL_WARNS("LLMediaDataClient") << *mRequest << " http failure " -				<< dumpResponse() << LL_ENDL; -	} +    if (mRequest->isDead()) +    { +        LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; +        return; +    } + +    LL_DEBUGS("LLMediaDataClientResponse") << *mRequest << LL_ENDL;  } -/*virtual*/ -void LLMediaDataClient::Responder::httpSuccess() +void LLMediaDataClient::Handler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)  { -	mRequest->stopTracking(); +    mRequest->stopTracking(); -	if(mRequest->isDead()) -	{ -		LL_WARNS("LLMediaDataClient") << "dead request " << *mRequest << LL_ENDL; -		return; -	} +    if (status == LLCore::HttpStatus(HTTP_SERVICE_UNAVAILABLE)) +    { +        F32 retry_timeout; +#if 0 +        // *TODO: Honor server Retry-After header. +        if (!hasResponseHeader(HTTP_IN_HEADER_RETRY_AFTER) +            || !getSecondsUntilRetryAfter(getResponseHeader(HTTP_IN_HEADER_RETRY_AFTER), retry_timeout)) +#endif +        { +            retry_timeout = mRequest->getRetryTimerDelay(); +        } + +        mRequest->incRetryCount(); -	LL_DEBUGS("LLMediaDataClientResponse") << *mRequest << " " << dumpResponse() << LL_ENDL; +        if (mRequest->getRetryCount() < mRequest->getMaxNumRetries())  +        { +            LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; + +            // Start timer (instances are automagically tracked by +            // InstanceTracker<> and LLEventTimer) +            new RetryTimer(F32(retry_timeout/*secs*/), mRequest); +        } +        else  +        { +            LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count "  +                << mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; +        } +    } +    else +    { +        LL_WARNS("LLMediaDataClient") << *mRequest << " HTTP failure " << LL_ENDL; +    }  } +  //////////////////////////////////////////////////////////////////////////////////////  //  // LLObjectMediaDataClient @@ -801,7 +814,7 @@ void LLObjectMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr  bool LLObjectMediaDataClient::processQueueTimer()  { -	if(isEmpty()) +    if (isDoneProcessing())  		return true;  	LL_DEBUGS("LLMediaDataClient") << "started, SORTED queue size is:	  " << mQueue.size()  @@ -816,6 +829,7 @@ bool LLObjectMediaDataClient::processQueueTimer()  	LL_DEBUGS("LLMediaDataClientQueue") << "after sort, SORTED queue is:	  " << mQueue << LL_ENDL;  	serviceQueue(); +    serviceHttp();  	swapCurrentQueue(); @@ -824,7 +838,7 @@ bool LLObjectMediaDataClient::processQueueTimer()  	LL_DEBUGS("LLMediaDataClientQueue") << "    SORTED queue is:	  " << mQueue << LL_ENDL;  	LL_DEBUGS("LLMediaDataClientQueue") << "    RR queue is:	  " << mRoundRobinQueue << LL_ENDL; -	return isEmpty(); +    return isDoneProcessing();  }  LLObjectMediaDataClient::RequestGet::RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc): @@ -841,9 +855,9 @@ LLSD LLObjectMediaDataClient::RequestGet::getPayload() const  	return result;  } -LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestGet::createResponder() +LLHttpSDHandler *LLObjectMediaDataClient::RequestGet::createHandler()  { -	return new LLObjectMediaDataClient::Responder(this); +	return new LLObjectMediaDataClient::Handler(this);  } @@ -877,60 +891,58 @@ LLSD LLObjectMediaDataClient::RequestUpdate::getPayload() const  	return result;  } -LLMediaDataClient::Responder *LLObjectMediaDataClient::RequestUpdate::createResponder() +LLHttpSDHandler *LLObjectMediaDataClient::RequestUpdate::createHandler()  {  	// This just uses the base class's responder. -	return new LLMediaDataClient::Responder(this); +	return new LLMediaDataClient::Handler(this);  } - -/*virtual*/ -void LLObjectMediaDataClient::Responder::httpSuccess() +void LLObjectMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)  { -	getRequest()->stopTracking(); +    LLMediaDataClient::Handler::onSuccess(response, content); + +    if (getRequest()->isDead()) +    {   // warning emitted from base method. +        return; +    } + +    if (!content.isMap()) +    { +        onFailure(response, LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents")); +        return; +    } + +    // This responder is only used for GET requests, not UPDATE. +    LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << LL_ENDL; + +    // Look for an error +    if (content.has("error")) +    { +        const LLSD &error = content["error"]; +        LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" <<  +            error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; + +        // XXX Warn user? +    } +    else  +    { +        // Check the data +        const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; +        if (object_id != getRequest()->getObject()->getID())  +        { +            // NOT good, wrong object id!! +            LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; +            return; +        } + +        // Otherwise, update with object media data +        getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY], +            content[LLTextureEntry::MEDIA_VERSION_KEY]); +    } -	if(getRequest()->isDead()) -	{ -		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; -		return; -	} - -	const LLSD& content = getContent(); -	if (!content.isMap()) -	{ -		failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); -		return; -	} - -	// This responder is only used for GET requests, not UPDATE. -	LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << dumpResponse() << LL_ENDL; - -	// Look for an error -	if (content.has("error")) -	{ -		const LLSD &error = content["error"]; -		LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" <<  -			error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; -		 -		// XXX Warn user? -	} -	else  -	{ -		// Check the data -		const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; -		if (object_id != getRequest()->getObject()->getID())  -		{ -			// NOT good, wrong object id!! -			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; -			return; -		} -		 -		// Otherwise, update with object media data -		getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY], -														 content[LLTextureEntry::MEDIA_VERSION_KEY]); -	}  } +  //////////////////////////////////////////////////////////////////////////////////////  //  // LLObjectMediaNavigateClient @@ -947,7 +959,7 @@ void LLObjectMediaNavigateClient::enqueue(Request *request)  {  	if(request->isDead())  	{ -		LL_DEBUGS("LLMediaDataClient") << "not queueing dead request " << *request << LL_ENDL; +		LL_DEBUGS("LLMediaDataClient") << "not queuing dead request " << *request << LL_ENDL;  		return;  	} @@ -979,7 +991,7 @@ void LLObjectMediaNavigateClient::enqueue(Request *request)  	else  #endif  	{ -		LL_DEBUGS("LLMediaDataClient") << "queueing new request " << (*request) << LL_ENDL; +		LL_DEBUGS("LLMediaDataClient") << "queuing new request " << (*request) << LL_ENDL;  		mQueue.push_back(request);  		// Start the timer if not already running @@ -1012,75 +1024,67 @@ LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const  	return result;  } -LLMediaDataClient::Responder *LLObjectMediaNavigateClient::RequestNavigate::createResponder() +LLHttpSDHandler *LLObjectMediaNavigateClient::RequestNavigate::createHandler()  { -	return new LLObjectMediaNavigateClient::Responder(this); +	return new LLObjectMediaNavigateClient::Handler(this);  } -/*virtual*/ -void LLObjectMediaNavigateClient::Responder::httpFailure() +void LLObjectMediaNavigateClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)  { -	getRequest()->stopTracking(); +    LLMediaDataClient::Handler::onSuccess(response, content); -	if(getRequest()->isDead()) -	{ -		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; -		return; -	} +    if (getRequest()->isDead()) +    {   // already warned. +        return; +    } + +    LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned" << LL_ENDL; + +    if (content.has("error")) +    { +        const LLSD &error = content["error"]; +        int error_code = error["code"]; + +        if (ERROR_PERMISSION_DENIED_CODE == error_code) +        { +            mediaNavigateBounceBack(); +        } +        else +        { +            LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << +                error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; +        } + +        // XXX Warn user? +    } +    else +    { +        // No action required. +        LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << LL_ENDL; +    } -	// Bounce back (unless HTTP_SERVICE_UNAVAILABLE, in which case call base -	// class -	if (getStatus() == HTTP_SERVICE_UNAVAILABLE) -	{ -		LLMediaDataClient::Responder::httpFailure(); -	} -	else -	{ -		// bounce the face back -		LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: " << dumpResponse() << LL_ENDL; -		const LLSD &payload = getRequest()->getPayload(); -		// bounce the face back -		getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); -	}  } -/*virtual*/ -void LLObjectMediaNavigateClient::Responder::httpSuccess() +void LLObjectMediaNavigateClient::Handler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)  { -	getRequest()->stopTracking(); +    LLMediaDataClient::Handler::onFailure(response, status); -	if(getRequest()->isDead()) -	{ -		LL_WARNS("LLMediaDataClient") << "dead request " << *(getRequest()) << LL_ENDL; -		return; -	} +    if (getRequest()->isDead()) +    {   // already warned. +        return; +    } -	LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << dumpResponse() << LL_ENDL; -	 -	const LLSD& content = getContent(); -	if (content.has("error")) -	{ -		const LLSD &error = content["error"]; -		int error_code = error["code"]; -		 -		if (ERROR_PERMISSION_DENIED_CODE == error_code) -		{ -			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; -			const LLSD &payload = getRequest()->getPayload(); -			// bounce the face back -			getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); -		} -		else -		{ -			LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" <<  -				error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; -		}			  +    if (status != LLCore::HttpStatus(HTTP_SERVICE_UNAVAILABLE)) +    { +        mediaNavigateBounceBack(); +    } +} -		// XXX Warn user? -	} -	else  -	{ -		// No action required. -		LL_DEBUGS("LLMediaDataClientResponse") << *(getRequest()) << " " << dumpResponse() << LL_ENDL; -	} +void LLObjectMediaNavigateClient::Handler::mediaNavigateBounceBack() +{ +    LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating or denied." << LL_ENDL; +    const LLSD &payload = getRequest()->getPayload(); +     +    // bounce the face back +    getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]);  } diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 80dd519812..d123aa7a11 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -32,7 +32,11 @@  #include "llrefcount.h"  #include "llpointer.h"  #include "lleventtimer.h" - +#include "llhttpsdhandler.h" +#include "httpcommon.h" +#include "httprequest.h" +#include "httpoptions.h" +#include "httpheaders.h"  // Link seam for LLVOVolume  class LLMediaDataClientObject : public LLRefCount @@ -109,8 +113,6 @@ protected:  	// Destructor  	virtual ~LLMediaDataClient(); // use unref -	class Responder; -	  	// Request (pure virtual base class for requests in the queue)  	class Request : public LLRefCount  	{ @@ -118,7 +120,7 @@ protected:  		// Subclasses must implement this to build a payload for their request type.  		virtual LLSD getPayload() const = 0;  		// and must create the correct type of responder. -		virtual Responder *createResponder() = 0; +        virtual LLHttpSDHandler *createHandler() = 0;  		virtual std::string getURL() { return ""; } @@ -190,23 +192,21 @@ protected:  	};  	typedef LLPointer<Request> request_ptr_t; -	// Responder -	class Responder : public LLHTTPClient::Responder -	{ -		LOG_CLASS(Responder); -	public: -		Responder(const request_ptr_t &request); -		request_ptr_t &getRequest() { return mRequest; } +    class Handler : public LLHttpSDHandler +    { +        LOG_CLASS(Handler); +    public: +        Handler(const request_ptr_t &request); +        request_ptr_t getRequest() const { return mRequest; } -	protected: -		//If we get back an error (not found, etc...), handle it here -		virtual void httpFailure(); -		//If we get back a normal response, handle it here.	 Default just logs it. -		virtual void httpSuccess(); +    protected: +        virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); +        virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +    private: +        request_ptr_t mRequest; +    }; -	private: -		request_ptr_t mRequest; -	};  	class RetryTimer : public LLEventTimer  	{ @@ -230,6 +230,7 @@ protected:  	virtual void enqueue(Request*) = 0;  	virtual void serviceQueue(); +    virtual void serviceHttp();  	virtual request_queue_t *getQueue() { return &mQueue; }; @@ -243,6 +244,8 @@ protected:  	void trackRequest(request_ptr_t request);  	void stopTrackingRequest(request_ptr_t request); + +    bool isDoneProcessing() const;  	request_queue_t mQueue; @@ -260,6 +263,11 @@ protected:  	void startQueueTimer();  	void stopQueueTimer(); +    LLCore::HttpRequest::ptr_t  mHttpRequest; +    LLCore::HttpHeaders::ptr_t  mHttpHeaders; +    LLCore::HttpOptions::ptr_t  mHttpOpts; +    LLCore::HttpRequest::policy_t mHttpPolicy; +  private:  	static F64 getObjectScore(const LLMediaDataClientObject::ptr_t &obj); @@ -309,7 +317,7 @@ public:  	public:  		RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc);  		/*virtual*/ LLSD getPayload() const; -		/*virtual*/ Responder *createResponder(); +        /*virtual*/ LLHttpSDHandler *createHandler();  	};  	class RequestUpdate: public Request @@ -317,7 +325,7 @@ public:  	public:  		RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc);  		/*virtual*/ LLSD getPayload() const; -		/*virtual*/ Responder *createResponder(); +        /*virtual*/ LLHttpSDHandler *createHandler();  	};  	// Returns true iff the queue is empty @@ -342,15 +350,18 @@ protected:  	// Puts the request into the appropriate queue  	virtual void enqueue(Request*); -    class Responder : public LLMediaDataClient::Responder +    class Handler: public LLMediaDataClient::Handler      { -        LOG_CLASS(Responder); +        LOG_CLASS(Handler);      public: -        Responder(const request_ptr_t &request) -            : LLMediaDataClient::Responder(request) {} +        Handler(const request_ptr_t &request): +            LLMediaDataClient::Handler(request) +        {} +      protected: -        virtual void httpSuccess(); +        virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content);      }; +  private:  	// The Get/Update data client needs a second queue to avoid object updates starving load-ins.  	void swapCurrentQueue(); @@ -391,7 +402,7 @@ public:  	public:  		RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url);  		/*virtual*/ LLSD getPayload() const; -		/*virtual*/ Responder *createResponder(); +        /*virtual*/ LLHttpSDHandler *createHandler();  		/*virtual*/ std::string getURL() { return mURL; }  	private:  		std::string mURL; @@ -401,15 +412,18 @@ protected:  	// Subclasses must override to return a cap name  	virtual const char *getCapabilityName() const; -    class Responder : public LLMediaDataClient::Responder +    class Handler : public LLMediaDataClient::Handler      { -        LOG_CLASS(Responder); +        LOG_CLASS(Handler);      public: -        Responder(const request_ptr_t &request) -            : LLMediaDataClient::Responder(request) {} +        Handler(const request_ptr_t &request): +            LLMediaDataClient::Handler(request) +        {} +      protected: -        virtual void httpFailure(); -        virtual void httpSuccess(); +        virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); +        virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); +      private:          void mediaNavigateBounceBack();      }; | 
