- Revision
- 100769
- Author
- [email protected]
- Date
- 2011-11-18 06:45:57 -0800 (Fri, 18 Nov 2011)
Log Message
[GTK] Downloads not started by WebView only fail for transport errors
https://bugs.webkit.org/show_bug.cgi?id=72718
Reviewed by Martin Robinson.
Source/WebKit/gtk:
Abort the download with an error if the response contains an
error code. It adds a new test case to the download unit tests.
* tests/testdownload.c:
(notifyDownloadStatusCallback):
(serverCallback):
(test_webkit_download_not_found):
(main):
* webkit/webkitdownload.cpp:
(DownloadClient::didReceiveResponse): Check whether http status of
the response is an error code and emit error signal in such case.
Source/WebKit2:
* WebProcess/Downloads/soup/DownloadSoup.cpp:
(WebKit::DownloadClient::didReceiveResponse): Check if the http
status of the response is an error code and finish the download
with an error in such case.
Modified Paths
Diff
Modified: trunk/Source/WebKit/gtk/ChangeLog (100768 => 100769)
--- trunk/Source/WebKit/gtk/ChangeLog 2011-11-18 14:43:10 UTC (rev 100768)
+++ trunk/Source/WebKit/gtk/ChangeLog 2011-11-18 14:45:57 UTC (rev 100769)
@@ -1,3 +1,22 @@
+2011-11-18 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Downloads not started by WebView only fail for transport errors
+ https://bugs.webkit.org/show_bug.cgi?id=72718
+
+ Reviewed by Martin Robinson.
+
+ Abort the download with an error if the response contains an
+ error code. It adds a new test case to the download unit tests.
+
+ * tests/testdownload.c:
+ (notifyDownloadStatusCallback):
+ (serverCallback):
+ (test_webkit_download_not_found):
+ (main):
+ * webkit/webkitdownload.cpp:
+ (DownloadClient::didReceiveResponse): Check whether http status of
+ the response is an error code and emit error signal in such case.
+
2011-11-18 Mario Sanchez Prada <[email protected]>
[GTK] Accessibility API tests failing because of using non-WebKit GtkWidgets
Modified: trunk/Source/WebKit/gtk/tests/testdownload.c (100768 => 100769)
--- trunk/Source/WebKit/gtk/tests/testdownload.c 2011-11-18 14:43:10 UTC (rev 100768)
+++ trunk/Source/WebKit/gtk/tests/testdownload.c 2011-11-18 14:45:57 UTC (rev 100769)
@@ -248,6 +248,67 @@
g_object_unref(webView);
}
+static void notifyDownloadStatusCallback(GObject *object, GParamSpec *pspec, gpointer data)
+{
+ WebKitDownload *download = WEBKIT_DOWNLOAD(object);
+ WebKitNetworkResponse *response = webkit_download_get_network_response(download);
+ SoupMessage *message = webkit_network_response_get_message(response);
+
+ switch (webkit_download_get_status(download)) {
+ case WEBKIT_DOWNLOAD_STATUS_ERROR:
+ g_assert_cmpint(message->status_code, ==, 404);
+ g_main_loop_quit(loop);
+ break;
+ case WEBKIT_DOWNLOAD_STATUS_FINISHED:
+ case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
+ g_assert_not_reached();
+ break;
+ default:
+ break;
+ }
+}
+
+static void serverCallback(SoupServer *server, SoupMessage *message, const char *path, GHashTable *query, SoupClientContext *context, gpointer userData)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+ soup_message_body_complete(message->response_body);
+}
+
+static void test_webkit_download_not_found(void)
+{
+ SoupServer *server = soup_server_new(SOUP_SERVER_PORT, 0, NULL);
+ soup_server_run_async(server);
+ soup_server_add_handler(server, NULL, serverCallback, NULL, NULL);
+ SoupURI *baseURI = soup_uri_new("http://127.0.0.1/");
+ soup_uri_set_port(baseURI, soup_server_get_port(server));
+
+ SoupURI *uri = soup_uri_new_with_base(baseURI, "/foo");
+ char *uriString = soup_uri_to_string(uri, FALSE);
+ soup_uri_free(uri);
+
+ loop = g_main_loop_new(NULL, TRUE);
+ WebKitNetworkRequest *request = webkit_network_request_new(uriString);
+ g_free (uriString);
+ WebKitDownload *download = webkit_download_new(request);
+ g_object_unref(request);
+
+ webkit_download_set_destination_uri(download, "file:///tmp/foo");
+ g_signal_connect(download, "notify::status", G_CALLBACK(notifyDownloadStatusCallback), NULL);
+
+ webkit_download_start(download);
+ g_main_loop_run(loop);
+
+ g_object_unref(download);
+ g_main_loop_unref(loop);
+ soup_uri_free(baseURI);
+ g_object_unref(server);
+}
+
int main(int argc, char** argv)
{
gtk_test_init(&argc, &argv, NULL);
@@ -257,6 +318,7 @@
g_test_add_func("/webkit/download/synch", test_webkit_download_synch);
g_test_add_func("/webkit/download/asynch", test_webkit_download_asynch);
g_test_add_func("/webkit/download/data", test_webkit_download_data);
+ g_test_add_func("/webkit/download/not-found", test_webkit_download_not_found);
return g_test_run ();
}
Modified: trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp (100768 => 100769)
--- trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp 2011-11-18 14:43:10 UTC (rev 100768)
+++ trunk/Source/WebKit/gtk/webkit/webkitdownload.cpp 2011-11-18 14:45:57 UTC (rev 100769)
@@ -940,6 +940,10 @@
void DownloadClient::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
{
webkit_download_set_response(m_download, response);
+ if (response.httpStatusCode() >= 400) {
+ webkit_download_error(m_download, ResourceError(errorDomainDownload, response.httpStatusCode(),
+ response.url().string(), response.httpStatusText()));
+ }
}
void DownloadClient::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
Modified: trunk/Source/WebKit2/ChangeLog (100768 => 100769)
--- trunk/Source/WebKit2/ChangeLog 2011-11-18 14:43:10 UTC (rev 100768)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-18 14:45:57 UTC (rev 100769)
@@ -1,3 +1,15 @@
+2011-11-18 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Downloads not started by WebView only fail for transport errors
+ https://bugs.webkit.org/show_bug.cgi?id=72718
+
+ Reviewed by Martin Robinson.
+
+ * WebProcess/Downloads/soup/DownloadSoup.cpp:
+ (WebKit::DownloadClient::didReceiveResponse): Check if the http
+ status of the response is an error code and finish the download
+ with an error in such case.
+
2011-11-17 Caio Marcelo de Oliveira Filho <[email protected]>
[Qt] Support customizing JS alert/confirm/prompt dialogs using QML
Modified: trunk/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp (100768 => 100769)
--- trunk/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp 2011-11-18 14:43:10 UTC (rev 100768)
+++ trunk/Source/WebKit2/WebProcess/Downloads/soup/DownloadSoup.cpp 2011-11-18 14:45:57 UTC (rev 100769)
@@ -55,6 +55,15 @@
void didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
{
+ m_response = adoptGRef(response.toSoupMessage());
+ m_download->didReceiveResponse(response);
+
+ if (response.httpStatusCode() >= 400) {
+ downloadFailed(downloadNetworkError(ResourceError(errorDomainDownload, response.httpStatusCode(),
+ response.url().string(), response.httpStatusText())));
+ return;
+ }
+
String suggestedFilename = response.suggestedFilename();
if (suggestedFilename.isEmpty()) {
KURL url = ""
@@ -79,9 +88,6 @@
downloadFailed(downloadDestinationError(response, error->message));
return;
}
-
- m_response = adoptGRef(response.toSoupMessage());
- m_download->didReceiveResponse(response);
}
void didReceiveData(ResourceHandle*, const char* data, int length, int /*encodedDataLength*/)