Skip to content
Permalink
Browse files
[curl] Improve multipart response handling
https://bugs.webkit.org/show_bug.cgi?id=117735

Reviewed by Brent Fulgham.

The multipart/x-mixed-replace mime type in responses are ignored
with the curl network backend. To handle such responses the
MultipartHandle is introduced which will split the content using
the boundary specified by the mime type.

There are already existing tests (http/tests/multipart).

* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPHeader):
* platform/network/HTTPParsers.h:
* platform/network/ResourceHandleInternal.h:
* platform/network/curl/MultipartHandle.cpp: Added.
(WebCore::MultipartHandle::extractBoundary):
(WebCore::MultipartHandle::matchForBoundary):
(WebCore::MultipartHandle::checkForBoundary):
(WebCore::MultipartHandle::parseHeadersIfPossible):
(WebCore::MultipartHandle::contentReceived):
(WebCore::MultipartHandle::processContent):
(WebCore::MultipartHandle::contentEnded):
(WebCore::MultipartHandle::didReceiveData):
(WebCore::MultipartHandle::didReceiveResponse):
* platform/network/curl/MultipartHandle.h: Added.
(WebCore::MultipartHandle::MultipartHandle):
(WebCore::MultipartHandle::~MultipartHandle):
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::writeCallback):
(WebCore::headerCallback):
(WebCore::ResourceHandleManager::downloadTimerCallback):


Canonical link: https://commits.webkit.org/139190@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
elecro committed Sep 12, 2013
1 parent 99150f1 commit fdbe6ce53372888ef082a114e4692933ac659f02
Showing 9 changed files with 530 additions and 7 deletions.
@@ -1,3 +1,41 @@
2013-09-12 Peter Gal <galpeter@inf.u-szeged.hu>

[curl] Improve multipart response handling
https://bugs.webkit.org/show_bug.cgi?id=117735

Reviewed by Brent Fulgham.

The multipart/x-mixed-replace mime type in responses are ignored
with the curl network backend. To handle such responses the
MultipartHandle is introduced which will split the content using
the boundary specified by the mime type.

There are already existing tests (http/tests/multipart).

* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* platform/network/HTTPParsers.cpp:
(WebCore::parseHTTPHeader):
* platform/network/HTTPParsers.h:
* platform/network/ResourceHandleInternal.h:
* platform/network/curl/MultipartHandle.cpp: Added.
(WebCore::MultipartHandle::extractBoundary):
(WebCore::MultipartHandle::matchForBoundary):
(WebCore::MultipartHandle::checkForBoundary):
(WebCore::MultipartHandle::parseHeadersIfPossible):
(WebCore::MultipartHandle::contentReceived):
(WebCore::MultipartHandle::processContent):
(WebCore::MultipartHandle::contentEnded):
(WebCore::MultipartHandle::didReceiveData):
(WebCore::MultipartHandle::didReceiveResponse):
* platform/network/curl/MultipartHandle.h: Added.
(WebCore::MultipartHandle::MultipartHandle):
(WebCore::MultipartHandle::~MultipartHandle):
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::writeCallback):
(WebCore::headerCallback):
(WebCore::ResourceHandleManager::downloadTimerCallback):

2013-09-12 Andreas Kling <akling@apple.com>

Remove RenderApplet.
@@ -8310,6 +8310,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\platform\network\curl\MultipartHandle.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\platform\network\curl\ProxyServerCurl.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -19679,6 +19685,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</CustomBuildStep>
<CustomBuildStep Include="..\platform\network\curl\MultipartHandle.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</CustomBuildStep>
<CustomBuildStep Include="..\platform\network\curl\ResourceError.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1968,6 +1968,9 @@
<ClCompile Include="..\platform\network\curl\FormDataStreamCurl.cpp">
<Filter>platform\network\curl</Filter>
</ClCompile>
<ClCompile Include="..\platform\network\curl\MultipartHandle.cpp">
<Filter>platform\network\curl</Filter>
</ClCompile>
<ClCompile Include="..\platform\network\curl\ProxyServerCurl.cpp">
<Filter>platform\network\curl</Filter>
</ClCompile>
@@ -15795,6 +15798,9 @@
<CustomBuildStep Include="..\platform\network\curl\FormDataStreamCurl.h">
<Filter>platform\network\curl</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\platform\network\curl\MultipartHandle.h">
<Filter>platform\network\curl</Filter>
</CustomBuildStep>
<CustomBuildStep Include="..\platform\network\curl\ResourceError.h">
<Filter>platform\network\curl</Filter>
</CustomBuildStep>
@@ -605,7 +605,7 @@ size_t parseHTTPRequestLine(const char* data, size_t length, String& failureReas
return end - data;
}

size_t parseHTTPHeader(const char* start, size_t length, String& failureReason, AtomicString& nameStr, String& valueStr)
size_t parseHTTPHeader(const char* start, size_t length, String& failureReason, AtomicString& nameStr, String& valueStr, bool strict)
{
const char* p = start;
const char* end = start + length;
@@ -648,17 +648,20 @@ size_t parseHTTPHeader(const char* start, size_t length, String& failureReason,
case '\r':
break;
case '\n':
failureReason = "Unexpected LF in value at " + trimInputSample(value.data(), value.size());
return 0;
if (strict) {
failureReason = "Unexpected LF in value at " + trimInputSample(value.data(), value.size());
return 0;
}
break;
default:
value.append(*p);
}
if (*p == '\r') {
if (*p == '\r' || (!strict && *p == '\n')) {
++p;
break;
}
}
if (p >= end || *p != '\n') {
if (p >= end || (strict && *p != '\n')) {
failureReason = "CR doesn't follow LF after value at " + trimInputSample(p, end - p);
return 0;
}
@@ -86,7 +86,7 @@ ContentTypeOptionsDisposition parseContentTypeOptionsHeader(const String& header
// Parsing Complete HTTP Messages.
enum HTTPVersion { Unknown, HTTP_1_0, HTTP_1_1 };
size_t parseHTTPRequestLine(const char* data, size_t length, String& failureReason, String& method, String& url, HTTPVersion&);
size_t parseHTTPHeader(const char* data, size_t length, String& failureReason, AtomicString& nameStr, String& valueStr);
size_t parseHTTPHeader(const char* data, size_t length, String& failureReason, AtomicString& nameStr, String& valueStr, bool strict = true);
size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned char>& body);

}
@@ -44,6 +44,7 @@
#if USE(CURL)
#include <curl/curl.h>
#include "FormDataStreamCurl.h"
#include "MultipartHandle.h"
#endif

#if USE(SOUP)
@@ -190,6 +191,8 @@ namespace WebCore {

FormDataStream m_formDataStream;
Vector<char> m_postBytes;

OwnPtr<MultipartHandle> m_multipartHandle;
#endif
#if USE(SOUP)
GRefPtr<SoupMessage> m_soupMessage;

0 comments on commit fdbe6ce

Please sign in to comment.