Small Code Optimization
This commit is contained in:
parent
c6584ccb8f
commit
5d210dbf06
1 changed files with 49 additions and 85 deletions
86
lweb.pbi
86
lweb.pbi
|
@ -44,27 +44,28 @@ Module lhs_web
|
|||
Global.i conf_cache_enable = 1
|
||||
|
||||
Enumeration s_client_do ;client_do_cli
|
||||
#CLI_DO_NOP ;0 Keine Arbeit
|
||||
#CLI_DO_DataWorking ;10 Datenverarbeitung
|
||||
#CLI_DO_DataToSend ;20 Daten zum Senden vorhanden
|
||||
#CLI_DO_WaitDataReceive ;30 Wartet auf Datenempfang
|
||||
#CLI_DO_WaitDataSend ;40 Wartet auf gesendete Daten
|
||||
#CLI_DO_NOP ;Keine Arbeit
|
||||
#CLI_DO_DataWorking ;Datenverarbeitung
|
||||
#CLI_DO_DataToSend ;Daten zum Senden vorhanden
|
||||
#CLI_DO_WaitDataReceive ;Wartet auf Datenempfang
|
||||
#CLI_DO_WaitDataSend ;Wartet auf gesendete Daten
|
||||
EndEnumeration
|
||||
|
||||
Enumeration s_server_do ;client_do_srv
|
||||
#SRV_DO_NOP ;0 Keine Arbeit
|
||||
#SRV_DO_NewDatainBuffer ;10 Neue Daten im incoming Buffer zur bearbeitung.
|
||||
#SRV_DO_MoreDatainBuffer ;11 Weitere Daten im incoming Buffer
|
||||
#SRV_DO_DataReceive ;12 Datem Empfangen Client Thread muss sich darum Kümmern
|
||||
#SRV_DO_DataReceiveCompleted ;18 Empfang der Daten Abgeschlossen
|
||||
#SRV_DO_DataReceiveFailes ;19 Beim Empfangen der Daten ist ein fehler passiert.
|
||||
#SRV_DO_DataSendOK ;20 Daten erfolgreich gesendet, Thread kann weiterarbeiten.
|
||||
#SRV_DO_DataSendNOK ;29 Daten nicht erfolgreich gesendet.
|
||||
#SRV_DO_ClientDisconnect ;99 Beenden des Threads Client hat verbindung getrennt.
|
||||
#SRV_DO_NOP ;Keine Arbeit
|
||||
#SRV_DO_NewDatainBuffer ;Neue Daten im incoming Buffer zur bearbeitung.
|
||||
#SRV_DO_MoreDatainBuffer ;Weitere Daten im incoming Buffer
|
||||
#SRV_DO_DataReceive ;Datem Empfangen Client Thread muss sich darum Kümmern
|
||||
#SRV_DO_DataReceiveCompleted ;Empfang der Daten Abgeschlossen
|
||||
#SRV_DO_DataReceiveFailes ;Beim Empfangen der Daten ist ein fehler passiert.
|
||||
#SRV_DO_DataSendOK ;Daten erfolgreich gesendet, Thread kann weiterarbeiten.
|
||||
#SRV_DO_DataSendNOK ;Daten nicht erfolgreich gesendet.
|
||||
#SRV_DO_ClientDisconnect ;Beenden des Threads Client hat verbindung getrennt.
|
||||
EndEnumeration
|
||||
|
||||
#http_method_get = "GET"
|
||||
#http_method_post = "POST"
|
||||
#http_method_put = "PUT"
|
||||
|
||||
;***********************
|
||||
;* s_lweb_client Struktur Jeder Clientthread muss in die Liste eingetragen werden.:
|
||||
|
@ -558,41 +559,6 @@ Module lhs_web
|
|||
;}
|
||||
|
||||
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
|
||||
|
||||
|
@ -735,6 +701,16 @@ Module lhs_web
|
|||
EndIf
|
||||
|
||||
EndIf
|
||||
|
||||
|
||||
Default
|
||||
;************************************
|
||||
;*
|
||||
;* Not a supported Command in HTTP Header Cleanup.
|
||||
;*
|
||||
;* Read Buffer to Memory and Clear Buffer to Zero until the complete Networkbuffer from this Client is Cleaned.
|
||||
;*
|
||||
EndSelect
|
||||
If thread_data_size
|
||||
If thread_type =""
|
||||
thread_type = mimetype(GetExtensionPart(thread_requested))
|
||||
|
@ -747,8 +723,6 @@ Module lhs_web
|
|||
" " +
|
||||
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)
|
||||
|
@ -768,16 +742,6 @@ 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
|
||||
|
||||
Default
|
||||
;************************************
|
||||
;*
|
||||
;* Not a supported Command in HTTP Header Cleanup.
|
||||
;*
|
||||
;* Read Buffer to Memory and Clear Buffer to Zero until the complete Networkbuffer from this Client is Cleaned.
|
||||
;*
|
||||
EndSelect
|
||||
|
||||
CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size)
|
||||
FreeMemory(thread_temp_cache_memory)
|
||||
; EndIf
|
||||
|
|
Loading…
Reference in a new issue