summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoriyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-10 00:30:42 +0000
committeriyengar@google.com <iyengar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-10 00:30:42 +0000
commitcc6cd3484260c20f59a6abd8f52d7b1f18b2e973 (patch)
treed2681f297f33dedba2552207a48e6e4afad1eea9 /webkit
parent11b901ee17f1ef5aa41c70046b7a5360534c633d (diff)
downloadchromium_src-cc6cd3484260c20f59a6abd8f52d7b1f18b2e973.zip
chromium_src-cc6cd3484260c20f59a6abd8f52d7b1f18b2e973.tar.gz
chromium_src-cc6cd3484260c20f59a6abd8f52d7b1f18b2e973.tar.bz2
This fixes http://code.google.com/p/chromium/issues/detail?id=643, which
is an issue with the shockwave game not loading. The plugin issues a number of geturlnotify requests. Some of these requests come in with response headers without the content length. We would pass in -1 in the NPStream passed down to the plugin. As the end field in the NPStream structure is an unsigned integer, the plugin would expect more data to arrive and hence the issue. The fix is to emulate Safari behavior and set the end field to 0 if the length is -1. Bug=643 Review URL: http://codereview.chromium.org/1676 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webplugin_impl.cc76
-rw-r--r--webkit/glue/webplugin_impl.h11
2 files changed, 52 insertions, 35 deletions
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index e4259b3..0485e44 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -130,27 +130,16 @@ void WebPluginContainer::detachFromWindow() {
void WebPluginContainer::didReceiveResponse(
const WebCore::ResourceResponse& response) {
-
- std::wstring url = webkit_glue::StringToStdWString(response.url().string());
- std::string ascii_url = WideToASCII(url);
-
- std::wstring mime_type(webkit_glue::StringToStdWString(response.mimeType()));
-
- uint32 last_modified = static_cast<uint32>(response.lastModifiedDate());
- uint32 expected_length =
- static_cast<uint32>(response.expectedContentLength());
- WebCore::String content_encoding =
- response.httpHeaderField("Content-Encoding");
- if (!content_encoding.isNull() && content_encoding != "identity") {
- // Don't send the compressed content length to the plugin, which only
- // cares about the decoded length.
- expected_length = 0;
- }
+
+ HttpResponseInfo http_response_info;
+ ReadHttpResponseInfo(response, &http_response_info);
impl_->delegate_->DidReceiveManualResponse(
- ascii_url, base::SysWideToNativeMB(mime_type),
+ http_response_info.url,
+ base::SysWideToNativeMB(http_response_info.mime_type),
base::SysWideToNativeMB(impl_->GetAllHeaders(response)),
- expected_length, last_modified);
+ http_response_info.expected_length,
+ http_response_info.last_modified);
}
void WebPluginContainer::didReceiveData(const char *buffer, int length) {
@@ -165,6 +154,31 @@ void WebPluginContainer::didFail(const WebCore::ResourceError&) {
impl_->delegate_->DidManualLoadFail();
}
+void WebPluginContainer::ReadHttpResponseInfo(
+ const WebCore::ResourceResponse& response,
+ HttpResponseInfo* http_response) {
+ std::wstring url = webkit_glue::StringToStdWString(response.url().string());
+ http_response->url = WideToASCII(url);
+
+ http_response->mime_type =
+ webkit_glue::StringToStdWString(response.mimeType());
+
+ http_response->last_modified =
+ static_cast<uint32>(response.lastModifiedDate());
+ // If the length comes in as -1, then it indicates that it was not
+ // read off the HTTP headers. We replicate Safari webkit behavior here,
+ // which is to set it to 0.
+ http_response->expected_length =
+ static_cast<uint32>(std::max(response.expectedContentLength(), 0LL));
+ WebCore::String content_encoding =
+ response.httpHeaderField("Content-Encoding");
+ if (!content_encoding.isNull() && content_encoding != "identity") {
+ // Don't send the compressed content length to the plugin, which only
+ // cares about the decoded length.
+ http_response->expected_length = 0;
+ }
+}
+
WebCore::Widget* WebPluginImpl::Create(const GURL& url,
char** argn,
char** argv,
@@ -789,25 +803,17 @@ void WebPluginImpl::didReceiveResponse(WebCore::ResourceHandle* handle,
if (!client)
return;
+ WebPluginContainer::HttpResponseInfo http_response_info;
+ WebPluginContainer::ReadHttpResponseInfo(response, &http_response_info);
+
bool cancel = false;
- std::wstring mime_type(webkit_glue::StringToStdWString(response.mimeType()));
- uint32 last_modified = static_cast<uint32>(response.lastModifiedDate());
- uint32 expected_length =
- static_cast<uint32>(response.expectedContentLength());
- WebCore::String content_encoding =
- response.httpHeaderField("Content-Encoding");
- if (!content_encoding.isNull() && content_encoding != "identity") {
- // Don't send the compressed content length to the plugin, which only
- // cares about the decoded length.
- expected_length = 0;
- }
+ client->DidReceiveResponse(
+ base::SysWideToNativeMB(http_response_info.mime_type),
+ base::SysWideToNativeMB(GetAllHeaders(response)),
+ http_response_info.expected_length,
+ http_response_info.last_modified, &cancel);
- client->DidReceiveResponse(base::SysWideToNativeMB(mime_type),
- base::SysWideToNativeMB(GetAllHeaders(response)),
- expected_length,
- last_modified,
- &cancel);
if (cancel) {
handle->cancel();
RemoveClient(handle);
@@ -1013,7 +1019,7 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id,
info.request.setResourceType(ResourceType::OBJECT);
info.request.setHTTPMethod(method);
- const WebCore::String& referrer = frame()->loader()->outgoingReferrer();
+ const WebCore::String& referrer = frame()->loader()->outgoingReferrer();
if (!WebCore::FrameLoader::shouldHideReferrer(
complete_url_string.spec().c_str(), referrer)) {
info.request.setHTTPReferrer(referrer);
diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h
index b19f178..04b48b3 100644
--- a/webkit/glue/webplugin_impl.h
+++ b/webkit/glue/webplugin_impl.h
@@ -70,6 +70,17 @@ class WebPluginContainer : public WebCore::Widget {
void didFinishLoading();
void didFail(const WebCore::ResourceError&);
+ struct HttpResponseInfo {
+ std::string url;
+ std::wstring mime_type;
+ uint32 last_modified;
+ uint32 expected_length;
+ };
+ // Helper function to read fields in a HTTP response structure.
+ // These fields are written to the HttpResponseInfo structure passed in.
+ static void ReadHttpResponseInfo(const WebCore::ResourceResponse& response,
+ HttpResponseInfo* http_response);
+
private:
WebPluginImpl* impl_;
};