From f8af33ab6ac9d2a9ca46227cd9fba62771b6eaa5 Mon Sep 17 00:00:00 2001
From: armatusmiles <akurotych@gmail.com>
Date: Sun, 24 Feb 2019 20:26:37 +0700
Subject: [PATCH] [+] Warning if data_read_callback is NULL

---
 http_server/http_client/dap_http_client.c | 11 +++++++----
 http_server/http_client/dap_http_client.h |  1 -
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/http_server/http_client/dap_http_client.c b/http_server/http_client/dap_http_client.c
index 9c9c177..cfe6f25 100644
--- a/http_server/http_client/dap_http_client.c
+++ b/http_server/http_client/dap_http_client.c
@@ -293,10 +293,11 @@ cnt:switch(cl_ht->state_read){
 
                     if(cl_ht->proc->headers_read_callback)
                         cl_ht->proc->headers_read_callback(cl_ht,NULL);
+
                      // If no headers callback we go to the DATA processing
-                    if(cl_ht->in_content_length ){
+                    if(cl_ht->in_content_length) {
                         cl_ht->state_read=DAP_HTTP_CLIENT_STATE_DATA;
-                    }else{
+                    } else {
                         //log_it
                         //cl_ht->state_read=DAP_HTTP_CLIENT_STATE_NONE;
                         //cl_ht->client->ready_to_read=t;
@@ -310,14 +311,16 @@ cnt:switch(cl_ht->state_read){
         case DAP_HTTP_CLIENT_STATE_DATA:{//Read the data
          //   log_it(L_WARNINGNG, "DBG_#002 [%s] [%s]",             cl_ht->in_query_string, cl_ht->url_path);
 
-            int read_bytes=0;
+            size_t read_bytes = 0;
             if(cl_ht->proc->data_read_callback){
                 //while(cl_ht->client->buf_in_size){
                     cl_ht->proc->data_read_callback(cl_ht,&read_bytes);
                     dap_client_remote_shrink_buf_in(cl,read_bytes);
                 //}
-            }else
+            }else {
+                log_it(L_WARNING, "data_read callback is NULL in DAP_HTTP_CLIENT_STATE_DATA");
                 cl->buf_in_size=0;
+            }
         } break;
         case DAP_HTTP_CLIENT_STATE_NONE:{
                 cl->buf_in_size=0;
diff --git a/http_server/http_client/dap_http_client.h b/http_server/http_client/dap_http_client.h
index 33acaf2..9e81cab 100644
--- a/http_server/http_client/dap_http_client.h
+++ b/http_server/http_client/dap_http_client.h
@@ -64,7 +64,6 @@ typedef struct dap_http_client
     time_t out_last_modified;
     bool out_connection_close;
 
-
     dap_client_remote_t * client;
     struct dap_http * http;
 
-- 
GitLab