Changeset 207405 in webkit
- Timestamp:
- Oct 17, 2016 3:52:02 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r207404 r207405 1 2016-10-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Downloads should always sniff contents 4 https://bugs.webkit.org/show_bug.cgi?id=163538 5 6 Reviewed by Michael Catanzaro. 7 8 It's quite common that downloads have weird filenames with no extension, so it would be better if the loader 9 sniff the contents to guess the mime type. 10 11 * NetworkProcess/Downloads/soup/DownloadSoup.cpp: 12 (WebKit::Download::startNetworkLoad): Pass true for shouldContentSniff parameter of ResourceHandle::create(). 13 1 14 2016-10-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 15 -
trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp
r206439 r207405 213 213 ASSERT(!m_resourceHandle); 214 214 m_downloadClient = std::make_unique<DownloadClient>(*this); 215 m_resourceHandle = ResourceHandle::create(0, m_request, m_downloadClient.get(), false, false);215 m_resourceHandle = ResourceHandle::create(0, m_request, m_downloadClient.get(), false, true); 216 216 didStart(); 217 217 } -
trunk/Tools/ChangeLog
r207399 r207405 1 2016-10-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Downloads should always sniff contents 4 https://bugs.webkit.org/show_bug.cgi?id=163538 5 6 Reviewed by Michael Catanzaro. 7 8 Add a test case to check that the MIME type is correctly guessed for downloads. 9 10 * TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp: 11 (writeNextChunk): 12 (serverCallback): 13 (testDownloadMIMEType): 14 (beforeAll): 15 (writeNextChunkIdle): Deleted. 16 1 17 2016-10-16 Daniel Bates <dabates@apple.com> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp
r185502 r207405 389 389 } 390 390 391 static gboolean writeNextChunkIdle(SoupMessage* message)392 {393 soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, "chunk", 5);394 return FALSE;395 }396 397 391 static void writeNextChunk(SoupMessage* message) 398 392 { 399 g_timeout_add(100, reinterpret_cast<GSourceFunc>(writeNextChunkIdle), message); 393 /* We need a big enough chunk for the sniffer to not block the load */ 394 static const char* chunk = "Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 395 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 396 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 397 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 398 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 399 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!" 400 "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"; 401 soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, chunk, strlen(chunk)); 400 402 } 401 403 … … 418 420 } 419 421 422 if (g_str_equal(path, "/unknown")) 423 path = "/test.pdf"; 424 420 425 GUniquePtr<char> filePath(g_build_filename(Test::getResourcesDir().data(), path, nullptr)); 421 426 char* contents; … … 611 616 g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); 612 617 test->cancelDownloadAndWaitUntilFinished(); 618 } 619 620 static void testDownloadMIMEType(DownloadTest* test, gconstpointer) 621 { 622 GRefPtr<WebKitDownload> download = adoptGRef(test->downloadURIAndWaitUntilFinishes(kServer->getURIForPath("/unknown"))); 623 g_assert(!webkit_download_get_web_view(download.get())); 624 625 Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; 626 g_assert_cmpint(events.size(), ==, 5); 627 g_assert_cmpint(events[0], ==, DownloadTest::Started); 628 g_assert_cmpint(events[1], ==, DownloadTest::ReceivedResponse); 629 g_assert_cmpint(events[2], ==, DownloadTest::CreatedDestination); 630 g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData); 631 g_assert_cmpint(events[4], ==, DownloadTest::Finished); 632 events.clear(); 633 634 WebKitURIRequest* request = webkit_download_get_request(download.get()); 635 WEBKIT_IS_URI_REQUEST(request); 636 ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/unknown")); 637 638 WebKitURIResponse* response = webkit_download_get_response(download.get()); 639 WEBKIT_IS_URI_RESPONSE(response); 640 g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "application/pdf"); 641 642 g_assert(webkit_download_get_destination(download.get())); 643 g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1); 644 test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename); 613 645 } 614 646 … … 626 658 WebViewDownloadTest::add("WebKitWebView", "download-uri", testWebViewDownloadURI); 627 659 PolicyResponseDownloadTest::add("Downloads", "policy-decision-download", testPolicyResponseDownload); 660 DownloadTest::add("Downloads", "mime-type", testDownloadMIMEType); 628 661 } 629 662
Note: See TracChangeset
for help on using the changeset viewer.