From 247d87bdb737c6d7058d9be341795d1249445d55 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 29 Jun 2015 10:11:50 +0200 Subject: [PATCH] If boundary in ZakCgiMain::parse_stdin, it tries to find it on envirenment. --- src/main.c | 20 ++++++++++++++++++-- tests/env.c | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index bcd981f..880ddf8 100644 --- a/src/main.c +++ b/src/main.c @@ -451,6 +451,24 @@ GHashTable ht = NULL; + content_type = (gchar *)g_getenv ("CONTENT_TYPE"); + gchar **splitted = g_strsplit (content_type, ";", -1); + if (g_strv_length (splitted) > 1 + && boundary == NULL) + { + gchar **boundary_splitted = g_strsplit (splitted[1], "=", 2); + _boundary = g_strdup_printf ("--%s", boundary_splitted[1]); + g_strfreev (boundary_splitted); + } + else + { + if (boundary != NULL) + { + _boundary = g_strdup_printf ("--%s", boundary); + } + } + g_strfreev (splitted); + env = g_getenv ("CONTENT_LENGTH"); if (env != NULL) { @@ -459,8 +477,6 @@ GHashTable { ht = g_hash_table_new (g_str_hash, g_str_equal); - _boundary = g_strdup_printf ("--%s", boundary); - i = 0; do { diff --git a/tests/env.c b/tests/env.c index d63504f..a4bb7dd 100644 --- a/tests/env.c +++ b/tests/env.c @@ -54,7 +54,8 @@ main (int argc, char *argv[]) { gchar **boundary = g_strsplit (splitted[1], "=", 2); - ht = zak_cgi_main_parse_stdin (env, boundary[1]); + /*ht = zak_cgi_main_parse_stdin (env, boundary[1]);*/ + ht = zak_cgi_main_parse_stdin (env, NULL); GHashTableIter iter; -- 2.49.0