Small Code Optimization
This commit is contained in:
parent
c6584ccb8f
commit
5d210dbf06
1 changed files with 49 additions and 85 deletions
130
lweb.pbi
130
lweb.pbi
|
@ -43,28 +43,29 @@ Module lhs_web
|
||||||
Global.i conf_cache_current = 0
|
Global.i conf_cache_current = 0
|
||||||
Global.i conf_cache_enable = 1
|
Global.i conf_cache_enable = 1
|
||||||
|
|
||||||
Enumeration s_client_do ;client_do_cli
|
Enumeration s_client_do ;client_do_cli
|
||||||
#CLI_DO_NOP ;0 Keine Arbeit
|
#CLI_DO_NOP ;Keine Arbeit
|
||||||
#CLI_DO_DataWorking ;10 Datenverarbeitung
|
#CLI_DO_DataWorking ;Datenverarbeitung
|
||||||
#CLI_DO_DataToSend ;20 Daten zum Senden vorhanden
|
#CLI_DO_DataToSend ;Daten zum Senden vorhanden
|
||||||
#CLI_DO_WaitDataReceive ;30 Wartet auf Datenempfang
|
#CLI_DO_WaitDataReceive ;Wartet auf Datenempfang
|
||||||
#CLI_DO_WaitDataSend ;40 Wartet auf gesendete Daten
|
#CLI_DO_WaitDataSend ;Wartet auf gesendete Daten
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
Enumeration s_server_do ;client_do_srv
|
Enumeration s_server_do ;client_do_srv
|
||||||
#SRV_DO_NOP ;0 Keine Arbeit
|
#SRV_DO_NOP ;Keine Arbeit
|
||||||
#SRV_DO_NewDatainBuffer ;10 Neue Daten im incoming Buffer zur bearbeitung.
|
#SRV_DO_NewDatainBuffer ;Neue Daten im incoming Buffer zur bearbeitung.
|
||||||
#SRV_DO_MoreDatainBuffer ;11 Weitere Daten im incoming Buffer
|
#SRV_DO_MoreDatainBuffer ;Weitere Daten im incoming Buffer
|
||||||
#SRV_DO_DataReceive ;12 Datem Empfangen Client Thread muss sich darum Kümmern
|
#SRV_DO_DataReceive ;Datem Empfangen Client Thread muss sich darum Kümmern
|
||||||
#SRV_DO_DataReceiveCompleted ;18 Empfang der Daten Abgeschlossen
|
#SRV_DO_DataReceiveCompleted ;Empfang der Daten Abgeschlossen
|
||||||
#SRV_DO_DataReceiveFailes ;19 Beim Empfangen der Daten ist ein fehler passiert.
|
#SRV_DO_DataReceiveFailes ;Beim Empfangen der Daten ist ein fehler passiert.
|
||||||
#SRV_DO_DataSendOK ;20 Daten erfolgreich gesendet, Thread kann weiterarbeiten.
|
#SRV_DO_DataSendOK ;Daten erfolgreich gesendet, Thread kann weiterarbeiten.
|
||||||
#SRV_DO_DataSendNOK ;29 Daten nicht erfolgreich gesendet.
|
#SRV_DO_DataSendNOK ;Daten nicht erfolgreich gesendet.
|
||||||
#SRV_DO_ClientDisconnect ;99 Beenden des Threads Client hat verbindung getrennt.
|
#SRV_DO_ClientDisconnect ;Beenden des Threads Client hat verbindung getrennt.
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
#http_method_get = "GET"
|
#http_method_get = "GET"
|
||||||
#http_method_post = "POST"
|
#http_method_post = "POST"
|
||||||
|
#http_method_put = "PUT"
|
||||||
|
|
||||||
;***********************
|
;***********************
|
||||||
;* s_lweb_client Struktur Jeder Clientthread muss in die Liste eingetragen werden.:
|
;* s_lweb_client Struktur Jeder Clientthread muss in die Liste eingetragen werden.:
|
||||||
|
@ -558,41 +559,6 @@ Module lhs_web
|
||||||
;}
|
;}
|
||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
|
|
||||||
If thread_data_size
|
|
||||||
If thread_type =""
|
|
||||||
thread_type = mimetype(GetExtensionPart(thread_requested))
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
thread_date = http_day(DayOfWeek(Date())) +
|
|
||||||
Str(Day(Date())) +
|
|
||||||
http_month(Month(Date())) +
|
|
||||||
Str(Year(Date())) +
|
|
||||||
" " +
|
|
||||||
FormatDate("%hh:%ii:%ss GMT+1", Date())
|
|
||||||
|
|
||||||
|
|
||||||
;lweb_srv_mod_mss()
|
|
||||||
ClearMap(Header())
|
|
||||||
If Response(#cha_R_http_head_status) <> ""
|
|
||||||
Header(#http_head_status) = Response(#cha_R_http_head_status)
|
|
||||||
ElseIf response_status <> ""
|
|
||||||
Header(#http_head_status) = response_status
|
|
||||||
Else
|
|
||||||
Header(#http_head_status) = "200 OK"
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
Header(#http_head_content_length) = Str(thread_data_size)
|
|
||||||
Header(#http_head_content_type) = thread_type
|
|
||||||
Header(#http_head_connection) = "Keep-Alive"
|
|
||||||
Header(#http_head_keep_alive) = "timeout=15, max=1000"
|
|
||||||
thread_header = http_header_generate(Header())
|
|
||||||
thread_buffer = AllocateMemory(thread_data_size+StringByteLength(thread_header)+12)
|
|
||||||
thread_buffer_offset = thread_buffer
|
|
||||||
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
|
|
||||||
;}
|
;}
|
||||||
Case #http_method_post
|
Case #http_method_post
|
||||||
|
|
||||||
|
@ -735,39 +701,7 @@ Module lhs_web
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
If thread_data_size
|
|
||||||
If thread_type =""
|
|
||||||
thread_type = mimetype(GetExtensionPart(thread_requested))
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
thread_date = http_day(DayOfWeek(Date())) +
|
|
||||||
Str(Day(Date())) +
|
|
||||||
http_month(Month(Date())) +
|
|
||||||
Str(Year(Date())) +
|
|
||||||
" " +
|
|
||||||
FormatDate("%hh:%ii:%ss GMT+1", Date())
|
|
||||||
|
|
||||||
|
|
||||||
;lweb_srv_mod_mss()
|
|
||||||
ClearMap(Header())
|
|
||||||
If Response(#cha_R_http_head_status) <> ""
|
|
||||||
Header(#http_head_status) = Response(#cha_R_http_head_status)
|
|
||||||
ElseIf response_status <> ""
|
|
||||||
Header(#http_head_status) = response_status
|
|
||||||
Else
|
|
||||||
Header(#http_head_status) = "200 OK"
|
|
||||||
EndIf
|
|
||||||
|
|
||||||
Header(#http_head_content_length) = Str(thread_data_size)
|
|
||||||
Header(#http_head_content_type) = thread_type
|
|
||||||
Header(#http_head_connection) = "Keep-Alive"
|
|
||||||
Header(#http_head_keep_alive) = "timeout=15, max=1000"
|
|
||||||
thread_header = http_header_generate(Header())
|
|
||||||
thread_buffer = AllocateMemory(thread_data_size+StringByteLength(thread_header)+12)
|
|
||||||
thread_buffer_offset = thread_buffer
|
|
||||||
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
|
|
||||||
|
|
||||||
Default
|
Default
|
||||||
;************************************
|
;************************************
|
||||||
|
@ -777,7 +711,37 @@ Module lhs_web
|
||||||
;* Read Buffer to Memory and Clear Buffer to Zero until the complete Networkbuffer from this Client is Cleaned.
|
;* Read Buffer to Memory and Clear Buffer to Zero until the complete Networkbuffer from this Client is Cleaned.
|
||||||
;*
|
;*
|
||||||
EndSelect
|
EndSelect
|
||||||
|
If thread_data_size
|
||||||
|
If thread_type =""
|
||||||
|
thread_type = mimetype(GetExtensionPart(thread_requested))
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
thread_date = http_day(DayOfWeek(Date())) +
|
||||||
|
Str(Day(Date())) +
|
||||||
|
http_month(Month(Date())) +
|
||||||
|
Str(Year(Date())) +
|
||||||
|
" " +
|
||||||
|
FormatDate("%hh:%ii:%ss GMT+1", Date())
|
||||||
|
|
||||||
|
ClearMap(Header())
|
||||||
|
If Response(#cha_R_http_head_status) <> ""
|
||||||
|
Header(#http_head_status) = Response(#cha_R_http_head_status)
|
||||||
|
ElseIf response_status <> ""
|
||||||
|
Header(#http_head_status) = response_status
|
||||||
|
Else
|
||||||
|
Header(#http_head_status) = "200 OK"
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
Header(#http_head_content_length) = Str(thread_data_size)
|
||||||
|
Header(#http_head_content_type) = thread_type
|
||||||
|
Header(#http_head_connection) = "Keep-Alive"
|
||||||
|
Header(#http_head_keep_alive) = "timeout=15, max=1000"
|
||||||
|
thread_header = http_header_generate(Header())
|
||||||
|
thread_buffer = AllocateMemory(thread_data_size+StringByteLength(thread_header)+12)
|
||||||
|
thread_buffer_offset = thread_buffer
|
||||||
|
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)
|
CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size)
|
||||||
FreeMemory(thread_temp_cache_memory)
|
FreeMemory(thread_temp_cache_memory)
|
||||||
; EndIf
|
; EndIf
|
||||||
|
|
Loading…
Reference in a new issue