From 6479c4645d6f3eea8edd6be255334c9f514f783b Mon Sep 17 00:00:00 2001 From: Ground0 Date: Mon, 23 Sep 2024 05:59:11 +0200 Subject: [PATCH] Errorpage handling change and header work --- inc/lweb_header_privat.pbi | 9 +++++ inc/lweb_http_status.pbi | 13 ++++++++ inc/lweb_http_status_header.pbi | 1 + lweb.pbi | 17 +++++++++- lweb.pbp | 58 ++++++++++++++++----------------- 5 files changed, 68 insertions(+), 30 deletions(-) diff --git a/inc/lweb_header_privat.pbi b/inc/lweb_header_privat.pbi index 4b531d8..c1194ec 100644 --- a/inc/lweb_header_privat.pbi +++ b/inc/lweb_header_privat.pbi @@ -99,6 +99,14 @@ lib_id.i EndStructure + Structure headerfunctions + header_name.s + call.i + type.i + library.s + perm.i + EndStructure + Structure host description.s http.server_http @@ -108,6 +116,7 @@ mem.memory Map dynamichandler.dynamichandler() Map usedlibs.usedlibs() + Map headerfunctions.headerfunctions() defaultfile.s basedir.s Map status.http_status_codes() ;Individual Error Messages and Headers diff --git a/inc/lweb_http_status.pbi b/inc/lweb_http_status.pbi index 7d700f0..cf4e47b 100644 --- a/inc/lweb_http_status.pbi +++ b/inc/lweb_http_status.pbi @@ -121,3 +121,16 @@ Procedure status_get_content(status.s, UUID.s="Default") EndIf EndProcedure +Procedure.s status_render_html(status.s, UUID.s="Default") + If UUID <> "Default" + If configuration\hosts(UUID)\status(status)\status = status + ProcedureReturn body.s + EndIf + Else + If configuration\status(status)\status = status + ProcedureReturn body.s + EndIf + EndIf +EndProcedure + + diff --git a/inc/lweb_http_status_header.pbi b/inc/lweb_http_status_header.pbi index cc4351e..548f5ae 100644 --- a/inc/lweb_http_status_header.pbi +++ b/inc/lweb_http_status_header.pbi @@ -15,4 +15,5 @@ Declare.s status_get_message(status.s, UUID.s="Default") Declare.s status_get_message_body(status.s, UUID.s="Default") Declare status_get_template(status.s, UUID.s="Default") Declare status_get_content(status.s, UUID.s="Default") +Declare.s status_render_html(status.s, UUID.s="Default") diff --git a/lweb.pbi b/lweb.pbi index 6b23b1f..ecf0682 100644 --- a/lweb.pbi +++ b/lweb.pbi @@ -155,8 +155,14 @@ Module lhs_web configuration_map_id.s EndStructure + Structure s_header_functions + header_name.s + call.i + type.i + library.s + perm.i + EndStructure - Enumeration cli_handler_infos 1 #get_handler_procedure ;Funktion die Aufgerufen werden muss #get_handler_prototype ;Welcher Prototype @@ -694,6 +700,9 @@ Module lhs_web ldl::Logging("Empty accesslog:["+AccessLog+"]") EndIf + ;TODO: Header Handler + ; ex. Cookie: #http_head_cookie + Select Header(#http_head_method) Case #http_method_get ;******************************** @@ -1070,6 +1079,12 @@ Module lhs_web 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 ... + If Header(#http_head_redirect) = "configuration\errorfile404" + ldl::Logging("Error 404 : ["+configuration\status("404")\content+"]") + Header(#http_head_redirect) = "" + EndIf + Header(#http_head_status) = status_get_header("303") Else Header(#http_head_content_length) = Str(thread_data_size) diff --git a/lweb.pbp b/lweb.pbp index 6fb0840..d0feeec 100644 --- a/lweb.pbp +++ b/lweb.pbp @@ -1,6 +1,6 @@ - +
Projekt ist inklusive Beispiel Code @@ -8,7 +8,7 @@
- +
@@ -29,66 +29,66 @@ - + - + - + - + - - + + - - + + - + - + - + - - + + - + - + - - + + - + - + @@ -105,7 +105,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -133,21 +133,21 @@
- + - + - + - + - +