diff --git a/enc_server/dap_enc_http.c b/enc_server/dap_enc_http.c
index 7f2e4a76d9a60b58d5d53bfc90584dad23fe49c4..ba7d4f7d20d53197ab48a77a04a2f6997f3a9302 100644
--- a/enc_server/dap_enc_http.c
+++ b/enc_server/dap_enc_http.c
@@ -34,6 +34,7 @@
 #include "dap_enc_http.h"
 #include "dap_enc_base64.h"
 #include "dap_enc_msrln.h"
+#include "http_status_code.h"
 
 
 #define LOG_TAG "dap_enc_http"
@@ -56,7 +57,7 @@ void enc_http_deinit()
 void enc_http_proc(struct dap_http_simple *cl_st, void * arg)
 {
     log_it(L_DEBUG,"Proc enc http request");
-    bool * isOk= (bool*)arg;
+    http_status_code_t * return_code = (http_status_code_t*)arg;
 
     if(strcmp(cl_st->http->url_path,"gd4y5yh78w42aaagh") == 0 ) {
 
@@ -64,7 +65,7 @@ void enc_http_proc(struct dap_http_simple *cl_st, void * arg)
         size_t decode_len = dap_enc_base64_decode(cl_st->request, cl_st->request_size, alice_msg, DAP_ENC_DATA_TYPE_B64);
         if(decode_len != MSRLN_PKA_BYTES) {
             log_it(L_WARNING, "Wrong http_enc request. Key not equal MSRLN_PKA_BYTES");
-            *isOk=false;
+            *return_code = Http_Status_BadRequest;
             return;
         }
 
@@ -92,9 +93,11 @@ void enc_http_proc(struct dap_http_simple *cl_st, void * arg)
         dap_http_simple_reply_f(cl_st, "%s %s", encrypt_id, encrypt_msg);
 
         dap_enc_key_delete(msrln_key);
+
+        *return_code = Http_Status_OK;
     } else{
         log_it(L_ERROR,"Wrong path '%s' in the request to enc_http module",cl_st->http->url_path);
-        *isOk=false;
+        *return_code = Http_Status_NotFound;
     }
 }
 
