From 9b955b26351c78faf6786a6abebdf14382b7ec03 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sat, 31 Aug 2013 16:21:04 +0300 Subject: [PATCH] Add --enable-cookies This option binds libquvi QUVI_OPTION_ALLOW_COOKIES, allowing the users to define the cookie parsing behaviour with libcurl. Cookie support is disabled by default. Signed-off-by: Toni Gundogdu --- doc/man1/opts-http.txt | 6 ++++++ src/opts.c | 7 +++++++ src/opts.h | 1 + src/setup.c | 1 + 4 files changed, 15 insertions(+) diff --git a/doc/man1/opts-http.txt b/doc/man1/opts-http.txt index e8f9cfb..a7c128d 100644 --- a/doc/man1/opts-http.txt +++ b/doc/man1/opts-http.txt @@ -1,6 +1,12 @@ HTTP ~~~~ +-c, --enable-cookies:: + Have libcurl parse the received cookies and use them in the subsequent + HTTP requests. + + + config: http.enable-cookies= + -u, --user-agent USERAGENT (default: Mozilla/5.0):: Identify as USERAGENT to the HTTP server. diff --git a/src/opts.c b/src/opts.c index 186258b..77211d4 100644 --- a/src/opts.c +++ b/src/opts.c @@ -119,6 +119,10 @@ const GOptionEntry option_entries[] = }, /* http */ { + "enable-cookies", 'c', 0, G_OPTION_ARG_NONE, &opts.http.enable_cookies, + NULL, NULL + }, + { "user-agent", 'u', 0, G_OPTION_ARG_STRING, &opts.http.user_agent, NULL, NULL }, @@ -259,6 +263,9 @@ void cb_parse_keyfile_values(GKeyFile *kf, const gchar *fpath) /* http */ + lopts_keyfile_get_bool(kf, fpath, g_http, + "enable-cookies", &opts.http.enable_cookies); + lopts_keyfile_get_str(kf, NULL, fpath, g_http, NULL, "user-agent", &opts.http.user_agent); } diff --git a/src/opts.h b/src/opts.h index d0b0908..8683e32 100644 --- a/src/opts.h +++ b/src/opts.h @@ -58,6 +58,7 @@ struct opts_s } get; struct { + gboolean enable_cookies; gchar *user_agent; } http; gchar **rargs; diff --git a/src/setup.c b/src/setup.c index 7c43324..f97a477 100644 --- a/src/setup.c +++ b/src/setup.c @@ -71,6 +71,7 @@ gint setup_quvi(quvi_t *q) r = lutil_quvi_init(q, &o); if (r == EXIT_SUCCESS) { + quvi_set(*q, QUVI_OPTION_ALLOW_COOKIES, opts.http.enable_cookies); quvi_set(*q, QUVI_OPTION_USER_AGENT, opts.http.user_agent); quvi_set(*q, QUVI_OPTION_CALLBACK_STATUS, cb_status); } -- 2.11.4.GIT