summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-10-30 17:52:40 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-10-30 17:52:40 +0200
commit9716a57aabbb2dc9b196030b3f9d837f0cd6861f (patch)
tree5b31f7fa47546ac2e75f2fbc1e36d7c5afa6501d
parentd706f4948c2c9634944598b989385c449ed19591 (diff)
downloadconnman-9716a57aabbb2dc9b196030b3f9d837f0cd6861f.tar.gz
connman-9716a57aabbb2dc9b196030b3f9d837f0cd6861f.tar.bz2
connman-9716a57aabbb2dc9b196030b3f9d837f0cd6861f.zip
Add proper support for HTTP close connection option
-rw-r--r--gweb/gweb.c21
-rw-r--r--gweb/gweb.h3
2 files changed, 23 insertions, 1 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 5aa06973..bda2f7d5 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -72,6 +72,7 @@ struct _GWeb {
GResolv *resolv;
char *accept_option;
char *user_agent;
+ gboolean close_connection;
GWebDebugFunc debug_func;
gpointer debug_data;
@@ -154,6 +155,7 @@ GWeb *g_web_new(int index)
web->accept_option = g_strdup("*/*");
web->user_agent = g_strdup_printf("GWeb/%s", VERSION);
+ web->close_connection = FALSE;
return web;
}
@@ -266,6 +268,22 @@ gboolean g_web_set_user_agent(GWeb *web, const char *format, ...)
return result;
}
+void g_web_set_close_connection(GWeb *web, gboolean enabled)
+{
+ if (web == NULL)
+ return;
+
+ web->close_connection = enabled;
+}
+
+gboolean g_web_get_close_connection(GWeb *web)
+{
+ if (web == NULL)
+ return FALSE;
+
+ return web->close_connection;
+}
+
static gboolean received_data(GIOChannel *channel, GIOCondition cond,
gpointer user_data)
{
@@ -375,7 +393,8 @@ static void start_request(struct web_session *session)
if (session->web->accept_option != NULL)
g_string_append_printf(buf, "Accept: %s\r\n",
session->web->accept_option);
- g_string_append(buf, "Connection: close\r\n");
+ if (session->web->close_connection == TRUE)
+ g_string_append(buf, "Connection: close\r\n");
g_string_append(buf, "\r\n");
str = g_string_free(buf, FALSE);
diff --git a/gweb/gweb.h b/gweb/gweb.h
index 28e9acb0..3fc54f89 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -59,6 +59,9 @@ gboolean g_web_set_accept(GWeb *web, const char *format, ...)
gboolean g_web_set_user_agent(GWeb *web, const char *format, ...)
__attribute__((format(printf, 2, 3)));
+void g_web_set_close_connection(GWeb *web, gboolean enabled);
+gboolean g_web_get_close_connection(GWeb *web);
+
guint g_web_request(GWeb *web, GWebMethod method, const char *url,
GWebResultFunc func, gpointer user_data);