From: Marcel Holtmann Date: Sat, 30 Oct 2010 15:52:40 +0000 (+0200) Subject: Add proper support for HTTP close connection option X-Git-Tag: 0.63~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9716a57aabbb2dc9b196030b3f9d837f0cd6861f;p=platform%2Fupstream%2Fconnman.git Add proper support for HTTP close connection option --- diff --git a/gweb/gweb.c b/gweb/gweb.c index 5aa0697..bda2f7d 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 28e9acb..3fc54f8 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);