<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206805] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206805">206805</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-05 00:08:38 -0700 (Wed, 05 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[SOUP] Move request HTTP body handling to ResourceRequestSoup and simplify it
https://bugs.webkit.org/show_bug.cgi?id=162891

Reviewed by Michael Catanzaro.

We are currently adding the HTTP body to the message in ResourceHandleSoup, but we could do it as part of the
ResourceRequest::updateSoupMessage() method, since the HTTP body is indeed part of the request. The code can be
also simplified, especially the handling of files, by using SharedBuffer that already mmaps the file when
possible, instead of using GMappedFile API.

* platform/SharedBuffer.h: Add createSoupBuffer() method.
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::createSoupMessageForHandleAndRequest):
(WebCore::milisecondsSinceRequest): Deleted.
(WebCore::ResourceHandle::didStartRequest): Deleted.
(WebCore::startingCallback): Deleted.
(WebCore::networkEventCallback): Deleted.
(WebCore::ResourceHandle::start): Deleted.
(WebCore::ResourceHandle::releaseForDownload): Deleted.
(WebCore::ResourceHandle::timeoutFired): Deleted.
* platform/network/soup/ResourceRequest.h:
* platform/network/soup/ResourceRequestSoup.cpp:
(WebCore::appendEncodedBlobItemToSoupMessageBody): Helper method to append the blob to the request message body.
(WebCore::ResourceRequest::updateSoupMessageBody): Add HTTPBody to the request message body.
(WebCore::ResourceRequest::updateSoupMessage): Call updateSoupMessageBody() to also update the body.
* platform/soup/SharedBufferSoup.cpp:
(WebCore::SharedBuffer::createSoupBuffer): Returns a new SoupBuffer for the SharedBuffer.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformSharedBufferh">trunk/Source/WebCore/platform/SharedBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupResourceHandleSoupcpp">trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupResourceRequesth">trunk/Source/WebCore/platform/network/soup/ResourceRequest.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupResourceRequestSoupcpp">trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformsoupSharedBufferSoupcpp">trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/ChangeLog        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-10-05  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [SOUP] Move request HTTP body handling to ResourceRequestSoup and simplify it
+        https://bugs.webkit.org/show_bug.cgi?id=162891
+
+        Reviewed by Michael Catanzaro.
+
+        We are currently adding the HTTP body to the message in ResourceHandleSoup, but we could do it as part of the
+        ResourceRequest::updateSoupMessage() method, since the HTTP body is indeed part of the request. The code can be
+        also simplified, especially the handling of files, by using SharedBuffer that already mmaps the file when
+        possible, instead of using GMappedFile API.
+
+        * platform/SharedBuffer.h: Add createSoupBuffer() method.
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::createSoupMessageForHandleAndRequest):
+        (WebCore::milisecondsSinceRequest): Deleted.
+        (WebCore::ResourceHandle::didStartRequest): Deleted.
+        (WebCore::startingCallback): Deleted.
+        (WebCore::networkEventCallback): Deleted.
+        (WebCore::ResourceHandle::start): Deleted.
+        (WebCore::ResourceHandle::releaseForDownload): Deleted.
+        (WebCore::ResourceHandle::timeoutFired): Deleted.
+        * platform/network/soup/ResourceRequest.h:
+        * platform/network/soup/ResourceRequestSoup.cpp:
+        (WebCore::appendEncodedBlobItemToSoupMessageBody): Helper method to append the blob to the request message body.
+        (WebCore::ResourceRequest::updateSoupMessageBody): Add HTTPBody to the request message body.
+        (WebCore::ResourceRequest::updateSoupMessage): Call updateSoupMessageBody() to also update the body.
+        * platform/soup/SharedBufferSoup.cpp:
+        (WebCore::SharedBuffer::createSoupBuffer): Returns a new SoupBuffer for the SharedBuffer.
+
</ins><span class="cx"> 2016-10-04  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement KeyboardEvent.code from the UI Event spec
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSharedBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SharedBuffer.h (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SharedBuffer.h        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/platform/SharedBuffer.h        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(SOUP)
</span><ins>+    GUniquePtr&lt;SoupBuffer&gt; createSoupBuffer(unsigned offset = 0, unsigned size = 0);
</ins><span class="cx">     static Ref&lt;SharedBuffer&gt; wrapSoupBuffer(SoupBuffer*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupResourceHandleSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -63,9 +63,6 @@
</span><span class="cx"> #include &lt;wtf/text/Base64.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> 
</span><del>-#include &quot;BlobData.h&quot;
-#include &quot;BlobRegistryImpl.h&quot;
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> static const size_t gDefaultReadBufferSize = 8192;
</span><span class="lines">@@ -614,96 +611,6 @@
</span><span class="cx">         G_PRIORITY_DEFAULT, d-&gt;m_cancellable.get(), readCallback, handle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool addFileToSoupMessageBody(SoupMessage* message, const String&amp; fileNameString, size_t offset, size_t lengthToSend, unsigned long&amp; totalBodySize)
-{
-    GUniqueOutPtr&lt;GError&gt; error;
-    CString fileName = fileSystemRepresentation(fileNameString);
-    GMappedFile* fileMapping = g_mapped_file_new(fileName.data(), false, &amp;error.outPtr());
-    if (error)
-        return false;
-
-    gsize bufferLength = lengthToSend;
-    if (!lengthToSend)
-        bufferLength = g_mapped_file_get_length(fileMapping);
-    totalBodySize += bufferLength;
-
-    SoupBuffer* soupBuffer = soup_buffer_new_with_owner(g_mapped_file_get_contents(fileMapping) + offset,
-                                                        bufferLength,
-                                                        fileMapping,
-                                                        reinterpret_cast&lt;GDestroyNotify&gt;(g_mapped_file_unref));
-    soup_message_body_append_buffer(message-&gt;request_body, soupBuffer);
-    soup_buffer_free(soupBuffer);
-    return true;
-}
-
-static bool blobIsOutOfDate(const BlobDataItem&amp; blobItem)
-{
-    ASSERT(blobItem.type() == BlobDataItem::Type::File);
-    if (!isValidFileTime(blobItem.file()-&gt;expectedModificationTime()))
-        return false;
-
-    time_t fileModificationTime;
-    if (!getFileModificationTime(blobItem.file()-&gt;path(), fileModificationTime))
-        return true;
-
-    return fileModificationTime != static_cast&lt;time_t&gt;(blobItem.file()-&gt;expectedModificationTime());
-}
-
-static void addEncodedBlobItemToSoupMessageBody(SoupMessage* message, const BlobDataItem&amp; blobItem, unsigned long&amp; totalBodySize)
-{
-    if (blobItem.type() == BlobDataItem::Type::Data) {
-        totalBodySize += blobItem.length();
-        soup_message_body_append(message-&gt;request_body, SOUP_MEMORY_TEMPORARY, blobItem.data().data()-&gt;data() + blobItem.offset(), blobItem.length());
-        return;
-    }
-
-    ASSERT(blobItem.type() == BlobDataItem::Type::File);
-    if (blobIsOutOfDate(blobItem))
-        return;
-
-    addFileToSoupMessageBody(message, blobItem.file()-&gt;path(), blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length(),  totalBodySize);
-}
-
-static void addEncodedBlobToSoupMessageBody(SoupMessage* message, const FormDataElement&amp; element, unsigned long&amp; totalBodySize)
-{
-    RefPtr&lt;BlobData&gt; blobData = static_cast&lt;BlobRegistryImpl&amp;&gt;(blobRegistry()).getBlobDataFromURL(URL(ParsedURLString, element.m_url));
-    if (!blobData)
-        return;
-
-    for (size_t i = 0; i &lt; blobData-&gt;items().size(); ++i)
-        addEncodedBlobItemToSoupMessageBody(message, blobData-&gt;items()[i], totalBodySize);
-}
-
-static bool addFormElementsToSoupMessage(SoupMessage* message, const char*, FormData* httpBody, unsigned long&amp; totalBodySize)
-{
-    soup_message_body_set_accumulate(message-&gt;request_body, FALSE);
-    size_t numElements = httpBody-&gt;elements().size();
-    for (size_t i = 0; i &lt; numElements; i++) {
-        const FormDataElement&amp; element = httpBody-&gt;elements()[i];
-
-        if (element.m_type == FormDataElement::Type::Data) {
-            totalBodySize += element.m_data.size();
-            soup_message_body_append(message-&gt;request_body, SOUP_MEMORY_TEMPORARY,
-                                     element.m_data.data(), element.m_data.size());
-            continue;
-        }
-
-        if (element.m_type == FormDataElement::Type::EncodedFile) {
-            if (!addFileToSoupMessageBody(message ,
-                                         element.m_filename,
-                                         0 /* offset */,
-                                         0 /* lengthToSend */,
-                                         totalBodySize))
-                return false;
-            continue;
-        }
-
-        ASSERT(element.m_type == FormDataElement::Type::EncodedBlob);
-        addEncodedBlobToSoupMessageBody(message, element, totalBodySize);
-    }
-    return true;
-}
-
</del><span class="cx"> #if ENABLE(WEB_TIMING)
</span><span class="cx"> static double milisecondsSinceRequest(double requestTime)
</span><span class="cx"> {
</span><span class="lines">@@ -788,6 +695,7 @@
</span><span class="cx"> 
</span><span class="cx">     SoupMessage* soupMessage = d-&gt;m_soupMessage.get();
</span><span class="cx">     request.updateSoupMessage(soupMessage);
</span><ins>+    d-&gt;m_bodySize = soupMessage-&gt;request_body-&gt;length;
</ins><span class="cx"> 
</span><span class="cx">     g_object_set_data(G_OBJECT(soupMessage), &quot;handle&quot;, handle);
</span><span class="cx">     if (!handle-&gt;shouldContentSniff())
</span><span class="lines">@@ -795,14 +703,6 @@
</span><span class="cx">     if (!d-&gt;m_useAuthenticationManager)
</span><span class="cx">         soup_message_disable_feature(soupMessage, SOUP_TYPE_AUTH_MANAGER);
</span><span class="cx"> 
</span><del>-    FormData* httpBody = request.httpBody();
-    CString contentType = request.httpContentType().utf8().data();
-    if (httpBody &amp;&amp; !httpBody-&gt;isEmpty() &amp;&amp; !addFormElementsToSoupMessage(soupMessage, contentType.data(), httpBody, d-&gt;m_bodySize)) {
-        // We failed to prepare the body data, so just fail this load.
-        d-&gt;m_soupMessage.clear();
-        return false;
-    }
-
</del><span class="cx">     // Make sure we have an Accept header for subresources; some sites
</span><span class="cx">     // want this to serve some of their subresources
</span><span class="cx">     if (!soup_message_headers_get_one(soupMessage-&gt;request_headers, &quot;Accept&quot;))
</span><span class="lines">@@ -812,8 +712,7 @@
</span><span class="cx">     // for consistency with other backends (e.g. Chromium's) and other UA implementations like FF. It's done
</span><span class="cx">     // in the backend here instead of in XHR code since in XHR CORS checking prevents us from this kind of
</span><span class="cx">     // late header manipulation.
</span><del>-    if ((request.httpMethod() == &quot;POST&quot; || request.httpMethod() == &quot;PUT&quot;)
-        &amp;&amp; (!request.httpBody() || request.httpBody()-&gt;isEmpty()))
</del><ins>+    if ((request.httpMethod() == &quot;POST&quot; || request.httpMethod() == &quot;PUT&quot;) &amp;&amp; !d-&gt;m_bodySize)
</ins><span class="cx">         soup_message_headers_set_content_length(soupMessage-&gt;request_headers, 0);
</span><span class="cx"> 
</span><span class="cx">     g_signal_connect(d-&gt;m_soupMessage.get(), &quot;notify::tls-errors&quot;, G_CALLBACK(tlsErrorsChangedCallback), handle);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupResourceRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequest.h (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/ResourceRequest.h        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequest.h        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -114,6 +114,7 @@
</span><span class="cx">         uint64_t m_initiatingPageID;
</span><span class="cx"> 
</span><span class="cx">         void updateSoupMessageMembers(SoupMessage*) const;
</span><ins>+        void updateSoupMessageBody(SoupMessage*) const;
</ins><span class="cx">         void doUpdatePlatformRequest() { }
</span><span class="cx">         void doUpdateResourceRequest() { }
</span><span class="cx">         void doUpdatePlatformHTTPBody() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupResourceRequestSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -20,12 +20,14 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if USE(SOUP)
</span><del>-
</del><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BlobData.h&quot;
+#include &quot;BlobRegistryImpl.h&quot;
</ins><span class="cx"> #include &quot;GUniquePtrSoup.h&quot;
</span><span class="cx"> #include &quot;HTTPParsers.h&quot;
</span><span class="cx"> #include &quot;MIMETypeRegistry.h&quot;
</span><ins>+#include &quot;SharedBuffer.h&quot;
</ins><span class="cx"> #include &quot;WebKitSoupRequestGeneric.h&quot;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -32,6 +34,66 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static uint64_t appendEncodedBlobItemToSoupMessageBody(SoupMessage* soupMessage, const BlobDataItem&amp; blobItem)
+{
+    switch (blobItem.type()) {
+    case BlobDataItem::Type::Data:
+        soup_message_body_append(soupMessage-&gt;request_body, SOUP_MEMORY_TEMPORARY, blobItem.data().data()-&gt;data() + blobItem.offset(), blobItem.length());
+        return blobItem.length();
+    case BlobDataItem::Type::File: {
+        if (!isValidFileTime(blobItem.file()-&gt;expectedModificationTime()))
+            return 0;
+
+        time_t fileModificationTime;
+        if (!getFileModificationTime(blobItem.file()-&gt;path(), fileModificationTime)
+            || fileModificationTime != static_cast&lt;time_t&gt;(blobItem.file()-&gt;expectedModificationTime()))
+            return 0;
+
+        if (RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::createWithContentsOfFile(blobItem.file()-&gt;path())) {
+            GUniquePtr&lt;SoupBuffer&gt; soupBuffer(buffer-&gt;createSoupBuffer(blobItem.offset(), blobItem.length() == BlobDataItem::toEndOfFile ? 0 : blobItem.length()));
+            soup_message_body_append_buffer(soupMessage-&gt;request_body, soupBuffer.get());
+            return soupBuffer-&gt;length;
+        }
+        break;
+    }
+    }
+
+    return 0;
+}
+
+void ResourceRequest::updateSoupMessageBody(SoupMessage* soupMessage) const
+{
+    auto* formData = httpBody();
+    if (!formData || formData-&gt;isEmpty())
+        return;
+
+    soup_message_body_set_accumulate(soupMessage-&gt;request_body, FALSE);
+    uint64_t bodySize = 0;
+    for (const auto&amp; element : formData-&gt;elements()) {
+        switch (element.m_type) {
+        case FormDataElement::Type::Data:
+            bodySize += element.m_data.size();
+            soup_message_body_append(soupMessage-&gt;request_body, SOUP_MEMORY_TEMPORARY, element.m_data.data(), element.m_data.size());
+            break;
+        case FormDataElement::Type::EncodedFile:
+            if (RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::createWithContentsOfFile(element.m_filename)) {
+                GUniquePtr&lt;SoupBuffer&gt; soupBuffer(buffer-&gt;createSoupBuffer());
+                bodySize += buffer-&gt;size();
+                soup_message_body_append_buffer(soupMessage-&gt;request_body, soupBuffer.get());
+            }
+            break;
+        case FormDataElement::Type::EncodedBlob:
+            if (auto* blobData = static_cast&lt;BlobRegistryImpl&amp;&gt;(blobRegistry()).getBlobDataFromURL(element.m_url)) {
+                for (const auto&amp; item : blobData-&gt;items())
+                    bodySize += appendEncodedBlobItemToSoupMessageBody(soupMessage, item);
+            }
+            break;
+        }
+    }
+
+    ASSERT(bodySize == static_cast&lt;uint64_t&gt;(soupMessage-&gt;request_body-&gt;length));
+}
+
</ins><span class="cx"> void ResourceRequest::updateSoupMessageMembers(SoupMessage* soupMessage) const
</span><span class="cx"> {
</span><span class="cx">     updateSoupMessageHeaders(soupMessage-&gt;request_headers);
</span><span class="lines">@@ -77,6 +139,7 @@
</span><span class="cx">     soup_message_set_uri(soupMessage, uri.get());
</span><span class="cx"> 
</span><span class="cx">     updateSoupMessageMembers(soupMessage);
</span><ins>+    updateSoupMessageBody(soupMessage);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceRequest::updateFromSoupMessage(SoupMessage* soupMessage)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformsoupSharedBufferSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp (206804 => 206805)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp        2016-10-05 06:16:15 UTC (rev 206804)
+++ trunk/Source/WebCore/platform/soup/SharedBufferSoup.cpp        2016-10-05 07:08:38 UTC (rev 206805)
</span><span class="lines">@@ -38,6 +38,20 @@
</span><span class="cx">     return adoptRef(*new SharedBuffer(soupBuffer));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GUniquePtr&lt;SoupBuffer&gt; SharedBuffer::createSoupBuffer(unsigned offset, unsigned size)
+{
+    if (m_soupBuffer &amp;&amp; !offset &amp;&amp; !size) {
+        GUniquePtr&lt;SoupBuffer&gt; buffer(soup_buffer_copy(m_soupBuffer.get()));
+        return buffer;
+    }
+
+    ref();
+    GUniquePtr&lt;SoupBuffer&gt; buffer(soup_buffer_new_with_owner(data() + offset, size ? size : this-&gt;size(), this, [](void* data) {
+        static_cast&lt;SharedBuffer*&gt;(data)-&gt;deref();
+    }));
+    return buffer;
+}
+
</ins><span class="cx"> void SharedBuffer::clearPlatformData()
</span><span class="cx"> {
</span><span class="cx">     m_soupBuffer.reset();
</span></span></pre>
</div>
</div>

</body>
</html>