diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-12-17 12:08:44 -0800 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-12-17 12:08:44 -0800 |
commit | 2475335994649dbd8bc20a75d9ca2a78630464c9 (patch) | |
tree | 1b3d87f1388b380f5ac9c466523790765a619c93 | |
parent | 0f7e49dea1dceacbf5c1e1fe2e047c2e18a59cf7 (diff) |
Rearranged the handling of error status codes in LLMimeDiscoveryResponder. We should now deal with many more classes of subtly misbehaving web servers, and will use the returned MIME type for 4xx errors instead of guessing text/html.
-rw-r--r-- | indra/newview/llviewermedia.cpp | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 1258bce151..5aebbc1bdd 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -160,36 +160,25 @@ public: std::string media_type = content["content-type"].asString(); std::string::size_type idx1 = media_type.find_first_of(";"); std::string mime_type = media_type.substr(0, idx1); - completeAny(status, mime_type); - } - virtual void error( U32 status, const std::string& reason ) - { - if(status == 401) - { - // This is the "you need to authenticate" status. - // Treat this like an html page. - completeAny(status, "text/html"); - } - else - if(status == 403) - { - completeAny(status, "text/html"); - } - else - if(status == 404) - { - // 404 is content not found - sites often have bespoke 404 pages so - // treat them like an html page. - completeAny(status, "text/html"); - } - else - if(status == 406) + lldebugs << "status is " << status << ", media type \"" << media_type << "\"" << llendl; + + // 2xx status codes indicate success. + // Most 4xx status codes are successful enough for our purposes. + // 499 is the error code for host not found, timeout, etc. + if( ((status >= 200) && (status < 300)) || + ((status >= 400) && (status < 499)) ) { - // 406 means the server sent something that we didn't indicate was acceptable - // Eventually we should send what we accept in the headers but for now, - // treat 406s like an html page. - completeAny(status, "text/html"); + // The probe was successful. + + if(mime_type.empty()) + { + // Some sites don't return any content-type header at all. + // Treat an empty mime type as text/html. + mime_type = "text/html"; + } + + completeAny(status, mime_type); } else { @@ -200,6 +189,7 @@ public: mMediaImpl->mMediaSourceFailed = true; } } + } void completeAny(U32 status, const std::string& mime_type) |