WebKit Bugzilla
Attachment 339107 Details for
Bug 174730
: [GTK] Epiphany (GNOME Web) says "Error downloading: Service Unavailable." when trying to download an image from discogs.com
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wk2-downloads-user-agent.diff (text/plain), 10.07 KB, created by
Carlos Garcia Campos
on 2018-04-30 02:08:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2018-04-30 02:08:31 PDT
Size:
10.07 KB
patch
obsolete
>diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 2ca3cdf1450..3632c697a06 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2018-04-30 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK] Epiphany (GNOME Web) says "Error downloading: Service Unavailable." when trying to download an image from discogs.com >+ https://bugs.webkit.org/show_bug.cgi?id=174730 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The problem is that we don't send any User-Agent HTTP header for downloads started by WebProcessPool::download(). >+ >+ * UIProcess/API/glib/WebKitDownload.cpp: >+ (webkitDownloadUpdateRequest): Helper to update the cached request. >+ (webkitDownloadStarted): Updated the cached request if we have one. >+ (webkit_download_get_request): Use webkitDownloadUpdateRequest(). >+ * UIProcess/API/glib/WebKitDownloadClient.cpp: >+ * UIProcess/API/glib/WebKitDownloadPrivate.h: >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::download): Set the User-Agent HTTP header if there isn't any. >+ > 2018-04-28 Andy Estes <aestes@apple.com> > > [iOS] Present an action sheet when long-pressing on PDF links >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp b/Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp >index b82b856fbf7..a75a8c02059 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp >@@ -323,6 +323,18 @@ WebKitDownload* webkitDownloadCreate(DownloadProxy* downloadProxy) > return download; > } > >+static void webkitDownloadUpdateRequest(WebKitDownload* download) >+{ >+ download->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(download->priv->download->request())); >+} >+ >+void webkitDownloadStarted(WebKitDownload* download) >+{ >+ // Update with the final request if needed. >+ if (download->priv->request) >+ webkitDownloadUpdateRequest(download); >+} >+ > void webkitDownloadSetResponse(WebKitDownload* download, WebKitURIResponse* response) > { > download->priv->response = response; >@@ -436,11 +448,11 @@ void webkitDownloadDestinationCreated(WebKitDownload* download, const String& de > */ > WebKitURIRequest* webkit_download_get_request(WebKitDownload* download) > { >- g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); >+ g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), nullptr); > > WebKitDownloadPrivate* priv = download->priv; > if (!priv->request) >- priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(priv->download->request())); >+ webkitDownloadUpdateRequest(download); > return priv->request.get(); > } > >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp b/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >index 7f2d5eb9d35..ead4f234991 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >@@ -43,6 +43,7 @@ private: > void didStart(WebProcessPool&, DownloadProxy& downloadProxy) override > { > GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy); >+ webkitDownloadStarted(download.get()); > webkitWebContextDownloadStarted(m_webContext, download.get()); > } > >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitDownloadPrivate.h b/Source/WebKit/UIProcess/API/glib/WebKitDownloadPrivate.h >index aa526966b43..42fafd144ee 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitDownloadPrivate.h >+++ b/Source/WebKit/UIProcess/API/glib/WebKitDownloadPrivate.h >@@ -24,6 +24,7 @@ > #include <WebCore/ResourceRequest.h> > > WebKitDownload* webkitDownloadCreate(WebKit::DownloadProxy*); >+void webkitDownloadStarted(WebKitDownload*); > bool webkitDownloadIsCancelled(WebKitDownload*); > void webkitDownloadSetResponse(WebKitDownload*, WebKitURIResponse*); > void webkitDownloadSetWebView(WebKitDownload*, WebKitWebView*); >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index ca548be1dfa..f51f3395acd 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -1213,9 +1213,13 @@ DownloadProxy* WebProcessPool::download(WebPageProxy* initiatingPage, const Reso > URL initiatingPageURL = URL { URL { }, initiatingPage->pageLoadState().url() }; > updatedRequest.setFirstPartyForCookies(initiatingPageURL); > updatedRequest.setIsSameSite(registrableDomainsAreEqual(initiatingPageURL, request.url())); >+ if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent)) >+ updatedRequest.setHTTPUserAgent(initiatingPage->userAgent()); > } else { > updatedRequest.setFirstPartyForCookies(URL()); > updatedRequest.setIsSameSite(false); >+ if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent)) >+ updatedRequest.setHTTPUserAgent(WebPageProxy::standardUserAgent()); > } > updatedRequest.setIsTopSite(false); > networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy->downloadID(), updatedRequest, suggestedFilename), 0); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5f79440757d..6d5d5530e3e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,20 @@ >+2018-04-30 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK] Epiphany (GNOME Web) says "Error downloading: Service Unavailable." when trying to download an image from discogs.com >+ https://bugs.webkit.org/show_bug.cgi?id=174730 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update unit tests to check that User-Agent header is included in HTTP download requests. >+ >+ * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp: >+ (testDownloadRemoteFile): >+ (testWebViewDownloadURI): >+ (testPolicyResponseDownload): >+ (testPolicyResponseDownloadCancel): >+ (testDownloadMIMEType): >+ (testContextMenuDownloadActions): >+ > 2018-04-28 Sihui Liu <sihui_liu@apple.com> > > [Cocoa] Set HTTPOnly flag when converting Cookie to NSHTTPCookie >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >index 62679a6d50d..53fd42aeada 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >@@ -453,6 +453,9 @@ static void testDownloadRemoteFile(DownloadTest* test, gconstpointer) > g_assert(request); > ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf")); > >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); >+ > g_assert(webkit_download_get_destination(download.get())); > g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1); > GUniquePtr<char> expectedFilename(g_strdup_printf("%s.pdf", kServerSuggestedFilename)); >@@ -566,6 +569,13 @@ static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer) > test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); > test->waitUntilDownloadStarted(); > g_assert(test->m_webView == webkit_download_get_web_view(download.get())); >+ >+ WebKitURIRequest* request = webkit_download_get_request(download.get()); >+ g_assert(request); >+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf")); >+ >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); > test->waitUntilDownloadFinished(); > > GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download.get()))); >@@ -619,6 +629,9 @@ static void testPolicyResponseDownload(PolicyResponseDownloadTest* test, gconstp > ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI); > > g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); >+ >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); > test->waitUntilDownloadFinished(); > > GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(test->m_download.get()))); >@@ -638,6 +651,9 @@ static void testPolicyResponseDownloadCancel(PolicyResponseDownloadTest* test, g > ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, requestURI); > > g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); >+ >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); > test->cancelDownloadAndWaitUntilFinished(); > } > >@@ -659,6 +675,9 @@ static void testDownloadMIMEType(DownloadTest* test, gconstpointer) > WEBKIT_IS_URI_REQUEST(request); > ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/unknown")); > >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); >+ > WebKitURIResponse* response = webkit_download_get_response(download.get()); > WEBKIT_IS_URI_RESPONSE(response); > g_assert_cmpstr(webkit_uri_response_get_mime_type(response), ==, "application/pdf"); >@@ -718,6 +737,14 @@ static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpoin > test->waitUntilDownloadStarted(); > > g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); >+ >+ WebKitURIRequest* request = webkit_download_get_request(test->m_download.get()); >+ WEBKIT_IS_URI_REQUEST(request); >+ ASSERT_CMP_CSTRING(webkit_uri_request_get_uri(request), ==, kServer->getURIForPath("/test.pdf")); >+ >+ auto headers = webkit_uri_request_get_http_headers(request); >+ g_assert_nonnull(soup_message_headers_get_one(headers, "User-Agent")); >+ > test->waitUntilDownloadFinished(); > > GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(test->m_download.get())));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 174730
:
339107
|
339109