From 319a1ceb63784aba2c0c94808707e1ce9ac90f71 Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Tue, 18 Jan 2011 15:56:59 +0000 Subject: [PATCH] Try to guess content type if header is generic Don't just use text/plain or application/octet-stream, this matches the old stack. Fix for bug 2981069 Change-Id: I1b5edf0e60e7c7012f4143906ec926227edcf927 --- WebKit/android/WebCoreSupport/WebResponse.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp index 52297b25b..a00b52d27 100644 --- a/WebKit/android/WebCoreSupport/WebResponse.cpp +++ b/WebKit/android/WebCoreSupport/WebResponse.cpp @@ -114,7 +114,10 @@ void WebResponse::setUrl(const string& url) // TODO: can we return a WTF::String directly? Need to check all callsites. const string& WebResponse::getMimeType() { - if (!m_mime.length() && m_url.length()) + if (!m_url.length()) + return m_mime; + + if (!m_mime.length() || !m_mime.compare("text/plain") || !m_mime.compare("application/octet-stream")) m_mime = resolveMimeType(m_url); return m_mime; @@ -134,6 +137,7 @@ const string WebResponse::resolveMimeType(string url) if (extensionPos != WTF::notFound) { // We found a file extension. path.remove(0, extensionPos + 1); + // TODO: Should use content-disposition instead of url if it is there WTF::String mime = WebCore::MIMETypeRegistry::getMIMETypeForExtension(path); if (!mime.isEmpty()) { // Great, we found a MIME type. -- 2.11.0