summaryrefslogtreecommitdiff
path: root/gweb
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-11-01 02:05:45 +0100
committerMarcel Holtmann <marcel@holtmann.org>2010-11-01 02:05:45 +0100
commit64e9586ae2953162b3b7ae1c0e11e4df4b0ed787 (patch)
tree0f704d3ffd81e511f35a8d189491db68e3ad96bc /gweb
parent0b011d307d9f87927fe9db8d0490a31a6a879ce4 (diff)
downloadconnman-64e9586ae2953162b3b7ae1c0e11e4df4b0ed787.tar.gz
connman-64e9586ae2953162b3b7ae1c0e11e4df4b0ed787.tar.bz2
connman-64e9586ae2953162b3b7ae1c0e11e4df4b0ed787.zip
The HTTP status code can be retrieved from result object
Diffstat (limited to 'gweb')
-rw-r--r--gweb/gweb.c15
-rw-r--r--gweb/gweb.h3
2 files changed, 10 insertions, 8 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 94da3d1a..eb31ae94 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -41,7 +41,7 @@
#define SESSION_FLAG_USE_TLS (1 << 0)
struct _GWebResult {
- guint status;
+ guint16 status;
const guint8 *buffer;
gsize length;
};
@@ -297,12 +297,15 @@ gboolean g_web_get_close_connection(GWeb *web)
return web->close_connection;
}
-static inline void call_result_func(struct web_session *session, guint status)
+static inline void call_result_func(struct web_session *session, guint16 status)
{
if (session->result_func == NULL)
return;
- session->result_func(status, &session->result, session->result_data);
+ if (status != 0)
+ session->result.status = status;
+
+ session->result_func(&session->result, session->result_data);
}
static gboolean received_data(GIOChannel *channel, GIOCondition cond,
@@ -331,7 +334,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
session->transport_watch = 0;
session->result.buffer = NULL;
session->result.length = 0;
- call_result_func(session, 200);
+ call_result_func(session, 0);
return FALSE;
}
@@ -340,7 +343,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
if (session->header_done == TRUE) {
session->result.buffer = session->receive_buffer;
session->result.length = bytes_read;
- call_result_func(session, 100);
+ call_result_func(session, 0);
return TRUE;
}
@@ -373,7 +376,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
session->header_done = TRUE;
session->result.buffer = pos + 1;
session->result.length = bytes_read;
- call_result_func(session, 100);
+ call_result_func(session, 0);
break;
}
diff --git a/gweb/gweb.h b/gweb/gweb.h
index cc2324c9..c07e00d6 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -42,8 +42,7 @@ typedef enum {
G_WEB_METHOD_GET,
} GWebMethod;
-typedef void (*GWebResultFunc)(guint16 status, GWebResult *result,
- gpointer user_data);
+typedef void (*GWebResultFunc)(GWebResult *result, gpointer user_data);
typedef void (*GWebDebugFunc)(const char *str, gpointer user_data);