diff options
author | John Reck <jreck@google.com> | 2010-11-22 09:29:44 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-22 09:29:44 -0800 |
commit | 985e2f61578296b57751753f83b1e6f81ba07ccb (patch) | |
tree | 8de8e146e666cbd3b9fa817c68cad716e7778225 /WebKit/android/WebCoreSupport/WebResponse.cpp | |
parent | d8fcffded6ee266e903e4e191ed95a07007fac74 (diff) | |
parent | 787e29b54f206839549283289018384538f050f0 (diff) | |
download | external_webkit-985e2f61578296b57751753f83b1e6f81ba07ccb.zip external_webkit-985e2f61578296b57751753f83b1e6f81ba07ccb.tar.gz external_webkit-985e2f61578296b57751753f83b1e6f81ba07ccb.tar.bz2 |
Merge "Fixes the handling of unspecified mime-type"
Diffstat (limited to 'WebKit/android/WebCoreSupport/WebResponse.cpp')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebResponse.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp index 57e9460..8f68a6a 100644 --- a/WebKit/android/WebCoreSupport/WebResponse.cpp +++ b/WebKit/android/WebCoreSupport/WebResponse.cpp @@ -26,9 +26,13 @@ #include "config.h" #include "WebResponse.h" +#include "MIMETypeRegistry.h" +#include "PlatformString.h" #include "ResourceResponse.h" #include "ResourceError.h" +#include <wtf/text/CString.h> + using namespace std; namespace android { @@ -42,6 +46,8 @@ WebResponse::WebResponse(URLRequest* request) m_url = request->url().spec(); m_host = request->url().HostNoBrackets(); request->GetMimeType(&m_mime); + setMimeType(m_mime); + request->GetCharset(&m_encoding); m_expectedSize = request->GetExpectedContentSize(); @@ -67,6 +73,7 @@ WebResponse::WebResponse(const string &url, const string &mimeType, long long ex , m_mime(mimeType) , m_url(url) { + setMimeType(mimeType); } WebCore::ResourceResponse WebResponse::createResourceResponse() @@ -110,6 +117,17 @@ const string& WebResponse::getMimeType() const return m_mime; } +void WebResponse::setMimeType(const std::string &mimeType) +{ + if (mimeType.length() == 0 && m_url.length() > 0) { + WTF::String wtfMime(m_url.c_str(), m_url.length()); + wtfMime = WebCore::MIMETypeRegistry::getMIMETypeForPath(wtfMime); + m_mime = std::string(wtfMime.utf8().data(), wtfMime.length()); + } else { + m_mime = mimeType; + } +} + bool WebResponse::getHeader(const string& header, string* result) const { map<string, string>::const_iterator iter = m_headerFields.find(header); |