Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: third_party/WebKit/WebCore/platform/network/soup/ResourceHandleSoup.cpp

Issue 39293: WebKit merge 41447:41498 [third_party/WebKit] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove CRLF Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/WebCore/platform/network/soup/ResourceHandleSoup.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/network/soup/ResourceHandleSoup.cpp (revision 11154)
+++ third_party/WebKit/WebCore/platform/network/soup/ResourceHandleSoup.cpp (working copy)
@@ -214,6 +214,12 @@
if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code))
return;
+ // We still don't know anything about Content-Type, so we will try
+ // sniffing the contents of the file, and then report that we got
+ // headers
+ if (!soup_message_headers_get_content_type(msg->response_headers, NULL))
+ return;
+
ResourceHandle* handle = static_cast<ResourceHandle*>(data);
if (!handle)
return;
@@ -226,7 +232,7 @@
fillResponseFromMessage(msg, &d->m_response);
client->didReceiveResponse(handle, d->m_response);
- soup_message_set_flags(msg, SOUP_MESSAGE_OVERWRITE_CHUNKS);
+ d->m_reportedHeaders = true;
}
static void gotChunkCallback(SoupMessage* msg, SoupBuffer* chunk, gpointer data)
@@ -244,6 +250,17 @@
if (!client)
return;
+ if (!d->m_reportedHeaders) {
+ gboolean uncertain;
+ char* contentType = g_content_type_guess(d->m_request.url().lastPathComponent().utf8().data(), reinterpret_cast<const guchar*>(chunk->data), chunk->length, &uncertain);
+ soup_message_headers_set_content_type(msg->response_headers, contentType, NULL);
+ g_free(contentType);
+
+ fillResponseFromMessage(msg, &d->m_response);
+ client->didReceiveResponse(handle, d->m_response);
+ d->m_reportedHeaders = true;
+ }
+
client->didReceiveData(handle, chunk->data, chunk->length, false);
}
@@ -431,13 +448,8 @@
* be (big) files, which we will want to mmap instead of
* copying into memory; TODO: support upload of non-local
* (think sftp://) files by using GIO?
- *
- * TODO: we can avoid appending all the buffers to the
- * request_body variable with the following call, but we
- * need to depend on libsoup > 2.25.4
- *
- * soup_message_body_set_accumulate(msg->request_body, FALSE);
*/
+ soup_message_body_set_accumulate(msg->request_body, FALSE);
for (size_t i = 0; i < numElements; i++) {
const FormDataElement& element = httpBody->elements()[i];
@@ -487,6 +499,10 @@
d->m_msg = static_cast<SoupMessage*>(g_object_ref(msg));
// balanced by a deref() in finishedCallback, which should always run
ref();
+
+ // We handle each chunk ourselves, and we don't need msg->response_body
+ // to contain all of the data we got, when we finish downloading.
+ soup_message_body_set_accumulate(msg->response_body, FALSE);
soup_session_queue_message(session, d->m_msg, finishedCallback, this);
return true;
@@ -551,16 +567,10 @@
void ResourceHandle::cancel()
{
d->m_cancelled = true;
- if (d->m_msg) {
+ if (d->m_msg)
soup_session_cancel_message(defaultSession(), d->m_msg, SOUP_STATUS_CANCELLED);
- // For re-entrancy troubles we call didFinishLoading when the message hasn't been handled yet.
- if (client())
- client()->didFinishLoading(this);
- } else if (d->m_cancellable) {
+ else if (d->m_cancellable)
g_cancellable_cancel(d->m_cancellable);
- if (client())
- client()->didFinishLoading(this);
- }
}
PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()

Powered by Google App Engine
This is Rietveld 408576698