summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage')
-rwxr-xr-xindra/llmessage/llhttpretrypolicy.cpp17
-rwxr-xr-xindra/llmessage/llhttpretrypolicy.h17
2 files changed, 31 insertions, 3 deletions
diff --git a/indra/llmessage/llhttpretrypolicy.cpp b/indra/llmessage/llhttpretrypolicy.cpp
index 23d9e64c13..7e4dfc7250 100755
--- a/indra/llmessage/llhttpretrypolicy.cpp
+++ b/indra/llmessage/llhttpretrypolicy.cpp
@@ -27,8 +27,21 @@
#include "linden_common.h"
#include "llhttpretrypolicy.h"
+bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, retry_header_time)
+{
+ return (headers.has(HTTP_IN_HEADER_RETRY_AFTER)
+ && getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time));
+}
+
void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers)
{
+ F32 retry_header_time;
+ bool has_retry_header_time = getRetryAfter(headers,retry_header_time);
+ onFailureCommon(status, has_retry_header_time, retry_header_time);
+}
+
+void LLAdaptiveRetryPolicy::onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time)
+{
if (mRetryCount > 0)
{
mDelay = llclamp(mDelay*mBackoffFactor,mMinDelay,mMaxDelay);
@@ -36,9 +49,7 @@ void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers)
// Honor server Retry-After header.
// Status 503 may ask us to wait for a certain amount of time before retrying.
F32 wait_time = mDelay;
- F32 retry_header_time;
- if (headers.has(HTTP_IN_HEADER_RETRY_AFTER)
- && getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time))
+ if (has_retry_header_time)
{
wait_time = retry_header_time;
}
diff --git a/indra/llmessage/llhttpretrypolicy.h b/indra/llmessage/llhttpretrypolicy.h
index f2eba0965b..cf27bb3048 100755
--- a/indra/llmessage/llhttpretrypolicy.h
+++ b/indra/llmessage/llhttpretrypolicy.h
@@ -29,8 +29,13 @@
#include "lltimer.h"
#include "llthread.h"
+
#include "llhttpconstants.h"
+// For compatibility with new core http lib.
+#include "httpresponse.h"
+#include "httpheaders.h"
+
// This is intended for use with HTTP Clients/Responders, but is not
// specifically coupled with those classes.
class LLHTTPRetryPolicy: public LLThreadSafeRefCount
@@ -40,6 +45,9 @@ public:
virtual ~LLHTTPRetryPolicy() {}
// Call once after an HTTP failure to update state.
virtual void onFailure(S32 status, const LLSD& headers) = 0;
+
+ virtual void onFailure(const HttpResponse *response, const HttpHeaders *headers) = 0;
+
virtual bool shouldRetry(F32& seconds_to_wait) const = 0;
};
@@ -59,10 +67,19 @@ public:
{
}
+ // virtual
void onFailure(S32 status, const LLSD& headers);
+ // virtual
+ void onFailure(const HttpResponse *response, const HttpHeaders *headers);
+ // virtual
bool shouldRetry(F32& seconds_to_wait) const;
+protected:
+ bool getRetryAfter(const LLSD& headers, retry_header_time)
+ void onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time);
+
private:
+
F32 mMinDelay; // delay never less than this value
F32 mMaxDelay; // delay never exceeds this value
F32 mBackoffFactor; // delay increases by this factor after each retry, up to mMaxDelay.