diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15393c8dc94141379f9c0a2cddf1243aab832f7a..d1d474ded4132c1db8d521ab77d01b4c3ba830b0 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0)
 
 if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
     if ( NOT ( TARGET dap_core ) )
-	add_subdirectory(libdap)
+  add_subdirectory(libdap)
     endif()
 
     if ( NOT ( TARGET dap_crypto ) )
@@ -20,10 +20,6 @@ if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
     
 endif()
 
-
-find_package(PkgConfig)
-pkg_check_modules(PC_JSON-C REQUIRED json-c)
-
 add_subdirectory(http_server)
 add_subdirectory(enc_server)
 
diff --git a/enc_server/CMakeLists.txt b/enc_server/CMakeLists.txt
index 7cb46498845d3f0ca3750c30501b790370bf034a..2872fd34ada605d9137fe111767f1778992f30b5 100755
--- a/enc_server/CMakeLists.txt
+++ b/enc_server/CMakeLists.txt
@@ -3,9 +3,58 @@ project(dap_enc_server C)
   
 set(DAP_ENC_SERVER_SRCS  dap_enc_http.c  dap_enc_ks.c)
 
+if(WIN32)
+    add_definitions ("-DUNDEBUG")
+    add_definitions ("-DNDEBUG")
+    add_definitions ("-DWIN32")
+    add_definitions ("-D_WINDOWS")
+    add_definitions ("-D__WINDOWS__")
+    add_definitions ("-D_CRT_SECURE_NO_WARNINGS")
+    add_definitions ("-DCURL_STATICLIB")
+#    add_definitions ("-DDAP_SERVER NODE_NETNAME=\"kelvin\"")
+endif()
+
+if(WIN32)
+  include_directories(../../libdap/src/win32/)
+  include_directories(../../3rdparty/libmemcached/)
+  include_directories(../../3rdparty/libmemcached/win32/)
+  include_directories(../../3rdparty/wepoll/include/)
+  include_directories(../../3rdparty/uthash/src/)
+  include_directories(../../3rdparty/libjson-c/)
+  include_directories(../../3rdparty/libmagic/src/)
+  include_directories(../../3rdparty/curl/include/)
+endif()
+
 add_library(${PROJECT_NAME} STATIC ${DAP_ENC_SERVER_SRCS})
 
-target_link_libraries(${PROJECT_NAME} dap_core dap_crypto
-    dap_server_core dap_http_server json-c)
+if(WIN32)
+  target_link_libraries(dap_enc_server dap_core dap_crypto dap_server_core dap_http_server
+
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/libmemcached[x86_64CLANG].a
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/libmagic[x86_64CLANG].a
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/curl[x86_64CLANG].a
+  KERNEL32
+  USER32
+  SHELL32
+  WINMM
+  GDI32
+  ADVAPI32
+  Ole32
+  Version
+  Imm32
+  OleAut32
+  ws2_32
+  ntdll
+  psapi
+  Shlwapi
+  Bcrypt
+  Crypt32
+  Secur32
+)
+endif()
+
+if(UNIX)
+  target_link_libraries(dap_enc_server dap_core dap_crypto dap_server_core dap_http_server json-c)
+endif()
 
 target_include_directories(dap_enc_server INTERFACE .)
diff --git a/enc_server/dap_enc_http.c b/enc_server/dap_enc_http.c
index bbca6d9e8afc017af62bb85b6c15e697f9bb9558..e06d5650643e9cd86961bfc37e00e01c3f16f91e 100755
--- a/enc_server/dap_enc_http.c
+++ b/enc_server/dap_enc_http.c
@@ -21,6 +21,24 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+
+#include "dap_common.h"
+
+#ifdef _WIN32
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#include <winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <time.h>
+#include <wepoll.h>
+#endif
+
+#include <pthread.h>
+
+
 #include "dap_common.h"
 
 #include "dap_http.h"