@@ -121,7 +124,7 @@ enc_http_delegate_t *enc_http_request_decode(struct dap_http_simple *a_http_simp
         enc_http_delegate_t * dg = DAP_NEW_Z(enc_http_delegate_t);
         dg->key=l_key;
         dg->http=a_http_simple->http;
-        dg->isOk=true;
+       // dg->isOk=true;
 
         strncpy(dg->action,a_http_simple->http->action,sizeof(dg->action)-1);
         if(a_http_simple->http->in_cookie[0])
diff --git a/http_server/CMakeLists.txt b/http_server/CMakeLists.txt
index eee0d5ee533d34117083b8e4d006bc5c31fd5dfb..27724d87cbbd25e7f04c0a7671ed4e4b9e0a17e6 100644
--- a/http_server/CMakeLists.txt
+++ b/http_server/CMakeLists.txt
@@ -7,7 +7,6 @@ set(HTTP_SERVER_SRCS
     dap_http.c
     dap_http_folder.c
     dap_http_simple.c
-    dap_http_simple.h
     http_client/dap_http_client.c
     http_client/dap_http_client_simple.c
     http_client/dap_http_header.c)
diff --git a/http_server/dap_http_simple.c b/http_server/dap_http_simple.c
index cf5db6bc469e8b7cf2025dd47bf7a23234f36ed0..3aa22ca249feaf9ff2708c171cf816eca2dd43c8 100644
--- a/http_server/dap_http_simple.c
+++ b/http_server/dap_http_simple.c
@@ -31,6 +31,7 @@
 #include "dap_enc_key.h"
 #include "../enc_server/dap_enc_ks.h"
 #include "../enc_server/dap_enc_http.h"
+#include "http_status_code.h"
 #include <ev.h>
 #include <sys/queue.h>
 
@@ -127,57 +128,54 @@ void dap_http_simple_proc_add(dap_http_t *sh, const char * url_path, size_t repl
 void* dap_http_simple_proc(dap_http_simple_t * cl_sh)
 {
     log_it(L_INFO, "dap http simple proc");
-    bool is_ok=true;
-    bool key_is_expiried = false;
-
-    dap_enc_key_t * key = dap_enc_ks_find_http(cl_sh->http);
-    if(key){
-        if( key->last_used_timestamp && ( (time(NULL) - key->last_used_timestamp  )
-                                          > s_TTL_session_key ) ) {
-
-            enc_http_delegate_t * dg = enc_http_request_decode(cl_sh);
-
-            if( dg == NULL ) {
-                log_it(L_ERROR, "dg is NULL");
-                return NULL;
-            }
-
-            log_it(L_WARNING, "Key has been expiried");
-            strcpy(cl_sh->reply_mime,"text/plain");
-            enc_http_reply_f(dg,"Key has been expiried");
-            enc_http_reply_encode(cl_sh,dg);
-            enc_http_delegate_delete(dg);
-            key_is_expiried = true;
-        } else{
-            key->last_used_timestamp = time(NULL);
-        }
+    http_status_code_t return_code = (http_status_code_t)0;
+//    bool key_is_expiried = false;
 
-    }
+//    dap_enc_key_t * key = dap_enc_ks_find_http(cl_sh->http);
+//    if(key){
+//        if( key->last_used_timestamp && ( (time(NULL) - key->last_used_timestamp  )
+//                                          > s_TTL_session_key ) ) {
 
-    if ( !key_is_expiried )
-        DAP_HTTP_SIMPLE_URL_PROC(cl_sh->http->proc)->proc_callback(cl_sh,&is_ok);
+//            enc_http_delegate_t * dg = enc_http_request_decode(cl_sh);
 
-    if(is_ok){
-        log_it(L_DEBUG, "Request was processed well");
+//            if( dg == NULL ) {
+//                log_it(L_ERROR, "dg is NULL");
+//                return NULL;
+//            }
+
+//            log_it(L_WARNING, "Key has been expiried");
+//            strcpy(cl_sh->reply_mime,"text/plain");
+//            enc_http_reply_f(dg,"Key has been expiried");
+//            enc_http_reply_encode(cl_sh,dg);
+//            enc_http_delegate_delete(dg);
+//            key_is_expiried = true;
+//        } else{
+//            key->last_used_timestamp = time(NULL);
+//        }
+//    }
+
+//    if ( !key_is_expiried )
 
-        cl_sh->http->out_content_length=cl_sh->reply_size;
-        strcpy(cl_sh->http->out_content_type, cl_sh->reply_mime);
+    DAP_HTTP_SIMPLE_URL_PROC(cl_sh->http->proc)->proc_callback(cl_sh,&return_code);
 
-        strcpy(cl_sh->http->reply_reason_phrase,"OK");
-        cl_sh->http->reply_status_code=200;
-        //cl_sh->http->client->ready_to_write=true;
+    if(return_code) {
+        log_it(L_DEBUG, "Request was processed well");
+        cl_sh->http->reply_status_code = (uint16_t)return_code;
+        if(cl_sh->reply_size != 0) {
+            cl_sh->http->out_content_length=cl_sh->reply_size;
+            strcpy(cl_sh->http->out_content_type, cl_sh->reply_mime);
+        }
     }else{
         log_it(L_ERROR, "Request was processed with ERROR");
-        strcpy(cl_sh->http->reply_reason_phrase,"ERROR");
-        cl_sh->http->reply_status_code=500;
-        //cl_sh->http->client->ready_to_read=false;
-        //cl_sh->http->client->ready_to_write=false;
+        cl_sh->http->reply_status_code = Http_Status_InternalServerError;
     }
     dap_client_remote_ready_to_read(cl_sh->http->client,false);
     cl_sh->http->state_write=DAP_HTTP_CLIENT_STATE_NONE;
 
     dap_client_remote_ready_to_write(cl_sh->http->client,true);
     cl_sh->http->state_write=DAP_HTTP_CLIENT_STATE_START;
+
+    return NULL;
 }
 
 /**
diff --git a/http_server/http_client/dap_http_client.c b/http_server/http_client/dap_http_client.c
index f020bb9a03eae76fa8a3650c3e4393a5bb7b6fa3..9c9c177f0f615b973e57cf2e6404bde947e7b7fb 100644
--- a/http_server/http_client/dap_http_client.c
+++ b/http_server/http_client/dap_http_client.c
@@ -27,6 +27,7 @@
 #include "dap_client_remote.h"
 
 #include "../dap_http.h"
+#include "../http_status_code.h"
 
 #include "dap_http_header.h"
 #include "dap_http_client.h"
@@ -347,7 +348,8 @@ void dap_http_client_write(dap_client_remote_t * cl,void * arg)
                 if(cl_ht->proc->headers_write_callback)
                     cl_ht->proc->headers_write_callback(cl_ht,NULL);
             log_it(L_DEBUG,"Output: HTTP response with %u status code",cl_ht->reply_status_code);
-            dap_client_remote_write_f(cl,"HTTP/1.1 %u %s\r\n",cl_ht->reply_status_code, cl_ht->reply_reason_phrase[0]?cl_ht->reply_reason_phrase:"UNDEFINED");
+            dap_client_remote_write_f(cl,"HTTP/1.1 %u %s\r\n",cl_ht->reply_status_code, cl_ht->reply_reason_phrase[0] ?
+                        cl_ht->reply_reason_phrase : http_status_reason_phrase(cl_ht->reply_status_code));
             dap_http_client_out_header_generate(cl_ht);
 
             cl_ht->state_write=DAP_HTTP_CLIENT_STATE_HEADERS;
diff --git a/http_server/http_client/dap_http_client.h b/http_server/http_client/dap_http_client.h
index 374fbe96c0ea9d2309c6517d2ff7ed8a2745ed79..33acaf2cbf1506a4f1aeae94dc328c766f14294c 100644
--- a/http_server/http_client/dap_http_client.h
+++ b/http_server/http_client/dap_http_client.h
@@ -68,7 +68,7 @@ typedef struct dap_http_client
     dap_client_remote_t * client;
     struct dap_http * http;
 
-    uint32_t reply_status_code;
+    uint16_t reply_status_code;
     char reply_reason_phrase[256];
 
     struct dap_http_url_proc * proc;
diff --git a/http_server/http_status_code.h b/http_server/http_status_code.h
index b45f5f21199acf7a16c004190f9ccc29155b380a..e518c19fa4c7613ed25cdd41ab67b0cdb654dbca 100644
--- a/http_server/http_status_code.h
+++ b/http_server/http_status_code.h
@@ -1,3 +1,5 @@
+#include "stdio.h"
+
 #ifndef HTTP_STATUS_CODE_DEFINITIONS_H
 #define HTTP_STATUS_CODE_DEFINITIONS_H
 
@@ -112,7 +114,7 @@ static char http_status_is_error(int code)         { return (code >= 400); }
  * \return The standard HTTP reason phrase for the given \p code or \c NULL if no standard
  * phrase for the given \p code is known.
  */
-static const char* http_status_reason_phrase(int code)
+static const char* http_status_reason_phrase(unsigned short code)
 {
     switch (code)
     {
@@ -187,7 +189,9 @@ static const char* http_status_reason_phrase(int code)
     case 510: return "Not Extended";
     case 511: return "Network Authentication Required";
 
-    default: return 0;
+    default:
+        fprintf(stderr, "Unknown status code %d\n", code);
+        return 0;
     }
 
 }