I’ve been trying for a while to figure out how to use the Webkit GTK API to get an HTTP response code for a particular page-load.
Webkit GTK uses the Soup API for HTTP networking, and according to the documentation, there seem to be two relevant signals: "resource-request-starting" and "resource-response-received".
So, I tried connecting a signal for "resource-request-starting":
g_signal_connect(web_view, "resource-request-starting", G_CALLBACK(resource_request_starting_callback), 0);
…and it works. Within the callback handler I can get access to the underlying SoupMessage object which gives me information about the HTTP request.
So that gets me the HTTP request, BUT… when I try to get the actual HTTP response, I run into trouble. I tried listening for the "resource-response-received" signal:
g_signal_connect(web_view, "resource-response-received", G_CALLBACK(resource_response_received_callback), 0);
This causes GTK to emit a warning:
GLib-GObject-WARNING **: /build/buildd/glib2.0-2.30.0/./gobject/gsignal.c:2295: signal `resource-response-received' is invalid for instance `0x2b46c00'
Googling around for resource-response-received, I find almost no information at all about this signal. The documentation claims it does what I want, but in practice it doesn’t actually work.
So, I don’t know if I’m going about this the wrong way. But in general, can anyone provide an example of how you can get an actual HTTP status code (like 200, 404, etc.) for a page load using Webkit GTK?
Are you using WebKit 1.7.5 or later? See the note at the bottom of the documentation you linked to.