Title: [212286] trunk/Source/WebKit2
Revision
212286
Author
[email protected]
Date
2017-02-14 03:54:59 -0800 (Tue, 14 Feb 2017)

Log Message

[SOUP] Ensure a response MIME type when Content-Type is missing and sniffing not allowed
https://bugs.webkit.org/show_bug.cgi?id=168299

Reviewed by Sergio Villar Senin.

Sniffing is not allowed but we can try to guess the MIME using the response path, or at least fallback to
default MIME type instead of leaving an empty string. This matches what mac port does.

Fixes: http/tests/inspector/network/fetch-response-body.html
       http/tests/inspector/network/xhr-response-body.html

* NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::didSendRequest):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (212285 => 212286)


--- trunk/Source/WebKit2/ChangeLog	2017-02-14 11:30:46 UTC (rev 212285)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-14 11:54:59 UTC (rev 212286)
@@ -1,5 +1,21 @@
 2017-02-14  Carlos Garcia Campos  <[email protected]>
 
+        [SOUP] Ensure a response MIME type when Content-Type is missing and sniffing not allowed
+        https://bugs.webkit.org/show_bug.cgi?id=168299
+
+        Reviewed by Sergio Villar Senin.
+
+        Sniffing is not allowed but we can try to guess the MIME using the response path, or at least fallback to
+        default MIME type instead of leaving an empty string. This matches what mac port does.
+
+        Fixes: http/tests/inspector/network/fetch-response-body.html
+               http/tests/inspector/network/xhr-response-body.html
+
+        * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+        (WebKit::NetworkDataTaskSoup::didSendRequest):
+
+2017-02-14  Carlos Garcia Campos  <[email protected]>
+
         CookieManager only works with the default session
         https://bugs.webkit.org/show_bug.cgi?id=168229
 

Modified: trunk/Source/WebKit2/NetworkProcess/soup/NetworkDataTaskSoup.cpp (212285 => 212286)


--- trunk/Source/WebKit2/NetworkProcess/soup/NetworkDataTaskSoup.cpp	2017-02-14 11:30:46 UTC (rev 212285)
+++ trunk/Source/WebKit2/NetworkProcess/soup/NetworkDataTaskSoup.cpp	2017-02-14 11:54:59 UTC (rev 212286)
@@ -36,6 +36,7 @@
 #include "WebErrors.h"
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/HTTPParsers.h>
+#include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/SharedBuffer.h>
 #include <WebCore/SoupNetworkSession.h>
@@ -325,6 +326,8 @@
         if (m_shouldContentSniff == SniffContent && m_soupMessage->status_code != SOUP_STATUS_NOT_MODIFIED)
             m_response.setSniffedContentType(soup_request_get_content_type(m_soupRequest.get()));
         m_response.updateFromSoupMessage(m_soupMessage.get());
+        if (m_response.mimeType().isEmpty() && m_soupMessage->status_code != SOUP_STATUS_NOT_MODIFIED)
+            m_response.setMimeType(MIMETypeRegistry::getMIMETypeForPath(m_response.url().path()));
 
         if (shouldStartHTTPRedirection()) {
             m_inputStream = WTFMove(inputStream);
@@ -346,6 +349,8 @@
         m_response.setMimeType(extractMIMETypeFromMediaType(contentType));
         m_response.setTextEncodingName(extractCharsetFromMediaType(contentType));
         m_response.setExpectedContentLength(soup_request_get_content_length(m_soupRequest.get()));
+        if (m_response.mimeType().isEmpty())
+            m_response.setMimeType(MIMETypeRegistry::getMIMETypeForPath(m_response.url().path()));
 
         m_inputStream = WTFMove(inputStream);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to