[capi-http] Fixed the https GET request issue 17/62917/1
authorpradeep kumar B <b.pradeep@samsung.com>
Mon, 21 Mar 2016 05:59:53 +0000 (11:29 +0530)
committerpradeep kumar B <b.pradeep@samsung.com>
Mon, 21 Mar 2016 05:59:53 +0000 (11:29 +0530)
Change-Id: Ie09bfef199f0624f02e630625ab3c8292c904822
Signed-off-by: pradeep kumar B <b.pradeep@samsung.com>
src/http_request.c
src/http_transaction.c

index c5c5e76..673f931 100644 (file)
@@ -230,14 +230,18 @@ int _read_request_body(http_transaction_h http_transaction, char **body)
        size_t new_len = 0;
        gchar* ptr = NULL;
 
+       len = g_queue_get_length(request->body_queue);
+       if (len == 0) {
+               *body = NULL;
+               return HTTP_ERROR_NONE;
+       }
+
        *body = malloc(curr_len + 1);
        if (*body == NULL) {
                DBG("malloc() failed\n");
                return HTTP_ERROR_OPERATION_FAILED;
        }
 
-       len = g_queue_get_length(request->body_queue);
-
        for (index = 0; index < len; index++) {
 
                ptr = (gchar*)g_queue_pop_head(request->body_queue);
index 11ec436..18ec22c 100644 (file)
@@ -231,13 +231,15 @@ int _transaction_submit(gpointer user_data)
                DBG("The write_event is %d.\n", write_event);
        }
 
-       if (!write_event) {
+       if ((_get_method(request->method) == HTTP_METHOD_POST) && !write_event) {
                gchar *body = NULL;
 
                _read_request_body(transaction, &body);
 
-               curl_easy_setopt(transaction->easy_handle, CURLOPT_COPYPOSTFIELDS, body);
-               free(body);
+               if (body) {
+                       curl_easy_setopt(transaction->easy_handle, CURLOPT_COPYPOSTFIELDS, body);
+                       free(body);
+               }
        }
 
        if (write_event) {