diff --git a/lweb.pbi b/lweb.pbi index bdf35a6..3d0de59 100644 --- a/lweb.pbi +++ b/lweb.pbi @@ -39,7 +39,7 @@ Module lhs_web Global.i conf_cache_time = 120 ;120Sekunden Global.i conf_cache_maxsize = 1 ;1 Mbyte Global.i conf_cache_current = 0 - Global.i conf_cache_enable = 1 + Global.i conf_cache_enable = 0 Global.i conf_TLS_Port = 8443 Global.s conf_TLS_binding = "127.0.0.1" Global.i conf_TLS_enable = 0 ;SSL Server @@ -431,6 +431,7 @@ Module lhs_web Protected thread_data_size, thread_file_handle Protected.s thread_requested, thread_type, thread_date, thread_header, thread_work, JSONStringToMap, Handler_Response, response_status, PostMapString Protected thread_buffer, thread_buffer_offset, thread_buffer_length, buffer_sent + Protected sent_length, sent_buffer_address, sent_total Protected.b thread_alive = #True, error_message = #False Define NewMap Header.s() Define NewMap Response.s() @@ -527,7 +528,7 @@ Module lhs_web thread_work = PeekS(m_clients(Str(thread_cli_id))\datenbuffer()\Buffer, m_clients(Str(thread_cli_id))\datenbuffer()\Size, #PB_Ascii) ;Header to Map - Debug "Datenbuffer:"+ Mid(thread_work,1,256) + ;Debug "Datenbuffer:"+ Mid(thread_work,1,256) JSONStringToMap = Work_Header_to_JSONMap(thread_work) If JSONStringToMap <> #error_string MyThreadJSON = ParseJSON(#PB_Any, JSONStringToMap) @@ -545,7 +546,7 @@ Module lhs_web - Debug "JSONString:"+ JSONStringToMap + ;Debug "JSONString:"+ JSONStringToMap thread_type = "" Select Header(#http_head_method) Case #http_method_get @@ -841,8 +842,13 @@ Module lhs_web thread_buffer_length = PokeS(thread_buffer_offset, thread_header,-1, #PB_UTF8|#PB_String_NoZero) : thread_buffer_offset + thread_buffer_length Debug "Header Finished" EndIf - CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size) - FreeMemory(thread_temp_cache_memory) + If thread_temp_cache_memory <> 0 And thread_buffer_offset <> 0 And thread_data_size <> 0 + CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size) + FreeMemory(thread_temp_cache_memory) + Else + Debug "File Buffer Troubles." + EndIf + ; EndIf Debug "HTTP File Buffer Cleaned." @@ -853,8 +859,26 @@ Module lhs_web DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer()) ;Daten Senden... ;TODO: SSL Send + sent_total = thread_data_size+(thread_buffer_offset-thread_buffer) If m_clients(Str(thread_cli_id))\client_ssl = 1 - sent = ltls::WriteTLSSocket(thread_cli_id, thread_buffer , thread_data_size+(thread_buffer_offset-thread_buffer)) + sent_length = sent_total + sent_buffer_address = thread_buffer + sent_total = 0 + Repeat + sent = ltls::WriteTLSSocket(thread_cli_id, sent_buffer_address , sent_length) + If sent <> -1 + Debug "TLS Sent:"+Str(sent)+" bytes" + sent_length - sent + sent_buffer_address + sent + sent_total + sent + Else + Debug "TLS Sent error:"+ltls::ErrorTLSCli(thread_cli_id) + EndIf + + Until sent_length <= 0 + sent = sent_total + thread_alive = #False + Else sent = SendNetworkData(thread_cli_id, thread_buffer , thread_data_size+(thread_buffer_offset-thread_buffer)) EndIf @@ -867,7 +891,7 @@ Module lhs_web m_clients(Str(thread_cli_id))\client_do_srv = #SRV_DO_NOP Else ;Fehler beim Senden ... Thread beenden. - Debug "Fehler" + Debug "Fehler:" + Str(Sent) thread_alive = #False EndIf @@ -892,6 +916,9 @@ Module lhs_web DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer()) EndIf Wend + If m_clients(Str(thread_cli_id))\client_ssl = 1 + ltls::CloseTLSSocket(thread_cli_id) + EndIf DeleteMapElement(m_clients(), Str(thread_cli_id)) Debug "Thread Beendet."