webkit2: Fix http://localhost:12345/ redirect handling

The resource-load-started cannot be used to replace the older
resource-request-starting signal and as such, the final redirect to the
special http://localhost:12345/ URL did not work. Use the decide-policy
signal for navigation action instead.

Also remove the attempt to modify the request URI from
resource-load-started since that is not going to work either. This is
not really critical for functionality, but could eventually be replaced
with a handler for the WebKitWebPage send-request signal.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2020-03-07 11:51:23 +02:00
parent bdb2eaf876
commit ca8a51c4bb

View file

@ -107,9 +107,6 @@ static void view_cb_resource_load_starting(WebKitWebView *view,
const gchar *uri = webkit_uri_request_get_uri(req);
wpa_printf(MSG_DEBUG, "BROWSER:%s uri=%s", __func__, uri);
if (g_str_has_suffix(uri, "/favicon.ico"))
webkit_uri_request_set_uri(req, "about:blank");
process_request_starting_uri(ctx, uri);
}
@ -134,6 +131,21 @@ static gboolean view_cb_decide_policy(WebKitWebView *view,
}
break;
}
case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
WebKitNavigationPolicyDecision *d;
WebKitNavigationAction *a;
WebKitURIRequest *req;
const gchar *uri;
d = WEBKIT_NAVIGATION_POLICY_DECISION(policy);
a = webkit_navigation_policy_decision_get_navigation_action(d);
req = webkit_navigation_action_get_request(a);
uri = webkit_uri_request_get_uri(req);
wpa_printf(MSG_DEBUG, "BROWSER:%s navigation action: uri=%s",
__func__, uri);
process_request_starting_uri(ctx, uri);
break;
}
default:
break;
}