aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-11-23 18:40:17 -0700
committerGravatar Brendan Taylor <whateley@gmail.com>2011-11-23 18:40:17 -0700
commitfd7cbacdf11d3c54f0e1ce72b43bdd2b9b2387f9 (patch)
treefafed60ab1b9037207fe48d5fa2f0042fd9a0cd7 /src
parent31a000f55d13178fa440f852074bcb3593cdf8fa (diff)
parent38fd1f02bbdc5edda7daf8210a0d2b241bc9b412 (diff)
Merge commit '38fd1f02bbdc5edda7'
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.c24
-rw-r--r--src/uzbl-core.h1
-rw-r--r--src/variables.c1
3 files changed, 26 insertions, 0 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index f939454..23b8d55 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -358,7 +358,31 @@ request_starting_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitWebRes
(void) response;
(void) user_data;
+ const gchar* uri = webkit_network_request_get_uri (request);
+
+ if (uzbl.state.verbose)
+ printf("Request starting -> %s\n", uri);
send_event (REQUEST_STARTING, NULL, TYPE_STR, webkit_network_request_get_uri(request), NULL);
+
+ if (uzbl.behave.request_handler) {
+ GString *result = g_string_new ("");
+ GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*));
+ const CommandInfo *c = parse_command_parts(uzbl.behave.request_handler, a);
+
+ if(c) {
+ g_array_append_val(a, uri);
+ run_parsed_command(c, a, result);
+ }
+ g_array_free(a, TRUE);
+
+ if(result->len > 0) {
+ char *p = strchr(result->str, '\n' );
+ if ( p != NULL ) *p = '\0';
+ webkit_network_request_set_uri(request, result->str);
+ }
+
+ g_string_free(result, TRUE);
+ }
}
void
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index 35533f7..aa88feb 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -150,6 +150,7 @@ typedef struct {
/* Handlers */
gchar* authentication_handler;
gchar* scheme_handler;
+ gchar* request_handler;
gchar* download_handler;
gboolean forward_keys;
diff --git a/src/variables.c b/src/variables.c
index ed76f95..7158faa 100644
--- a/src/variables.c
+++ b/src/variables.c
@@ -725,6 +725,7 @@ const struct var_name_to_ptr_t {
{ "authentication_handler", PTR_V_STR(uzbl.behave.authentication_handler, 1, set_authentication_handler)},
{ "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, NULL)},
+ { "request_handler", PTR_V_STR(uzbl.behave.request_handler, 1, NULL)},
{ "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)},
{ "fifo_dir", PTR_V_STR(uzbl.behave.fifo_dir, 1, set_fifo_dir)},