summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2022-03-21 14:07:48 +0100
committerCarlos Garcia Campos <cgarcia@igalia.com>2022-03-22 16:35:46 +0100
commit0b37e58ab3aaf4e78aa0370eaf5de8489e13072d (patch)
treef0006de1e111a12d652911971a88081028f2367a
parentd49694b4a458290c1c3dd38dd8ba8e11a09d1c57 (diff)
downloadlibsoup-0b37e58ab3aaf4e78aa0370eaf5de8489e13072d.tar.gz
get: add --user-agent command line option
-rw-r--r--examples/get.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/get.c b/examples/get.c
index f7bad501..657914ca 100644
--- a/examples/get.c
+++ b/examples/get.c
@@ -112,6 +112,7 @@ on_request_sent (GObject *source, GAsyncResult *result, gpointer user_data)
static const char *ca_file, *proxy;
static char *client_cert_file, *client_key_file;
+static char *user_agent;
static gboolean ntlm;
static gboolean negotiate;
@@ -128,6 +129,9 @@ static GOptionEntry entries[] = {
{ "debug", 'd', 0,
G_OPTION_ARG_NONE, &debug,
"Show HTTP headers", NULL },
+ { "user-agent", 'u', 0,
+ G_OPTION_ARG_STRING, &user_agent,
+ "User agent string", "STRING" },
{ "head", 'h', 0,
G_OPTION_ARG_NONE, &head,
"Do HEAD rather than GET", NULL },
@@ -234,6 +238,9 @@ main (int argc, char **argv)
}
}
+ if (user_agent)
+ soup_session_set_user_agent (session, user_agent);
+
if (debug) {
SoupLogger *logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));