summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-12-14 16:35:23 +0000
committerBen Murdoch <benm@google.com>2010-12-15 13:21:10 +0000
commit7911c3f54e13fc70b49ed513e2be226129cd4ea7 (patch)
treebb48cf3e970c4965eec35fdb512331fd2a53310c /WebKit/android/WebCoreSupport
parentc7911ffd666a7e73131dfd68919b769086a093e0 (diff)
downloadexternal_webkit-7911c3f54e13fc70b49ed513e2be226129cd4ea7.zip
external_webkit-7911c3f54e13fc70b49ed513e2be226129cd4ea7.tar.gz
external_webkit-7911c3f54e13fc70b49ed513e2be226129cd4ea7.tar.bz2
Fix WebView form submission CTS failure.
When we try to resolve the MIME type from the URL path, we need to be sure to pass just the path so strip off any fragment or query strings. Otherwise this wreaks havoc when we try and extract the file extension to deduce the MIME type. Bug:3241908 Change-Id: I592ae7ba0acc7478789599aeb6973675ed415a37
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/WebResponse.cpp28
-rw-r--r--WebKit/android/WebCoreSupport/WebResponse.h3
2 files changed, 17 insertions, 14 deletions
diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp
index 8f68a6a..e564215 100644
--- a/WebKit/android/WebCoreSupport/WebResponse.cpp
+++ b/WebKit/android/WebCoreSupport/WebResponse.cpp
@@ -46,7 +46,6 @@ 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();
@@ -73,12 +72,11 @@ WebResponse::WebResponse(const string &url, const string &mimeType, long long ex
, m_mime(mimeType)
, m_url(url)
{
- setMimeType(mimeType);
}
WebCore::ResourceResponse WebResponse::createResourceResponse()
{
- WebCore::ResourceResponse resourceResponse(createKurl(), m_mime.c_str(), m_expectedSize, m_encoding.c_str(), "");
+ WebCore::ResourceResponse resourceResponse(createKurl(), getMimeType().c_str(), m_expectedSize, m_encoding.c_str(), "");
resourceResponse.setHTTPStatusCode(m_httpStatusCode);
resourceResponse.setHTTPStatusText(m_httpStatusText.c_str());
@@ -112,20 +110,26 @@ void WebResponse::setUrl(const string& url)
m_url = url;
}
-const string& WebResponse::getMimeType() const
+// Calls WebCore APIs so should only be called from the WebCore thread.
+// TODO: can we return a WTF::String directly? Need to check all callsites.
+const string& WebResponse::getMimeType()
{
- return m_mime;
-}
-
-void WebResponse::setMimeType(const std::string &mimeType)
-{
- if (mimeType.length() == 0 && m_url.length() > 0) {
+ if (!m_mime.length() && m_url.length()) {
WTF::String wtfMime(m_url.c_str(), m_url.length());
+ // Need to strip fragment and/or query if present.
+ size_t position = wtfMime.reverseFind('#');
+ if (position != WTF::notFound)
+ wtfMime.truncate(position);
+
+ position = wtfMime.reverseFind('?');
+ if (position != WTF::notFound)
+ wtfMime.truncate(position);
+
wtfMime = WebCore::MIMETypeRegistry::getMIMETypeForPath(wtfMime);
m_mime = std::string(wtfMime.utf8().data(), wtfMime.length());
- } else {
- m_mime = mimeType;
}
+
+ return m_mime;
}
bool WebResponse::getHeader(const string& header, string* result) const
diff --git a/WebKit/android/WebCoreSupport/WebResponse.h b/WebKit/android/WebCoreSupport/WebResponse.h
index f03e4bb..8bbfef5 100644
--- a/WebKit/android/WebCoreSupport/WebResponse.h
+++ b/WebKit/android/WebCoreSupport/WebResponse.h
@@ -52,7 +52,7 @@ public:
const std::string& getUrl() const;
void setUrl(const std::string&);
- const std::string& getMimeType() const;
+ const std::string& getMimeType(); // Use only on WebCore thread.
bool getHeader(const std::string& header, std::string* result) const;
long long getExpectedSize() const;
@@ -81,7 +81,6 @@ private:
// See RFC 822, 3.4.7, "CASE INDEPENDENCE".
std::map<std::string, std::string, CaseInsensitiveLessThan> m_headerFields;
- void setMimeType(const std::string &mimeType);
};
} // namespace android