configuration variabel cleanup
This commit is contained in:
parent
02875d9be4
commit
07c1b19efe
6 changed files with 170 additions and 98 deletions
|
@ -16,7 +16,7 @@ Procedure FileCacheCleaner(Information.i)
|
||||||
m_file_cache(MapKey(m_file_cache_map()))\Timer - 1
|
m_file_cache(MapKey(m_file_cache_map()))\Timer - 1
|
||||||
If m_file_cache(MapKey(m_file_cache_map()))\Timer <= 0
|
If m_file_cache(MapKey(m_file_cache_map()))\Timer <= 0
|
||||||
If m_file_cache(MapKey(m_file_cache_map()))\Buffer > 0
|
If m_file_cache(MapKey(m_file_cache_map()))\Buffer > 0
|
||||||
conf_cache_current - m_file_cache(MapKey(m_file_cache_map()))\Size
|
configuration\cache\current - m_file_cache(MapKey(m_file_cache_map()))\Size
|
||||||
FreeMemory(m_file_cache(MapKey(m_file_cache_map()))\Buffer)
|
FreeMemory(m_file_cache(MapKey(m_file_cache_map()))\Buffer)
|
||||||
DeleteMapElement(m_file_cache(), MapKey(m_file_cache_map()))
|
DeleteMapElement(m_file_cache(), MapKey(m_file_cache_map()))
|
||||||
Debug "Info:["+Str(innercount)+"] Killed:["+MapKey(m_file_cache_map())+"]"
|
Debug "Info:["+Str(innercount)+"] Killed:["+MapKey(m_file_cache_map())+"]"
|
||||||
|
@ -41,18 +41,18 @@ Procedure FileCache(Information.i)
|
||||||
;http://purearea.net/pb/english/manual/reference/ug_memory.html
|
;http://purearea.net/pb/english/manual/reference/ug_memory.html
|
||||||
Protected FileCacheCleanerThread.i
|
Protected FileCacheCleanerThread.i
|
||||||
Protected Tempbuffer.i, MaxSize.i, Current.i
|
Protected Tempbuffer.i, MaxSize.i, Current.i
|
||||||
MaxSize = conf_cache_maxsize * 1024 * 1024
|
MaxSize = configuration\cache\maxsize * 1024 * 1024
|
||||||
FileCacheCleanerThread = CreateThread(@FileCacheCleaner(), MaxSize)
|
FileCacheCleanerThread = CreateThread(@FileCacheCleaner(), MaxSize)
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
WaitSemaphore(file_cache_semaphore)
|
WaitSemaphore(file_cache_semaphore)
|
||||||
Debug "Adresse:"+m_file_cache()\Buffer
|
Debug "Adresse:"+m_file_cache()\Buffer
|
||||||
If (m_file_cache()\Size + conf_cache_current) <= MaxSize
|
If (m_file_cache()\Size + configuration\cache\current) <= MaxSize
|
||||||
conf_cache_current + m_file_cache()\Size
|
configuration\cache\current + m_file_cache()\Size
|
||||||
Tempbuffer = AllocateMemory(m_file_cache()\Size)
|
Tempbuffer = AllocateMemory(m_file_cache()\Size)
|
||||||
CopyMemory(m_file_cache()\Buffer, Tempbuffer, MemorySize(m_file_cache()\Buffer))
|
CopyMemory(m_file_cache()\Buffer, Tempbuffer, MemorySize(m_file_cache()\Buffer))
|
||||||
m_file_cache()\Buffer = Tempbuffer
|
m_file_cache()\Buffer = Tempbuffer
|
||||||
m_file_cache()\Timer = conf_cache_time
|
m_file_cache()\Timer = configuration\cache\time
|
||||||
m_file_cache()\Is = #True
|
m_file_cache()\Is = #True
|
||||||
m_file_cache_map(MapKey(m_file_cache())) = #True
|
m_file_cache_map(MapKey(m_file_cache())) = #True
|
||||||
SignalSemaphore(file_cache_semaphore_thread)
|
SignalSemaphore(file_cache_semaphore_thread)
|
||||||
|
@ -66,7 +66,7 @@ EndProcedure
|
||||||
|
|
||||||
Procedure AddFileToCache(MemoryID.i, FileName.s, Size.i)
|
Procedure AddFileToCache(MemoryID.i, FileName.s, Size.i)
|
||||||
LockMutex(file_cache_mutex)
|
LockMutex(file_cache_mutex)
|
||||||
Debug "Cache MaxSize:"+Str(conf_cache_maxsize*1024*1024)+" Actual Size:"+Str(conf_cache_current)
|
Debug "Cache MaxSize:"+Str(configuration\cache\maxsize*1024*1024)+" Actual Size:"+Str(configuration\cache\current)
|
||||||
m_file_cache(FileName)\Buffer = MemoryID
|
m_file_cache(FileName)\Buffer = MemoryID
|
||||||
m_file_cache(FileName)\Size = Size
|
m_file_cache(FileName)\Size = Size
|
||||||
SignalSemaphore(file_cache_semaphore)
|
SignalSemaphore(file_cache_semaphore)
|
||||||
|
@ -74,7 +74,7 @@ Procedure AddFileToCache(MemoryID.i, FileName.s, Size.i)
|
||||||
If m_file_cache(FileName)\Is
|
If m_file_cache(FileName)\Is
|
||||||
Debug FileName+" Size:"+Str(m_file_cache(FileName)\Size)+" Timer:"+Str(m_file_cache(FileName)\Timer)+ " new Memory ID:"+Str(m_file_cache(FileName)\Buffer)
|
Debug FileName+" Size:"+Str(m_file_cache(FileName)\Size)+" Timer:"+Str(m_file_cache(FileName)\Timer)+ " new Memory ID:"+Str(m_file_cache(FileName)\Buffer)
|
||||||
Else
|
Else
|
||||||
Debug "File not in cache was to full:"+FileName+ " MaxSize:"+Str(conf_cache_maxsize)+" Actual Size:"+Str(conf_cache_current/1024/1024)
|
Debug "File not in cache was to full:"+FileName+ " MaxSize:"+Str(configuration\cache\maxsize)+" Actual Size:"+Str(configuration\cache\current/1024/1024)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
UnlockMutex(file_cache_mutex)
|
UnlockMutex(file_cache_mutex)
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
Str(Year(Date())) +
|
Str(Year(Date())) +
|
||||||
" " +
|
" " +
|
||||||
FormatDate("%hh:%ii:%ss GMT+1", Date()) : EndIf
|
FormatDate("%hh:%ii:%ss GMT+1", Date()) : EndIf
|
||||||
If Not FindMapElement(Header(), #http_head_server) : Header(#http_head_server) = conf_titel : EndIf
|
If Not FindMapElement(Header(), #http_head_server) : Header(#http_head_server) = configuration\identifikation : EndIf
|
||||||
If Not FindMapElement(Header(), #http_head_content_length) : Header(#http_head_content_length) = "0" : EndIf
|
If Not FindMapElement(Header(), #http_head_content_length) : Header(#http_head_content_length) = "0" : EndIf
|
||||||
If Not FindMapElement(Header(), #http_head_content_type) : Header(#http_head_content_type) = "text/txt" : EndIf
|
If Not FindMapElement(Header(), #http_head_content_type) : Header(#http_head_content_type) = "text/txt" : EndIf
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,11 @@ EndIf
|
||||||
;*
|
;*
|
||||||
|
|
||||||
If lhs_web::start_server()
|
If lhs_web::start_server()
|
||||||
lhs_log::Out("Server gestartet" + lhs_web::get_config(lhs_web::#conf_port)
|
lhs_log::Out("Server started:")
|
||||||
|
lhs_log::Out("HTTP Port:"+ lhs_web::get_config(lhs_web::#conf_HTTP_port)
|
||||||
|
lhs_log::Out("HTTPS Port:"+ lhs_web::get_config(lhs_web::#conf_HTTPS_port)
|
||||||
Else
|
Else
|
||||||
lhs_log::Out("Fehlgeschlagen"
|
lhs_log::Out("Serverstart failed."
|
||||||
End
|
End
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
|
|
200
lweb.pbi
200
lweb.pbi
|
@ -18,36 +18,84 @@ Module lhs_web
|
||||||
;*
|
;*
|
||||||
;{
|
;{
|
||||||
|
|
||||||
|
;*
|
||||||
|
;* Configuration Structures
|
||||||
|
;*
|
||||||
|
;{
|
||||||
|
Structure server_http
|
||||||
|
enabled.i
|
||||||
|
port.i
|
||||||
|
binding.s
|
||||||
|
max_clients.i
|
||||||
|
EndStructure
|
||||||
|
|
||||||
|
Structure server_https
|
||||||
|
enabled.i
|
||||||
|
port.i
|
||||||
|
binding.s
|
||||||
|
max_clients.i
|
||||||
|
CA.s
|
||||||
|
Certs.s
|
||||||
|
key.s
|
||||||
|
key_pass.s
|
||||||
|
EndStructure
|
||||||
|
|
||||||
|
Structure server_cache
|
||||||
|
time.i
|
||||||
|
maxsize.i
|
||||||
|
current.i
|
||||||
|
enable.i
|
||||||
|
EndStructure
|
||||||
|
|
||||||
|
Structure server
|
||||||
|
http.server_http
|
||||||
|
https.server_https
|
||||||
|
cache.server_cache
|
||||||
|
version.s
|
||||||
|
identifikation.s
|
||||||
|
defaultfile.s
|
||||||
|
basedir.s
|
||||||
|
error400.s
|
||||||
|
type.i
|
||||||
|
EndStructure
|
||||||
|
;}
|
||||||
|
;*
|
||||||
|
|
||||||
;*
|
;*
|
||||||
;* Identifikation des Servers.
|
;* Identifikation des Servers.
|
||||||
;*
|
;*
|
||||||
|
|
||||||
Global.s conf_version = "V0.9"
|
Global configuration.server
|
||||||
Global.s conf_titel = "LiHaSo Webserver " + conf_version
|
configuration\version = "V0.9"
|
||||||
|
configuration\identifikation = "LiHaSo Webserver " + configuration\version
|
||||||
|
|
||||||
;*
|
;*
|
||||||
;* Diese Parameter müssen entsprechend angepasst sein.
|
;* Diese Parameter müssen entsprechend angepasst sein.
|
||||||
;* Später ausgelagert in ein nicht synchronisiertes lweb-cfg.pbi
|
;* Später ausgelagert in ein nicht synchronisiertes lweb-cfg.pbi
|
||||||
;* Folgende Parameter müssen im Hauptprogramm definiert sein.
|
;* Folgende Parameter müssen im Hauptprogramm definiert sein.
|
||||||
Global.s conf_defaultfile = "index.html"
|
configuration\defaultfile = "index.html"
|
||||||
Global.s conf_basedir = "/srv/lweb-srv/"
|
configuration\basedir = "/srv/lweb-srv/"
|
||||||
Global.s conf_error400 = "integrated" ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
configuration\error400 = "integrated" ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
||||||
Global.i conf_max_HTTP_clients = 10 ; Max sametime HTTP connections.
|
configuration\type = 0
|
||||||
Global.i conf_max_HTTPS_clients = 100 ; Max sametime HTTPS connections.
|
|
||||||
Global.i conf_server_type = 0
|
configuration\http\max_clients = 10 ; Max sametime HTTP connections.
|
||||||
Global.i conf_HTTP_port = 8080
|
configuration\http\port = 8080
|
||||||
Global.s conf_HTTP_binding = "127.0.0.1"
|
configuration\http\binding = "127.0.0.1"
|
||||||
Global.i conf_cache_time = 120 ;120Sekunden
|
|
||||||
Global.i conf_cache_maxsize = 1 ;1 Mbyte
|
configuration\https\max_clients = 100
|
||||||
Global.i conf_cache_current = 0
|
configuration\https\port = 8443
|
||||||
Global.i conf_cache_enable = 0
|
configuration\https\binding = "127.0.0.1"
|
||||||
Global.i conf_HTTPS_Port = 8443
|
configuration\https\enabled = 0
|
||||||
Global.s conf_HTTPS_binding = "127.0.0.1"
|
configuration\https\CA = ""
|
||||||
Global.i conf_HTTPS_enable = 0 ;SSL Server
|
configuration\https\Certs = ""
|
||||||
Global.s conf_HTTPS_CA = ""
|
configuration\https\key = ""
|
||||||
Global.s conf_HTTPS_Cert = ""
|
configuration\https\key_pass = ""
|
||||||
Global.s conf_HTTPS_Key = ""
|
|
||||||
Global.s conf_HTTPS_Key_Pass = ""
|
configuration\cache\enable = 0 ; Enable / Disable Cached Server
|
||||||
|
configuration\cache\time = 120 ; TTL of cached files
|
||||||
|
configuration\cache\maxsize = 1 ; Max Cache
|
||||||
|
configuration\cache\current = 0 ;
|
||||||
|
|
||||||
|
|
||||||
Enumeration s_client_do ;client_do_cli
|
Enumeration s_client_do ;client_do_cli
|
||||||
#CLI_DO_NOP ;Keine Arbeit
|
#CLI_DO_NOP ;Keine Arbeit
|
||||||
|
@ -143,7 +191,7 @@ Module lhs_web
|
||||||
Global.i file_cache_semaphore_thread = CreateSemaphore()
|
Global.i file_cache_semaphore_thread = CreateSemaphore()
|
||||||
Global NewMap m_file_cache_map.i()
|
Global NewMap m_file_cache_map.i()
|
||||||
Global NewMap m_file_cache.s_file_cache()
|
Global NewMap m_file_cache.s_file_cache()
|
||||||
Global NewMap m_clients.s_clients(conf_max_HTTP_clients+conf_max_HTTPS_clients)
|
Global NewMap m_clients.s_clients(configuration\http\max_clients+configuration\https\max_clients)
|
||||||
Global NewMap m_request.s_request_handler()
|
Global NewMap m_request.s_request_handler()
|
||||||
|
|
||||||
;}
|
;}
|
||||||
|
@ -189,57 +237,57 @@ Module lhs_web
|
||||||
Procedure set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
|
Procedure set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
|
||||||
Select parameter
|
Select parameter
|
||||||
Case #conf_HTTP_port
|
Case #conf_HTTP_port
|
||||||
conf_HTTP_port = Val(setting)
|
configuration\http\port = Val(setting)
|
||||||
Case #conf_HTTPS_Port
|
Case #conf_HTTPS_Port
|
||||||
conf_HTTPS_Port = Val(setting)
|
configuration\https\port = Val(setting)
|
||||||
Case #conf_HTTP_binding
|
Case #conf_HTTP_binding
|
||||||
If IsIPStringValid(setting)
|
If IsIPStringValid(setting)
|
||||||
conf_HTTP_binding = setting
|
configuration\http\binding = setting
|
||||||
Else
|
Else
|
||||||
conf_HTTP_binding = "127.0.0.1"
|
configuration\http\binding = "127.0.0.1"
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndIf
|
EndIf
|
||||||
Case #conf_HTTPS_Binding
|
Case #conf_HTTPS_Binding
|
||||||
If IsIPStringValid(setting)
|
If IsIPStringValid(setting)
|
||||||
conf_HTTP_binding = setting
|
configuration\https\binding = setting
|
||||||
Else
|
Else
|
||||||
conf_HTTP_binding = "127.0.0.1"
|
configuration\https\binding = "127.0.0.1"
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndIf
|
EndIf
|
||||||
Case #conf_HTTPS_CA
|
Case #conf_HTTPS_CA
|
||||||
conf_HTTPS_CA = setting
|
configuration\https\CA = setting
|
||||||
Case #conf_HTTPS_Cert
|
Case #conf_HTTPS_Cert
|
||||||
conf_HTTPS_Cert = setting
|
configuration\https\Certs = setting
|
||||||
Case #conf_HTTPS_Key
|
Case #conf_HTTPS_Key
|
||||||
conf_HTTPS_Key = setting
|
configuration\https\Key = setting
|
||||||
Case #conf_HTTPS_Key_Pass
|
Case #conf_HTTPS_Key_Pass
|
||||||
conf_HTTPS_Key_Pass = setting
|
configuration\https\key_pass = setting
|
||||||
Case #conf_HTTPS_Enable
|
Case #conf_HTTPS_Enable
|
||||||
conf_HTTPS_enable = Val(setting)
|
configuration\https\enabled = Val(setting)
|
||||||
Case #conf_defaultfile
|
Case #conf_defaultfile
|
||||||
conf_defaultfile = setting
|
configuration\defaultfile = setting
|
||||||
Case #conf_basedir
|
Case #conf_basedir
|
||||||
conf_basedir = setting
|
configuration\basedir = setting
|
||||||
Case #conf_error400
|
Case #conf_error400
|
||||||
conf_error400 = setting ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
configuration\error400 = setting ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
||||||
Case #conf_max_HTTP_clients
|
Case #conf_max_HTTP_clients
|
||||||
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
||||||
conf_max_HTTP_clients = Val(setting)
|
configuration\http\max_clients = Val(setting)
|
||||||
Else
|
Else
|
||||||
conf_max_HTTP_clients = 10
|
configuration\http\max_clients = 10
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndIf
|
EndIf
|
||||||
Case #conf_max_HTTPS_clients
|
Case #conf_max_HTTPS_clients
|
||||||
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
||||||
conf_max_HTTPS_clients = Val(setting)
|
configuration\https\max_clients = Val(setting)
|
||||||
Else
|
Else
|
||||||
conf_max_HTTPS_clients = 10
|
configuration\https\max_clients = 10
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndIf
|
EndIf
|
||||||
Case #conf_server_type
|
Case #conf_server_type
|
||||||
conf_server_type = Val(setting)
|
configuration\type = Val(setting)
|
||||||
Case #conf_cache_enable
|
Case #conf_cache_enable
|
||||||
conf_cache_enable = Val(Setting)
|
configuration\cache\enable = Val(Setting)
|
||||||
Default
|
Default
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndSelect
|
EndSelect
|
||||||
|
@ -249,34 +297,34 @@ Module lhs_web
|
||||||
Procedure.s get_config(parameter.i=#conf_defaultfile)
|
Procedure.s get_config(parameter.i=#conf_defaultfile)
|
||||||
Select parameter
|
Select parameter
|
||||||
Case #conf_defaultfile
|
Case #conf_defaultfile
|
||||||
ProcedureReturn conf_defaultfile
|
ProcedureReturn configuration\defaultfile
|
||||||
Case #conf_basedir
|
Case #conf_basedir
|
||||||
ProcedureReturn conf_basedir
|
ProcedureReturn configuration\basedir
|
||||||
Case #conf_error400
|
Case #conf_error400
|
||||||
ProcedureReturn conf_error400
|
ProcedureReturn configuration\error400
|
||||||
Case #conf_max_HTTP_clients
|
Case #conf_max_HTTP_clients
|
||||||
ProcedureReturn Str(conf_max_HTTP_clients)
|
ProcedureReturn Str(configuration\http\max_clients)
|
||||||
Case #conf_server_type
|
Case #conf_server_type
|
||||||
ProcedureReturn Str(conf_server_type)
|
ProcedureReturn Str(configuration\type)
|
||||||
Case #conf_HTTP_port
|
Case #conf_HTTP_port
|
||||||
ProcedureReturn Str(conf_HTTP_port)
|
ProcedureReturn Str(configuration\http\port)
|
||||||
Case #conf_HTTPS_Port
|
Case #conf_HTTPS_Port
|
||||||
ProcedureReturn Str(conf_HTTPS_Port)
|
ProcedureReturn Str(configuration\https\port)
|
||||||
Default
|
Default
|
||||||
ProcedureReturn ""
|
ProcedureReturn ""
|
||||||
EndSelect
|
EndSelect
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure start_server()
|
Procedure start_server()
|
||||||
Global NewMap m_clients.s_clients(conf_max_HTTP_clients+conf_max_HTTPS_clients)
|
Global NewMap m_clients.s_clients(configuration\http\max_clients+configuration\https\max_clients)
|
||||||
Protected tlsresponse.i
|
Protected tlsresponse.i
|
||||||
|
|
||||||
;Init HTTP Socket
|
;Init HTTP Socket
|
||||||
server_HTTP_id = lsocket::CreateSocket(conf_HTTP_port, conf_max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, conf_HTTP_binding)
|
server_HTTP_id = lsocket::CreateSocket(configuration\http\port, configuration\http\max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, configuration\http\binding)
|
||||||
If conf_HTTPS_enable = 1
|
If configuration\https\enabled = 1
|
||||||
server_HTTPS_id = lsocket::CreateSocket(conf_HTTPS_Port, conf_max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, conf_HTTPS_binding)
|
server_HTTPS_id = lsocket::CreateSocket(configuration\https\port, configuration\https\max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, configuration\https\binding)
|
||||||
If server_HTTPS_id
|
If server_HTTPS_id
|
||||||
tlsresponse = ltls::InitSimpleTLS(conf_HTTPS_CA, conf_HTTPS_Cert, conf_HTTPS_Key, conf_HTTPS_Key_Pass)
|
tlsresponse = ltls::InitSimpleTLS(configuration\https\CA, configuration\https\Certs, configuration\https\key, configuration\https\key_pass)
|
||||||
If tlsresponse > 0
|
If tlsresponse > 0
|
||||||
CreateThread(@server_HTTPS(), server_HTTPS_id)
|
CreateThread(@server_HTTPS(), server_HTTPS_id)
|
||||||
Else
|
Else
|
||||||
|
@ -314,7 +362,7 @@ Module lhs_web
|
||||||
If m_clients(Str(client_id))\client_id = client_id
|
If m_clients(Str(client_id))\client_id = client_id
|
||||||
lhs_log::Out("Client Thread for socket already exist :"+Str(client_id))
|
lhs_log::Out("Client Thread for socket already exist :"+Str(client_id))
|
||||||
Else
|
Else
|
||||||
If count_HTTPS_client < conf_max_HTTPS_clients
|
If count_HTTPS_client < configuration\https\max_clients
|
||||||
m_clients(Str(client_id))\client_id = client_id
|
m_clients(Str(client_id))\client_id = client_id
|
||||||
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
||||||
m_clients(Str(client_id))\client_do_srv = #SRV_DO_DataReceive
|
m_clients(Str(client_id))\client_do_srv = #SRV_DO_DataReceive
|
||||||
|
@ -351,7 +399,7 @@ Module lhs_web
|
||||||
If m_clients(Str(client_id))\client_id = client_id
|
If m_clients(Str(client_id))\client_id = client_id
|
||||||
lhs_log::Out("Client Thread for socket already exist :"+Str(client_id))
|
lhs_log::Out("Client Thread for socket already exist :"+Str(client_id))
|
||||||
Else
|
Else
|
||||||
If count_HTTP_client < conf_max_HTTP_clients
|
If count_HTTP_client < configuration\http\max_clients
|
||||||
m_clients(Str(client_id))\client_id = client_id
|
m_clients(Str(client_id))\client_id = client_id
|
||||||
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
||||||
m_clients(Str(client_id))\client_do_srv = #SRV_DO_DataReceive
|
m_clients(Str(client_id))\client_do_srv = #SRV_DO_DataReceive
|
||||||
|
@ -465,7 +513,7 @@ Module lhs_web
|
||||||
;Change Thread to Work mode.
|
;Change Thread to Work mode.
|
||||||
|
|
||||||
;{
|
;{
|
||||||
lhs_log::Out("Date received, working...")
|
lhs_log::Out("Data received, working...")
|
||||||
m_clients(Str(thread_cli_id))\client_do_cli = #CLI_DO_DataWorking
|
m_clients(Str(thread_cli_id))\client_do_cli = #CLI_DO_DataWorking
|
||||||
;Work on Answer.
|
;Work on Answer.
|
||||||
ResetList(m_clients(Str(thread_cli_id))\datenbuffer())
|
ResetList(m_clients(Str(thread_cli_id))\datenbuffer())
|
||||||
|
@ -505,7 +553,7 @@ Module lhs_web
|
||||||
;{
|
;{
|
||||||
lhs_log::Out(#http_method_get)
|
lhs_log::Out(#http_method_get)
|
||||||
If Header(#http_head_request) = "/"
|
If Header(#http_head_request) = "/"
|
||||||
thread_requested = conf_defaultfile
|
thread_requested = configuration\defaultfile
|
||||||
Else
|
Else
|
||||||
thread_requested = Header(#http_head_request)
|
thread_requested = Header(#http_head_request)
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -562,18 +610,18 @@ Module lhs_web
|
||||||
lhs_log::Out("Content Finished")
|
lhs_log::Out("Content Finished")
|
||||||
;}
|
;}
|
||||||
|
|
||||||
ElseIf conf_cache_enable = 1
|
ElseIf configuration\cache\enable = 1
|
||||||
;{ Cached File Handling BUGGY!!!!!!!
|
;{ Cached File Handling BUGGY!!!!!!!
|
||||||
thread_temp_cache_memory = AllocateMemory(1024)
|
thread_temp_cache_memory = AllocateMemory(1024)
|
||||||
thread_temp_cache = GetFileFromCache(thread_requested, thread_temp_cache_memory)
|
thread_temp_cache = GetFileFromCache(thread_requested, thread_temp_cache_memory)
|
||||||
If thread_temp_cache = #error_string
|
If thread_temp_cache = #error_string
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + thread_requested,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + thread_requested,#PB_File_SharedRead)
|
||||||
|
|
||||||
If thread_file_handle
|
If thread_file_handle
|
||||||
;Alles Ok
|
;Alles Ok
|
||||||
Else
|
Else
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + conf_defaultfile,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + configuration\defaultfile,#PB_File_SharedRead)
|
||||||
lhs_log::Out("FileDir:" + conf_basedir + conf_defaultfile)
|
lhs_log::Out("FileDir:" + configuration\basedir + configuration\defaultfile)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -593,10 +641,10 @@ Module lhs_web
|
||||||
|
|
||||||
Else
|
Else
|
||||||
;{ Uncached file sems to be stable tested up to 200 clients and 100 requests.
|
;{ Uncached file sems to be stable tested up to 200 clients and 100 requests.
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + thread_requested,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + thread_requested,#PB_File_SharedRead)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + conf_defaultfile,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + configuration\defaultfile,#PB_File_SharedRead)
|
||||||
lhs_log::Out("FileDir:" + conf_basedir + conf_defaultfile)
|
lhs_log::Out("FileDir:" + configuration\basedir + configuration\defaultfile)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -650,7 +698,7 @@ Module lhs_web
|
||||||
;}
|
;}
|
||||||
|
|
||||||
If Header(#http_head_request) = "/"
|
If Header(#http_head_request) = "/"
|
||||||
thread_requested = conf_defaultfile
|
thread_requested = configuration\defaultfile
|
||||||
Else
|
Else
|
||||||
thread_requested = Header(#http_head_request)
|
thread_requested = Header(#http_head_request)
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -710,13 +758,13 @@ Module lhs_web
|
||||||
thread_temp_cache_memory = AllocateMemory(1024)
|
thread_temp_cache_memory = AllocateMemory(1024)
|
||||||
thread_temp_cache = GetFileFromCache(thread_requested, thread_temp_cache_memory)
|
thread_temp_cache = GetFileFromCache(thread_requested, thread_temp_cache_memory)
|
||||||
If thread_temp_cache = #error_string
|
If thread_temp_cache = #error_string
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + thread_requested,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + thread_requested,#PB_File_SharedRead)
|
||||||
|
|
||||||
If thread_file_handle
|
If thread_file_handle
|
||||||
;Alles Ok
|
;Alles Ok
|
||||||
Else
|
Else
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + conf_defaultfile,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + configuration\defaultfile,#PB_File_SharedRead)
|
||||||
lhs_log::Out("FileDir:" + conf_basedir + conf_defaultfile)
|
lhs_log::Out("FileDir:" + configuration\basedir + configuration\defaultfile)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -736,10 +784,10 @@ Module lhs_web
|
||||||
|
|
||||||
Else
|
Else
|
||||||
;{ Uncached file sems to be stable tested up to 200 clients and 100 requests.
|
;{ Uncached file sems to be stable tested up to 200 clients and 100 requests.
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + thread_requested,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + thread_requested,#PB_File_SharedRead)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + conf_defaultfile,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + configuration\defaultfile,#PB_File_SharedRead)
|
||||||
lhs_log::Out("FileDir:" + conf_basedir + conf_defaultfile)
|
lhs_log::Out("FileDir:" + configuration\basedir + configuration\defaultfile)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -753,16 +801,16 @@ Module lhs_web
|
||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
If Header(#http_head_request) = "/"
|
If Header(#http_head_request) = "/"
|
||||||
thread_requested = conf_defaultfile
|
thread_requested = configuration\defaultfile
|
||||||
Else
|
Else
|
||||||
thread_requested = Header(#http_head_request)
|
thread_requested = Header(#http_head_request)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + thread_requested,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + thread_requested,#PB_File_SharedRead)
|
||||||
|
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, conf_basedir + conf_defaultfile,#PB_File_SharedRead)
|
thread_file_handle = ReadFile(#PB_Any, configuration\basedir + configuration\defaultfile,#PB_File_SharedRead)
|
||||||
lhs_log::Out("FileDir:" + conf_basedir + thread_requested)
|
lhs_log::Out("FileDir:" + configuration\basedir + thread_requested)
|
||||||
If Not thread_file_handle
|
If Not thread_file_handle
|
||||||
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
thread_file_handle = ReadFile(#PB_Any, "error.html")
|
||||||
EndIf
|
EndIf
|
||||||
|
|
22
lweb.pbp
22
lweb.pbp
|
@ -8,7 +8,7 @@
|
||||||
<section name="data">
|
<section name="data">
|
||||||
<explorer view="../../../bin/purebasic/examples/" pattern="0"/>
|
<explorer view="../../../bin/purebasic/examples/" pattern="0"/>
|
||||||
<log show="1"/>
|
<log show="1"/>
|
||||||
<lastopen date="2021-05-18 11:07" user="renlin" host="localhost.localdomain"/>
|
<lastopen date="2021-05-22 11:19" user="renlin" host="localhost.localdomain"/>
|
||||||
</section>
|
</section>
|
||||||
<section name="files">
|
<section name="files">
|
||||||
<file name="inc/lweb_file_cache.pbi">
|
<file name="inc/lweb_file_cache.pbi">
|
||||||
|
@ -37,15 +37,23 @@
|
||||||
</file>
|
</file>
|
||||||
<file name="inc/lweb_IP.pbi">
|
<file name="inc/lweb_IP.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
|
||||||
<fingerprint md5="6129682ac18bbfa953feb6f6f6efe65d"/>
|
<fingerprint md5="8c770722dc3dde3f15c774e31ae2038f"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="inc/lweb_IP_header.pbi">
|
<file name="inc/lweb_IP_header.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+-"/>
|
||||||
<fingerprint md5="636558037ff2cab03552fb129e2a4f52"/>
|
<fingerprint md5="636558037ff2cab03552fb129e2a4f52"/>
|
||||||
</file>
|
</file>
|
||||||
|
<file name="lhs_lib/SYS/lhs_log.pbi">
|
||||||
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+--"/>
|
||||||
|
<fingerprint md5="6b31d19e01b0030f0864597f48e078de"/>
|
||||||
|
</file>
|
||||||
|
<file name="lhs_lib/SYS/lhs_log_ext.pbi">
|
||||||
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+--"/>
|
||||||
|
<fingerprint md5="f015019624b5fc7e88221c5d0c122b31"/>
|
||||||
|
</file>
|
||||||
<file name="lhttpd.pb">
|
<file name="lhttpd.pb">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
<fingerprint md5="c00ea68ded3163bfc61ae5b742ab5b93"/>
|
<fingerprint md5="ebf734d9cd3289f62402f2e53926a082"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="lsocket.pbi">
|
<file name="lsocket.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
|
@ -53,19 +61,19 @@
|
||||||
</file>
|
</file>
|
||||||
<file name="ltls.pbi">
|
<file name="ltls.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
<fingerprint md5="b956381cac547736cc02dc190f3667ef"/>
|
<fingerprint md5="03aa93c8873d761cfdc9763b38196677"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="lweb.pbi">
|
<file name="lweb.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
<fingerprint md5="de8dab8fa9d7a38afdba1b88cc9d7f23"/>
|
<fingerprint md5="985d9d6bae18494533ca4ef51ae62645"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="lweb_header.pbi">
|
<file name="lweb_header.pbi">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
<fingerprint md5="da9f9d3acca1364e9c78a2410c267ae0"/>
|
<fingerprint md5="8d10080da88196da4c3b9966c56d497a"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="server_example.pb">
|
<file name="server_example.pb">
|
||||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
<config load="0" scan="1" panel="1" warn="1" lastopen="1" panelstate="+"/>
|
||||||
<fingerprint md5="c69b5870aa1149d4e08f6f6e4fee2a00"/>
|
<fingerprint md5="7c546da941de1600c939a645628a7f8d"/>
|
||||||
</file>
|
</file>
|
||||||
</section>
|
</section>
|
||||||
<section name="targets">
|
<section name="targets">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
;*
|
;*
|
||||||
;* Lihaso Web Server
|
;* Lihaso Web Server
|
||||||
;*
|
;*
|
||||||
;* HTTP/HTTPS Server Beispiel
|
;* HTTP/HTTPS example extended Server
|
||||||
;*
|
;*
|
||||||
;* (c)2015 - 2021 by Linder Hard- und Software
|
;* (c)2015 - 2021 by Linder Hard- und Software
|
||||||
;*
|
;*
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
EnableExplicit
|
EnableExplicit
|
||||||
|
|
||||||
;*
|
;*
|
||||||
;* Deklaration Variabeln
|
;* Includes:
|
||||||
;*
|
;*
|
||||||
|
|
||||||
XIncludeFile "lhs_lib/SYS/lhs_log.pbi" ;Currently for Debugging
|
XIncludeFile "lhs_lib/SYS/lhs_log.pbi" ;Currently for Debugging
|
||||||
|
@ -19,15 +19,29 @@ XIncludeFile "lhs_lib/SYS/lhs_log_ext.pbi" ;User for Access Log, Error Access
|
||||||
XIncludeFile "lweb_header.pbi"
|
XIncludeFile "lweb_header.pbi"
|
||||||
XIncludeFile "lweb.pbi"
|
XIncludeFile "lweb.pbi"
|
||||||
|
|
||||||
|
;*
|
||||||
|
;* Variable declaration:
|
||||||
|
;*
|
||||||
|
|
||||||
Define counter, v_lweb_srv_stop
|
Define counter, v_lweb_srv_stop
|
||||||
|
Define Accesslog.s
|
||||||
|
|
||||||
|
;*
|
||||||
|
;* Basic Debug Log initialization:
|
||||||
|
;*
|
||||||
|
|
||||||
lhs_log::App_Name = "http-s_server_example"
|
lhs_log::App_Name = "http-s_server_example"
|
||||||
lhs_log::SetLogFile("http-s_server_example.log")
|
lhs_log::SetLogFile("http-s_server_example_debug.log")
|
||||||
lhs_log::SetMaxSize(32)
|
lhs_log::SetMaxSize(32)
|
||||||
lhs_log::SetLogDateFormat("%yyyy.%mm.%dd %hh:%ii:%ss")
|
lhs_log::SetLogDateFormat("%yyyy.%mm.%dd %hh:%ii:%ss")
|
||||||
lhs_log::SetLogFileDateFormat("%yyyy_%mm_%dd_%hh_%ii_%ss")
|
lhs_log::SetLogFileDateFormat("%yyyy_%mm_%dd_%hh_%ii_%ss")
|
||||||
lhs_log::Init()
|
lhs_log::Init()
|
||||||
|
|
||||||
|
;*
|
||||||
|
;* Enable extended Logging:
|
||||||
|
;*
|
||||||
|
Accesslog = lhs_log_ext::Create("Accesslog")
|
||||||
|
|
||||||
lhs_web::set_config(lhs_web::#conf_HTTP_port, "8081")
|
lhs_web::set_config(lhs_web::#conf_HTTP_port, "8081")
|
||||||
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
|
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
|
||||||
lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0")
|
lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0")
|
||||||
|
|
Loading…
Reference in a new issue