@@ -245,12 +263,13 @@ size_t enc_http_reply_f(enc_http_delegate_t * dg, const char * data, ...)
 {
     va_list ap;
     va_start(ap, data);
-    int mem_size = vsnprintf(0, 0, data, ap);
+    int mem_size = dap_vsnprintf(0, 0, data, ap);
+
     va_end(ap);
     char *buf = (char*)malloc(sizeof(char) * mem_size + 1);
     if(buf) {
         va_start(ap, data);
-        vsprintf(buf, data, ap);
+        dap_vsprintf(buf, data, ap);
         va_end(ap);
         return enc_http_reply(dg,buf,mem_size);
     }else
diff --git a/enc_server/dap_enc_ks.c b/enc_server/dap_enc_ks.c
index 6cf2aab6783ffb9cc0857fc168ecf566e9090724..b41c7246618642bcd52fa1a800a99a09099b8c4d 100755
--- a/enc_server/dap_enc_ks.c
+++ b/enc_server/dap_enc_ks.c
@@ -18,7 +18,20 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "pthread.h"
+#ifdef _WIN32
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#include <winsock2.h>
+#include <windows.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#include <time.h>
+#include <wepoll.h>
+#endif
+
+#include <pthread.h>
+
 #include "uthash.h"
 #include "dap_common.h"
 
diff --git a/http_server/CMakeLists.txt b/http_server/CMakeLists.txt
index 0a548ba8bc0f4361c56489faf08bac67d01091b2..113570015d212220cde05deac2f593fae9ff7b77 100755
--- a/http_server/CMakeLists.txt
+++ b/http_server/CMakeLists.txt
@@ -12,9 +12,58 @@ set(HTTP_SERVER_SRCS
     http_client/dap_http_header.c
     http_client/dap_http_user_agent.c)
 
+if(WIN32)
+    add_definitions ("-DUNDEBUG")
+    add_definitions ("-DNDEBUG")
+    add_definitions ("-DWIN32")
+    add_definitions ("-D_WINDOWS")
+    add_definitions ("-D__WINDOWS__")
+    add_definitions ("-D_CRT_SECURE_NO_WARNINGS")
+    add_definitions ("-DCURL_STATICLIB")
+#    add_definitions ("-DDAP_SERVER NODE_NETNAME=\"kelvin\"")
+endif()
+
+if(WIN32)
+  include_directories(../../libdap/src/win32/)
+  include_directories(../../3rdparty/libmemcached/)
+  include_directories(../../3rdparty/libmemcached/win32/)
+  include_directories(../../3rdparty/wepoll/include/)
+  include_directories(../../3rdparty/uthash/src/)
+  include_directories(../../3rdparty/libjson-c/)
+  include_directories(../../3rdparty/libmagic/src/)
+  include_directories(../../3rdparty/curl/include/)
+endif()
+
 add_library(${PROJECT_NAME} STATIC ${HTTP_SERVER_SRCS})
 
 target_include_directories(dap_http_server INTERFACE . http_client)
 
-target_link_libraries(dap_http_server dap_core dap_crypto dap_server_core magic curl json-c)
+if(WIN32)
+  target_link_libraries(dap_http_server dap_core dap_crypto dap_server_core
+
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/libmemcached[x86_64CLANG].a
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/libmagic[x86_64CLANG].a
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/[x86_64CLANG]/curl[x86_64CLANG].a
+  KERNEL32
+  USER32
+  SHELL32
+  WINMM
+  GDI32
+  ADVAPI32
+  Ole32
+  Version
+  Imm32
+  OleAut32
+  ws2_32
+  ntdll
+  psapi
+  Shlwapi
+  Bcrypt
+  Crypt32
+  Secur32
+)
+endif()
 
+if(UNIX)
+  target_link_libraries(dap_http_server dap_core dap_crypto dap_server_core magic curl json-c)
+endif()
diff --git a/http_server/dap_http.c b/http_server/dap_http.c
index 57b4a3ecee7a91933fb84ff9fd1e41de31558a99..3c071fedd4e6ed24e93d29d61b11e79470307579 100755
--- a/http_server/dap_http.c
+++ b/http_server/dap_http.c
@@ -22,19 +22,17 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
 
 #ifndef _WIN32
 #include <netinet/in.h>
-
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h>
 #include <netdb.h>
 #else
 #undef _WIN32_WINNT
@@ -45,16 +43,14 @@
 #include <ws2tcpip.h>
 #include <io.h>
 #include <time.h>
-#include "wrappers.h"
 #include <wepoll.h>
-#include <pthread.h>
 #endif
 
-#include "dap_common.h"
+#include <pthread.h>
 
+#include "dap_common.h"
 #include "dap_server.h"
 #include "dap_client_remote.h"
-
 #include "dap_http.h"
 #include "dap_http_header.h"
 #include "dap_http_client.h"
diff --git a/http_server/dap_http_folder.c b/http_server/dap_http_folder.c
index 090ece34e6042aa7c13ef74b6d2c1678867f7f21..4569d2028e18ec639dac8d34fc6507354709fb26 100755
--- a/http_server/dap_http_folder.c
+++ b/http_server/dap_http_folder.c
@@ -19,13 +19,13 @@
 */
 
 #include <stdio.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <errno.h>
 
 #ifndef _WIN32
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
 #else
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0600
@@ -34,11 +34,10 @@
 #include <mswsock.h>
 #include <ws2tcpip.h>
 #include <io.h>
-#include "wrappers.h"
 #include <wepoll.h>
-#include <pthread.h>
 #endif
 
+#include <pthread.h>
 #include <magic.h>
 
 #include "dap_common.h"
@@ -198,7 +197,7 @@ void dap_http_folder_headers_write( dap_http_client_t *cl_ht, void * arg)
   cl_ht_file->client=cl_ht;
 
   // Produce local path for file to open
-  snprintf(cl_ht_file->local_path,sizeof(cl_ht_file->local_path),"%s/%s", up_folder->local_path, cl_ht->url_path );
+  dap_snprintf(cl_ht_file->local_path,sizeof(cl_ht_file->local_path),"%s/%s", up_folder->local_path, cl_ht->url_path );
   log_it(L_DEBUG, "Check %s file", cl_ht_file->local_path);
 
 #ifndef _WIN32
diff --git a/http_server/dap_http_simple.c b/http_server/dap_http_simple.c
index 0c9c159c775ecfdaa55277365788aa2e5b6eb6d2..bcfac6209726a5617ba4d895293bf16b55696f58 100755
--- a/http_server/dap_http_simple.c
+++ b/http_server/dap_http_simple.c
@@ -31,9 +31,7 @@
 #include <time.h>
 
 #ifndef _WIN32
-//#include <ev.h> 
 #include <sys/queue.h>
-#include <utlist.h>
 #else
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0600
@@ -42,13 +40,14 @@
 #include <mswsock.h>
 #include <ws2tcpip.h>
 #include <io.h>
-#include "wrappers.h"
 #include <wepoll.h>
-#include <pthread.h>
 #endif
 
+#include <pthread.h>
 #include <json-c/json.h>
 
+#include "utlist.h"
+
 #include "dap_common.h"
 #include "dap_config.h"
 #include "dap_http.h"
@@ -173,7 +172,7 @@ static void *loop_http_simple_proc( void *arg )
 
       for ( uint32_t i = 0; i < s_requestsproc_count; ++ i ) {
         dap_http_simple_proc( s_requestsproc[i] );
-//        s_requestsproc[i]->http->client->no_close = false;
+        s_requestsproc[i]->http->client->no_close = false;
 //        free( s_requestsproc[i] ); // ???
       }
     }
