Append all multiple message-header fields with the same name and
remove any white space in front of fiels value.
---
 gweb/gweb.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index c6a76cc..87c323a 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -786,17 +786,45 @@ static gboolean received_data(GIOChannel *channel, 
GIOCondition cond,
                                        g_strdup(str));
                        }
                } else {
+                       gchar *key;
+                       gchar *value;
+
                        pos = memchr(str, ':', session->current_header->len);
                        if (pos != NULL) {
                                *pos = '\0';
                                pos++;
 
+                               key = g_strdup(str);
+
+                               /* remove white space */
+                               while (*pos == ' ')
+                                       pos++;
+
+                               count = (char *)pos - str;
+                               g_string_erase(session->current_header, 0,
+                                                                       count);
+
+                               value = g_hash_table_lookup(
+                                               session->result.headers, key);
+                               if (value != NULL) {
+                                       g_string_insert_c(
+                                                       session->current_header,
+                                                                       0, ' ');
+                                       g_string_insert_c(
+                                                       session->current_header,
+                                                                       0, ';');
+
+                                       g_string_insert(session->current_header,
+                                                               0, value);
+                               }
+
+                               str = session->current_header->str;
                                g_hash_table_replace(session->result.headers,
-                                                       g_strdup(str),
-                                                       g_strdup((char *)pos));
+                                                       key,
+                                                       g_strdup(str));
 
                                g_free(session->result.last_key);
-                               session->result.last_key = g_strdup(str);
+                               session->result.last_key = g_strdup(key);
                        }
                }
 
-- 
1.7.3.3

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to