WebKitWebFrame *frame, WebKitNetworkRequest *request, char *mime_type,
WebKitWebPolicyDecision *decision)
{
- /* don't start download if request failed or stopped by proxy */
- if (!mime_type || *mime_type == '\0') {
+ SoupMessage *msg;
+ /* don't start download if request failed or stopped by proxy or can be
+ * displayed in the webview */
+ if (!mime_type || *mime_type == '\0'
+ || webkit_web_view_can_show_mime_type(webview, mime_type)) {
+
return false;
}
- if (webkit_web_view_can_show_mime_type(webview, mime_type) == false) {
- webkit_web_policy_decision_download(decision);
+ /* don't start a download when the response has no 2xx status code */
+ msg = webkit_network_request_get_message(request);
+ if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
+ webkit_web_policy_decision_download(decision);
return true;
}
return false;