@@ -518,7 +517,7 @@ size_t dap_http_simple_reply_f( dap_http_simple_t * shs, const char * data, ...
   int vret;
 
   va_start(va,data);
-  vret = vsnprintf( buf, sizeof(buf) - 1, data, va );
+  vret = dap_vsnprintf( buf, sizeof(buf) - 1, data, va );
   va_end(va);
 
   if ( vret > 0 )
@@ -543,7 +542,7 @@ inline void queue_http_request_put( dap_http_simple_t *cl_sh )
   log_it( L_WARNING, "queue_http_request_put >>> %u", s_requests_count );
 
   s_requests[ s_requests_count ++ ] = cl_sh;
-//  cl_sh->http->client->no_close = true;
+  cl_sh->http->client->no_close = true;
 
   pthread_mutex_unlock( &mutex_on_queue_http_response );
 }
diff --git a/http_server/http_client/CMakeLists.txt b/http_server/http_client/CMakeLists.txt
index a10df6f5bcb21c881b5d26d2c84dda981774d54f..6abb664ff549aff84a4c6aa2b70f1d3f8c0fa85e 100755
--- a/http_server/http_client/CMakeLists.txt
+++ b/http_server/http_client/CMakeLists.txt
@@ -2,6 +2,17 @@ cmake_minimum_required(VERSION 2.8)
 project (dap_http_client)
   
 set(HTTP_SRCS dap_http_client.c dap_http_client_simple.c dap_http_header.c)
