https://bugs.webkit.org/show_bug.cgi?id=115354
Patch by Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> on 2013-08-07
Reviewed by Philippe Normand.
The default value for the HTTP "Accept-Encoding:" header field in the request allows
compressed data to be received on requests.
While this works fine for most cases, it can break the webkit source that needs to rely on the
the proper data size when receiving the response (even though the received data is already
uncompressed the size reported in ResourceResponse::expectedContentLength() is the same
represented by the HTTP header field "Content-Length" which is the size of the compressed data).
This patch disables the HTTP "Accept-Encoding:" header field when using the request
as we don't want the received response to be encoded in any way, as we need to rely on the proper
size of the returned data on ResourceHandle::didReceiveResponse().
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcStart):
* platform/network/soup/ResourceRequest.h:
(ResourceRequestBase):
(WebCore::ResourceRequest::acceptEncoding):
(WebCore::ResourceRequest::setAcceptEncoding):
(WebCore::ResourceRequest::ResourceRequestBase):
* platform/network/soup/ResourceRequestSoup.cpp:
(WebCore::ResourceRequest::updateSoupMessage):
(WebCore::ResourceRequest::toSoupMessage):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153795
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-08-07 Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk>
+
+ Disable HTTP request "Accept-Encoding:" header field on gstreamer source element to avoid receiving the wrong size when retrieving data
+ https://bugs.webkit.org/show_bug.cgi?id=115354
+
+ Reviewed by Philippe Normand.
+
+ The default value for the HTTP "Accept-Encoding:" header field in the request allows
+ compressed data to be received on requests.
+ While this works fine for most cases, it can break the webkit source that needs to rely on the
+ the proper data size when receiving the response (even though the received data is already
+ uncompressed the size reported in ResourceResponse::expectedContentLength() is the same
+ represented by the HTTP header field "Content-Length" which is the size of the compressed data).
+
+ This patch disables the HTTP "Accept-Encoding:" header field when using the request
+ as we don't want the received response to be encoded in any way, as we need to rely on the proper
+ size of the returned data on ResourceHandle::didReceiveResponse().
+
+ * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+ (webKitWebSrcStart):
+ * platform/network/soup/ResourceRequest.h:
+ (ResourceRequestBase):
+ (WebCore::ResourceRequest::acceptEncoding):
+ (WebCore::ResourceRequest::setAcceptEncoding):
+ (WebCore::ResourceRequest::ResourceRequestBase):
+ * platform/network/soup/ResourceRequestSoup.cpp:
+ (WebCore::ResourceRequest::updateSoupMessage):
+ (WebCore::ResourceRequest::toSoupMessage):
+
2013-08-07 Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt] REGRESSION(r) Two pixel result fail after r153522
request.setAllowCookies(true);
request.setHTTPReferrer(priv->player->referrer());
+#if USE(SOUP)
+ // Let's disable HTTP Accept-Encoding here as we don't want the received response to be
+ // encoded in any way as we need to rely on the proper size of the returned data on
+ // didReceiveResponse.
+ // If Accept-Encoding is used, the server may send the data in encoded format and
+ // request.expectedContentLength() will have the "wrong" size (the size of the
+ // compressed data), even though the data received in didReceiveData is uncompressed.
+ request.setAcceptEncoding(false);
+#endif
+
// Let Apple web servers know we want to access their nice movie trailers.
if (!g_ascii_strcasecmp("movies.apple.com", url.host().utf8().data())
|| !g_ascii_strcasecmp("trailers.apple.com", url.host().utf8().data()))
public:
ResourceRequest(const String& url)
: ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy)
+ , m_acceptEncoding(true)
, m_soupFlags(static_cast<SoupMessageFlags>(0))
{
}
ResourceRequest(const KURL& url)
: ResourceRequestBase(url, UseProtocolCachePolicy)
+ , m_acceptEncoding(true)
, m_soupFlags(static_cast<SoupMessageFlags>(0))
{
}
ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
: ResourceRequestBase(url, policy)
+ , m_acceptEncoding(true)
, m_soupFlags(static_cast<SoupMessageFlags>(0))
{
setHTTPReferrer(referrer);
ResourceRequest()
: ResourceRequestBase(KURL(), UseProtocolCachePolicy)
+ , m_acceptEncoding(true)
, m_soupFlags(static_cast<SoupMessageFlags>(0))
{
}
ResourceRequest(SoupMessage* soupMessage)
: ResourceRequestBase(KURL(), UseProtocolCachePolicy)
+ , m_acceptEncoding(true)
, m_soupFlags(static_cast<SoupMessageFlags>(0))
{
updateFromSoupMessage(soupMessage);
void updateFromDelegatePreservingOldHTTPBody(const ResourceRequest& delegateProvidedRequest) { *this = delegateProvidedRequest; }
+ bool acceptEncoding() const { return m_acceptEncoding; }
+ void setAcceptEncoding(bool acceptEncoding) { m_acceptEncoding = acceptEncoding; }
+
void updateSoupMessageHeaders(SoupMessageHeaders*) const;
void updateFromSoupMessageHeaders(SoupMessageHeaders*);
void updateSoupMessage(SoupMessage*) const;
private:
friend class ResourceRequestBase;
+ bool m_acceptEncoding : 1;
SoupMessageFlags m_soupFlags;
void doUpdatePlatformRequest() { }
}
soup_message_set_flags(soupMessage, m_soupFlags);
+
+ if (!acceptEncoding())
+ soup_message_disable_feature(soupMessage, SOUP_TYPE_CONTENT_DECODER);
}
SoupMessage* ResourceRequest::toSoupMessage() const