diff --git a/inc/lweb_header_privat.pbi b/inc/lweb_header_privat.pbi index 3025546..24fe4b5 100644 --- a/inc/lweb_header_privat.pbi +++ b/inc/lweb_header_privat.pbi @@ -109,6 +109,9 @@ Structure session Cookie.s + TTL.q + KillTime.q + Daten.s EndStructure Structure host diff --git a/lweb.pbi b/lweb.pbi index 95a1a20..41836c7 100644 --- a/lweb.pbi +++ b/lweb.pbi @@ -701,13 +701,38 @@ Module lhs_web EndIf ;TODO: Header Handler - ; ex. Cookie: #http_head_cookie + ; ex. Cookie: #http_head_cookie and #http_head_cookie_set + ;TODO: Optimizing and change Cookie Session Handling. + ldl::Logging("Check {"+#http_head_cookie+"}:["+Header(#http_head_cookie)+"]") If Header(#http_head_cookie) <> "" ldl::Logging("Session:"+Header(#http_head_cookie)) + If configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie))\KillTime >= Second(Date()) + ;Session Lifetime over? + ldl::Logging("Session TTL Over. Resetting.") + DeleteMapElement(configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(), Header(#http_head_cookie)) + Header(#http_head_cookie_set) = CreateUUID() + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\Cookie = Header(#http_head_cookie_set) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL = 3600 + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\KillTime = Second(Date()) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL + ElseIf configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie))\Cookie = Header(#http_head_cookie) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie))\KillTime = Second(Date()) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie))\TTL + Else + ;Session unknown: + ldl::Logging("Session unknown. Resetting.") + Header(#http_head_cookie_set) = CreateUUID() + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\Cookie = Header(#http_head_cookie_set) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL = 3600 + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\KillTime = Second(Date()) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL + EndIf Else - Header(#http_head_cookie) = CreateUUID() - configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie))\Cookie = Header(#http_head_cookie) + ldl::Logging("No Cookie set .... Set one:") + Header(#http_head_cookie_set) = CreateUUID() + ldl::Logging("Set {"+#http_head_cookie_set+"}:["+Header(#http_head_cookie_set)+"]") + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\Cookie = Header(#http_head_cookie_set) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL = 3600 + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\KillTime = Second(Date()) + configuration\hosts(m_clients(Str(thread_cli_id))\host_id)\sessions(Header(#http_head_cookie_set))\TTL + EndIf Select Header(#http_head_method) @@ -1074,6 +1099,7 @@ Module lhs_web 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 <> "" @@ -1081,9 +1107,11 @@ Module lhs_web Else Header(#http_head_status) = status_get_header("200") EndIf - If Response(#http_head_set_cookie) <> "" - Header(#http_head_set_cookie) = Response(#http_head_set_cookie) + + If Response(#http_head_cookie) <> "" + Header(#http_head_cookie) = Response(#http_head_cookie) EndIf + If thread_redirect = #True Header(#http_head_redirect) = file_check(thread_requested, m_clients(Str(thread_cli_id))\host_id) ;TODO: Verify it's a file or a configuration ... @@ -1102,7 +1130,8 @@ Module lhs_web Header(#http_head_keep_alive) = "timeout=15, max=1000" thread_header = http_header_generate(Header()) - ldl::Logging("Header:"+thread_header) + ldl::Logging("Header:") + ldl::Logging(thread_header) ;large File Handling If thread_redirect = #True thread_buffer = AllocateMemory(StringByteLength(thread_header)+12) @@ -1115,6 +1144,11 @@ Module lhs_web 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 ldl::Logging("Header Finished") + ldl::Logging("Header Map fields:") + ForEach(Header()) + ldl::Logging("Field:["+MapKey(Header())+"] and content:["+Header()+"]") + Next + ldl::Logging("Header Map fields finished.") EndIf ;Copy temporary File Buffer to normal Buffer. If thread_temp_cache_memory <> 0 And thread_buffer_offset <> 0 And thread_data_size <> 0 And thread_oversized_file = #False And thread_redirect = #False @@ -1461,7 +1495,8 @@ Module lhs_web Debug thread_requested file_type = FileSize(configuration\hosts(hostid)\basedir + thread_requested) If file_type = -1 - thread_requested = "configuration\errorfile404" + thread_requested = "configuration\errorfile404" ;TODO: Change wrong File + ElseIf file_type = -2 ;Is a Directory If Right(thread_requested,1) = "/" diff --git a/lweb.pbp b/lweb.pbp index 2f8ea7e..f99a221 100644 --- a/lweb.pbp +++ b/lweb.pbp @@ -8,7 +8,7 @@
- +
@@ -28,88 +28,88 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/lweb_header.pbi b/lweb_header.pbi index 9483b12..5b5ed6c 100644 --- a/lweb_header.pbi +++ b/lweb_header.pbi @@ -100,7 +100,7 @@ DeclareModule lhs_web #http_head_connection = "connection:" #http_head_keep_alive = "keep-alive:" #http_head_cookie = "cookie:" - #http_head_set_cookie = "set-cookie:" + #http_head_cookie_set = "set-cookie:" #http_head_redirect = "location:" #http_content_type_application_x_www_form_urlencoded = "application/x-www-form-urlencoded"