+
+if(WIN32)
+  include_directories(../../../libdap/src/win32/)
+  include_directories(../../../3rdparty/libmemcached/)
+  include_directories(../../../3rdparty/libmemcached/win32/)
+  include_directories(../../../3rdparty/wepoll/include/)
+  include_directories(../../../3rdparty/uthash/src/)
+  include_directories(../../../3rdparty/libjson-c/)
+  include_directories(../../../3rdparty/libmagic/src/)
+  include_directories(../../../3rdparty/curl/include/)
+endif()
  
 add_library(${PROJECT_NAME} STATIC ${HTTP_SRCS})
 
diff --git a/http_server/http_client/dap_http_client.c b/http_server/http_client/dap_http_client.c
index 99cb6c1b1aeeb80a480bcd275b85a5fcdc0d8644..6f4d7df93079e9fab65fd6ebfdb11ca253c998c3 100755
--- a/http_server/http_client/dap_http_client.c
+++ b/http_server/http_client/dap_http_client.c
@@ -35,9 +35,10 @@
 #include <io.h>
 #include "wrappers.h"
 #include <wepoll.h>
-#include "../pthread-win32/pthread.h"
-
 #endif
+
+#include <pthread.h>
+
 #include "dap_common.h"
 #include "dap_client_remote.h"
 
@@ -102,24 +103,21 @@ void dap_http_client_delete( dap_client_remote_t * cl, void *arg )
 {
   dap_http_client_t *cl_ht = DAP_HTTP_CLIENT( cl );
 
-  log_it( L_NOTICE,"dap_http_client_delete" );
-
   while( cl_ht->in_headers )
     dap_http_header_remove( &cl_ht->in_headers, cl_ht->in_headers );
 
   while( cl_ht->out_headers )
     dap_http_header_remove( &cl_ht->out_headers, cl_ht->out_headers );
 
-
   if( cl_ht->proc ) {
     if( cl_ht->proc->delete_callback ) {
-      log_it( L_NOTICE,"dap_http_client_delete: callback delete" );
       cl_ht->proc->delete_callback( cl_ht, NULL );
     }
   }
 
-  if( cl_ht->_inheritor )
+  if( cl_ht->_inheritor ) {
     free( cl_ht->_inheritor );
+  }
 
   (void) arg;
 }
@@ -324,7 +322,7 @@ void dap_http_client_read( dap_client_remote_t *cl, void *arg )
   char buf_line[4096];
   dap_http_client_t *cl_ht = DAP_HTTP_CLIENT( cl );
 
