<rdar://problem/12886312> Cannot upload patches to Bugzilla (<input type...
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2012 01:31:00 +0000 (01:31 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2012 01:31:00 +0000 (01:31 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=105120

        Reviewed by Sam Weinig.

        Serialize HTTP body. ResourceRequest serialization cannot (and shouldn't) know about
        body streams, as used with files.

        * Shared/Network/NetworkResourceLoadParameters.cpp:
        (WebKit::NetworkResourceLoadParameters::encode):
        (WebKit::NetworkResourceLoadParameters::decode):
        * Shared/WebCoreArgumentCoders.cpp:
        (CoreIPC::::encode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137825 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/FormData.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

index 864f06f..417379b 100644 (file)
@@ -1,3 +1,20 @@
+2012-12-15  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/12886312> Cannot upload patches to Bugzilla (<input type=file> doesn't work)
+        https://bugs.webkit.org/show_bug.cgi?id=105120
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in:
+        * history/HistoryItem.cpp:
+        * platform/network/FormData.h:
+        Renamed encodeForBackForward and decodeForBackForward to encode and decode, respectively.
+        I couldn't find anything in these that would limit them to this use, and data encoded
+        for b/f has to be good enough to re-create a request anyway.
+
+        * platform/network/FormData.cpp: (WebCore::decode): Fixed file data decoder to not
+        bail out in the general case of posting a complete file.
+
 2012-12-15  Nima Ghanavatian  <nghanavatian@rim.com>
 
         [BlackBerry] Pass key modifiers with touch and mouse events
index 11d5205..0dc308d 100644 (file)
@@ -934,6 +934,7 @@ __ZN7WebCore8Document26pageSizeAndMarginsInPixelsEiRNS_7IntSizeERiS3_S3_S3_
 __ZN7WebCore8Document27removeMediaCanStartListenerEPNS_21MediaCanStartListenerE
 __ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsEv
 __ZN7WebCore8Document4headEv
+__ZN7WebCore8FormData6decodeERN3WTF7DecoderE
 __ZN7WebCore8Document8iconURLsEv
 __ZN7WebCore8FormData6createEPKvm
 __ZN7WebCore8FormDataD1Ev
@@ -1310,6 +1311,7 @@ __ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
 __ZNK7WebCore19ResourceRequestBase3urlEv
 __ZNK7WebCore19ResourceRequestBase6isNullEv
 __ZNK7WebCore19ResourceRequestBase7isEmptyEv
+__ZNK7WebCore19ResourceRequestBase8httpBodyEv
 __ZNK7WebCore20CachedResourceLoader11isPreloadedERKN3WTF6StringE
 __ZNK7WebCore20HTMLTableCellElement9cellAboveEv
 __ZNK7WebCore20ResourceResponseBase14httpStatusCodeEv
@@ -1449,6 +1451,7 @@ __ZNK7WebCore8Document4bodyEv
 __ZNK7WebCore8Document4pageEv
 __ZNK7WebCore8Document4viewEv
 __ZNK7WebCore8Document6domainEv
+__ZNK7WebCore8FormData6encodeERN3WTF7EncoderE
 __ZNK7WebCore8Document6loaderEv
 __ZNK7WebCore8Document8settingsEv
 __ZNK7WebCore8IntPointcv7CGPointEv
index a8f374e..049ce5a 100644 (file)
@@ -703,7 +703,7 @@ void HistoryItem::encodeBackForwardTreeNode(Encoder& encoder) const
 
     encoder.encodeBool(m_formData);
     if (m_formData)
-        m_formData->encodeForBackForward(encoder);
+        m_formData->encode(encoder);
 
     encoder.encodeInt64(m_itemSequenceNumber);
 
@@ -801,7 +801,7 @@ resume:
     if (!decoder.decodeBool(hasFormData))
         return 0;
     if (hasFormData) {
-        node->m_formData = FormData::decodeForBackForward(decoder);
+        node->m_formData = FormData::decode(decoder);
         if (!node->m_formData)
             return 0;
     }
index 33edcf4..694b2d3 100644 (file)
@@ -503,7 +503,7 @@ static bool decode(Decoder& decoder, FormDataElement& element)
         int64_t fileLength;
         if (!decoder.decodeInt64(fileLength))
             return false;
-        if (fileLength < fileStart)
+        if (fileLength != BlobDataItem::toEndOfFile && fileLength < fileStart)
             return false;
         double expectedFileModificationTime;
         if (!decoder.decodeDouble(expectedFileModificationTime))
@@ -539,7 +539,7 @@ static bool decode(Decoder& decoder, FormDataElement& element)
     return false;
 }
 
-void FormData::encodeForBackForward(Encoder& encoder) const
+void FormData::encode(Encoder& encoder) const
 {
     encoder.encodeBool(m_alwaysStream);
 
@@ -555,7 +555,7 @@ void FormData::encodeForBackForward(Encoder& encoder) const
     encoder.encodeInt64(m_identifier);
 }
 
-PassRefPtr<FormData> FormData::decodeForBackForward(Decoder& decoder)
+PassRefPtr<FormData> FormData::decode(Decoder& decoder)
 {
     RefPtr<FormData> data = FormData::create();
 
index 12ca78a..00a001e 100644 (file)
@@ -117,8 +117,8 @@ public:
     PassRefPtr<FormData> deepCopy() const;
     ~FormData();
 
-    void encodeForBackForward(Encoder&) const;
-    static PassRefPtr<FormData> decodeForBackForward(Decoder&);
+    void encode(Encoder&) const;
+    static PassRefPtr<FormData> decode(Decoder&);
 
     void appendData(const void* data, size_t);
     void appendFile(const String& filePath, bool shouldGenerateFile = false);
index 8e1bd38..43f321a 100644 (file)
@@ -1,3 +1,19 @@
+2012-12-15  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/12886312> Cannot upload patches to Bugzilla (<input type=file> doesn't work)
+        https://bugs.webkit.org/show_bug.cgi?id=105120
+
+        Reviewed by Sam Weinig.
+
+        Serialize HTTP body. ResourceRequest serialization cannot (and shouldn't) know about
+        body streams, as used with files.
+
+        * Shared/Network/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode):
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (CoreIPC::::encode):
+
 2012-12-15  Anders Carlsson  <andersca@apple.com>
 
         Handle downloads in the network process
index edf87bc..aa7a31f 100644 (file)
@@ -27,6 +27,9 @@
 #include "NetworkResourceLoadParameters.h"
 
 #include "ArgumentCoders.h"
+#include "DataReference.h"
+#include "DecoderAdapter.h"
+#include "EncoderAdapter.h"
 #include "WebCoreArgumentCoders.h"
 
 #if ENABLE(NETWORK_PROCESS)
@@ -54,6 +57,14 @@ NetworkResourceLoadParameters::NetworkResourceLoadParameters(const ResourceReque
 void NetworkResourceLoadParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
 {
     encoder.encode(m_request);
+
+    encoder.encode(static_cast<bool>(m_request.httpBody()));
+    if (m_request.httpBody()) {
+        EncoderAdapter httpBodyEncoderAdapter;
+        m_request.httpBody()->encode(httpBodyEncoderAdapter);
+        encoder.encode(httpBodyEncoderAdapter.dataReference());
+    }
+
     encoder.encodeEnum(m_priority);
     encoder.encodeEnum(m_contentSniffingPolicy);
     encoder.encodeEnum(m_allowStoredCredentials);
@@ -64,6 +75,19 @@ bool NetworkResourceLoadParameters::decode(CoreIPC::ArgumentDecoder* decoder, Ne
 {
     if (!decoder->decode(result.m_request))
         return false;
+
+    bool hasHTTPBody;
+    if (!decoder->decode(hasHTTPBody))
+        return false;
+
+    if (hasHTTPBody) {
+        CoreIPC::DataReference formData;
+        if (!decoder->decode(formData))
+            return false;
+        DecoderAdapter httpBodyDecoderAdapter(formData.data(), formData.size());
+        result.m_request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));
+    }
+
     if (!decoder->decodeEnum(result.m_priority))
         return false;
     if (!decoder->decodeEnum(result.m_contentSniffingPolicy))
index 12f387e..058a74f 100644 (file)
@@ -380,6 +380,9 @@ void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const Reso
         encoder << resourceRequest.httpMethod();
         encoder << resourceRequest.httpHeaderFields();
 
+        // FIXME: Do not encode HTTP message body.
+        // 1. It can be large and thus costly to send across.
+        // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
         FormData* httpBody = resourceRequest.httpBody();
         encoder << static_cast<bool>(httpBody);
         if (httpBody)