-  log_it( L_DEBUG, "dap_http_client_read..." );
+//  log_it( L_DEBUG, "dap_http_client_read..." );
   log_it( L_WARNING, "HTTP client in state read %d taked bytes in input %lu", cl_ht->state_read, cl->buf_in_size );
 
   do {
@@ -459,7 +457,7 @@ void dap_http_client_read( dap_client_remote_t *cl, void *arg )
 
         if ( cl_ht->proc->access_callback ) {
 
-          log_it( L_WARNING, "access_callback" );
+//          log_it( L_WARNING, "access_callback" );
 
           bool isOk = true;
           cl_ht->proc->access_callback( cl_ht, &isOk );
@@ -497,7 +495,7 @@ void dap_http_client_read( dap_client_remote_t *cl, void *arg )
 
       size_t read_bytes = 0;
       if ( cl_ht->proc->data_read_callback ) {
-            log_it( L_WARNING, "cl_ht->proc->data_read_callback()" );
+//            log_it( L_WARNING, "cl_ht->proc->data_read_callback()" );
 
         //while(cl_ht->client->buf_in_size){
         cl_ht->proc->data_read_callback( cl_ht, &read_bytes );
@@ -520,7 +518,7 @@ void dap_http_client_read( dap_client_remote_t *cl, void *arg )
 
   } while ( cl->buf_in_size > 0 );
 
-  log_it( L_DEBUG, "dap_http_client_read...exit" );
+//  log_it( L_DEBUG, "dap_http_client_read...exit" );
 //  Sleep(100);
 }
 
@@ -531,7 +529,7 @@ void dap_http_client_read( dap_client_remote_t *cl, void *arg )
  */
 void dap_http_client_write( dap_client_remote_t * cl, void *arg )
 {
-  log_it( L_DEBUG, "dap_http_client_write..." );
+//  log_it( L_DEBUG, "dap_http_client_write..." );
 
   (void) arg;
   dap_http_client_t *cl_ht = DAP_HTTP_CLIENT( cl );
@@ -614,7 +612,7 @@ void dap_http_client_out_header_generate(dap_http_client_t *cl_ht)
       log_it(L_DEBUG,"output: Content-Type = '%s'",cl_ht->out_content_type);
     }
     if ( cl_ht->out_content_length ) {
-      snprintf(buf,sizeof(buf),"%llu",(unsigned long long)cl_ht->out_content_length);
+      dap_snprintf(buf,sizeof(buf),"%llu",(unsigned long long)cl_ht->out_content_length);
       dap_http_header_add(&cl_ht->out_headers,"Content-Length",buf);
       log_it(L_DEBUG,"output: Content-Length = %llu",cl_ht->out_content_length);
     }
diff --git a/http_server/http_client/dap_http_client_simple.c b/http_server/http_client/dap_http_client_simple.c
index f5e3ce797ddf44a9fa65b2e821505b0f3f92b112..2e74761913006599e9097854072126078dd6574c 100755
--- a/http_server/http_client/dap_http_client_simple.c
+++ b/http_server/http_client/dap_http_client_simple.c
@@ -7,11 +7,9 @@
 #include <stdint.h>
 #include <string.h>
 #include <time.h>
-
-#ifndef _WIN32
 #include <unistd.h>
-#include <pthread.h>
-#else
+
+#ifdef _WIN32
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0600
 #include <winsock2.h>
@@ -20,11 +18,12 @@
 #include <ws2tcpip.h>
 #include <io.h>
 #include <time.h>
-#include "wrappers.h"
+//#include "wrappers.h"
 #include <wepoll.h>
-#include "../../pthread-win32/pthread.h"
 #endif
 
+#include <pthread.h>
+
 #include <curl/curl.h>
 
 #include "utlist.h"
@@ -67,7 +66,6 @@ static void *dap_http_client_thread( void *arg );
 
 size_t dap_http_client_curl_request_callback( char *a_ptr, size_t a_size, size_t a_nmemb, void *a_userdata );
 size_t dap_http_client_curl_response_callback(char *a_ptr, size_t a_size, size_t a_nmemb, void *a_userdata );
-size_t dap_http_client_curl_close_callback( char *a_ptr, size_t a_size, size_t a_nmemb, void *a_userdata );
 
 void dap_http_client_internal_delete( dap_http_client_internal_t *a_client );
 
@@ -118,6 +116,7 @@ void dap_http_client_internal_delete( dap_http_client_internal_t * a_client_inte
     free( a_client_internal->response );
 
   free( a_client_internal );
+  log_it( L_NOTICE,"dap_http_client_internal_delete ok" );
 }
 
 /**
@@ -174,7 +173,7 @@ void dap_http_client_simple_request_custom( const char *a_url, const char *a_met
       if ( a_cookie )
         l_client_internal->request_headers = curl_slist_append( l_client_internal->request_headers,(char*) a_cookie );
 
-        snprintf(l_buf,sizeof(l_buf),"Content-Length: %lu", a_request_size );
+        dap_snprintf(l_buf,sizeof(l_buf),"Content-Length: %lu", a_request_size );
         l_client_internal->request_headers = curl_slist_append(l_client_internal->request_headers, l_buf);
 
         //curl_easy_setopt( l_curl_h , CURLOPT_READDATA , l_client_internal );
@@ -195,15 +194,14 @@ void dap_http_client_simple_request_custom( const char *a_url, const char *a_met
   curl_easy_setopt( l_curl_h , CURLOPT_WRITEDATA , l_client_internal );
   curl_easy_setopt( l_curl_h , CURLOPT_WRITEFUNCTION , dap_http_client_curl_response_callback );
 
-  curl_easy_setopt( l_curl_h , CURLOPT_CLOSESOCKETDATA , l_client_internal );
-  curl_easy_setopt( l_curl_h , CURLOPT_CLOSESOCKETFUNCTION , dap_http_client_curl_close_callback );
-
   curl_multi_add_handle( m_curl_mh, l_curl_h );
     //curl_multi_perform(m_curl_mh, &m_curl_cond);
 
+#ifndef _WIN32
   pthread_cond_signal( &m_curl_cond);
-
   send_select_break( );
+#endif
+
 }
 
 /**
@@ -259,21 +257,6 @@ size_t dap_http_client_curl_response_callback( char *a_ptr, size_t a_size, size_
     return a_size*a_nmemb;
 }
 
-
-/**
- * @brief dap_http_client_curl_response_callback
- * @param a_ptr
- * @param a_size
- * @param a_nmemb
- * @param a_userdata
- * @return
- */
-size_t dap_http_client_curl_close_callback( char *a_ptr, size_t a_size, size_t a_nmemb, void *a_userdata )
-{
-    dap_http_client_internal_t * l_client_internal = (dap_http_client_internal_t *) a_userdata;
-    printf("\n*** close l_client_internal=%x\n\n", l_client_internal);
-}
-
 /**
  * @brief dap_http_client_curl_request_callback
  * @param a_ptr
@@ -333,8 +316,12 @@ static void* dap_http_client_thread(void * arg)
         timeout.tv_sec = 10;
         timeout.tv_usec = 0;
 
+//        log_it(L_DEBUG, "curl_multi_timeout( )\n");
         curl_multi_timeout( m_curl_mh, &curl_timeo );
 
+//        Sleep(1000);
+//        log_it(L_DEBUG, "curl_timeo = %u\n", curl_timeo);
+
         if(curl_timeo >= 0) {
           timeout.tv_sec = curl_timeo / 1000;
           if(timeout.tv_sec > 1)
@@ -344,13 +331,16 @@ static void* dap_http_client_thread(void * arg)
         }
 
         /* get file descriptors from the transfers */
-        mc = curl_multi_fdset(m_curl_mh, &fdread, &fdwrite, &fdexcep, &maxfd);
+        mc = curl_multi_fdset( m_curl_mh, &fdread, &fdwrite, &fdexcep, &maxfd );
+
+//        log_it(L_DEBUG, "curl_multi_fdset() = %u maxfd = %u\n", mc, maxfd );
 
+#ifndef _WIN32
         FD_SET(get_select_breaker(),&fdread);
 
         if(get_select_breaker() > maxfd)
             maxfd = get_select_breaker();
-
+#endif
         if(mc != CURLM_OK) {
           log_it(L_ERROR, "curl_multi_fdset() failed, code %d.\n", mc);
           break;
@@ -364,22 +354,34 @@ static void* dap_http_client_thread(void * arg)
 
         rc = 0;
 
-        if(maxfd == -1) {
+        if ( maxfd == -1 ) {
 //            log_it(L_DEBUG, "Waiting for signal");
-            pthread_cond_wait(&m_curl_cond,&m_curl_mutex);
+#ifndef _WIN32
+            pthread_cond_wait( &m_curl_cond, &m_curl_mutex );
+#else
+            Sleep(100);
+#endif
+//            Sleep(1000);
         }  else {
-//            log_it(L_DEBUG, "Selecting stuff");
+//            Sleep(100);
+//            log_it(L_DEBUG, "Selecting stuff maxfd = %u select timeout %u", maxfd, timeout );
           /* Note that on some platforms 'timeout' may be modified by select().
              If you need access to the original value save a copy beforehand. */
-          rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
+          rc = select( maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout );
         }
+//        log_it(L_DEBUG, "Select error rc = %u", rc );
+
 
         switch(rc) {
             case -1: {
+//              log_it(L_DEBUG, "Select error rc = %u", rc );
               /* select error */
             } break;
             case 0: /* timeout */
+//              log_it(L_DEBUG, "Select timeout rc = %u", rc );
             default: { /* action */
+//              log_it(L_DEBUG, "ACTTION ? rc = %u", rc );
+
               int l_curl_eh_count = 0;
               curl_multi_perform( m_curl_mh , &l_curl_eh_count );
                // Check if we have smth complete
@@ -390,10 +392,12 @@ static void* dap_http_client_thread(void * arg)
                   m = curl_multi_info_read(m_curl_mh, &msgq);
 
                   if(m && (m->msg == CURLMSG_DONE)) {
+//                      log_it(L_DEBUG, "CURLMSG_DONE" );
                       CURL *e = m->easy_handle;
                       char * l_private = NULL;
                       int l_err_code = 0;
                       curl_easy_getinfo( e, CURLINFO_PRIVATE, &l_private );
+//                      log_it(L_DEBUG, "l_private = %p", l_private );
                       if( l_private ){
 
                           bool l_is_ok = false;
@@ -424,7 +428,6 @@ static void* dap_http_client_thread(void * arg)
                           }
 
                           dap_http_client_internal_delete(l_client_internal);
-
                       } 
                       else {
                         log_it(L_CRITICAL, "Can't get private information from libcurl handle to perform the reply to SAP connection");
diff --git a/http_server/http_client/dap_http_header.c b/http_server/http_client/dap_http_header.c
index fe1301027356cda452eec9efd2a9cc7171050cbb..d5444d4ea1aebdcccc0edce38b8396e53dda9822 100755
--- a/http_server/http_client/dap_http_header.c
+++ b/http_server/http_client/dap_http_header.c
@@ -33,10 +33,10 @@
 #include <io.h>
 #include "wrappers.h"
 #include <wepoll.h>
-#include "../pthread-win32/pthread.h"
-
 #endif
 
+#include <pthread.h>
+
 #include "dap_common.h"
 #include "dap_client_remote.h"
 #include "dap_http_client.h"
@@ -171,7 +171,7 @@ dap_http_header_t * dap_http_out_header_add_f(dap_http_client_t * ht, const char
     dap_http_header_t * ret;
     char buf[1024];
     va_start(ap,value);
-    vsnprintf(buf,sizeof(buf)-1,value,ap);
+    dap_vsnprintf(buf,sizeof(buf)-1,value,ap);
     ret=dap_http_out_header_add(ht,name,buf);
     va_end(ap);
     return ret;
diff --git a/http_server/http_client/dap_http_user_agent.c b/http_server/http_client/dap_http_user_agent.c
index 92b851a65233d0977f39caf661fa8aa1e63a935b..24f6b913cf54036ff2b0bc51eecb870f69a9c6ac 100755
--- a/http_server/http_client/dap_http_user_agent.c
+++ b/http_server/http_client/dap_http_user_agent.c
@@ -18,11 +18,11 @@ static char* _dap_http_user_agent_to_string(dap_http_user_agent_ptr_t a_agent)
     char * result = calloc(1, sizeof(*a_agent));
 
     if(a_agent->comment) {
-        sprintf(result, "%s/%d.%d %s", a_agent->name,
+        dap_sprintf(result, "%s/%d.%d %s", a_agent->name,
                 a_agent->major_version, a_agent->minor_version,
                 a_agent->comment);
     } else {
-        sprintf(result, "%s/%d.%d", a_agent->name,
+        dap_sprintf(result, "%s/%d.%d", a_agent->name,
                 a_agent->major_version, a_agent->minor_version);
     }