Errorpage handling change and header work

This commit is contained in:
René Linder 2024-09-23 05:59:11 +02:00
parent bd70412795
commit 6479c4645d
5 changed files with 68 additions and 30 deletions

View file

@ -99,6 +99,14 @@
lib_id.i lib_id.i
EndStructure EndStructure
Structure headerfunctions
header_name.s
call.i
type.i
library.s
perm.i
EndStructure
Structure host Structure host
description.s description.s
http.server_http http.server_http
@ -108,6 +116,7 @@
mem.memory mem.memory
Map dynamichandler.dynamichandler() Map dynamichandler.dynamichandler()
Map usedlibs.usedlibs() Map usedlibs.usedlibs()
Map headerfunctions.headerfunctions()
defaultfile.s defaultfile.s
basedir.s basedir.s
Map status.http_status_codes() ;Individual Error Messages and Headers Map status.http_status_codes() ;Individual Error Messages and Headers

View file

@ -121,3 +121,16 @@ Procedure status_get_content(status.s, UUID.s="Default")
EndIf EndIf
EndProcedure 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

View file

@ -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.s status_get_message_body(status.s, UUID.s="Default")
Declare status_get_template(status.s, UUID.s="Default") Declare status_get_template(status.s, UUID.s="Default")
Declare status_get_content(status.s, UUID.s="Default") Declare status_get_content(status.s, UUID.s="Default")
Declare.s status_render_html(status.s, UUID.s="Default")

View file

@ -155,8 +155,14 @@ Module lhs_web
configuration_map_id.s configuration_map_id.s
EndStructure EndStructure
Structure s_header_functions
header_name.s
call.i
type.i
library.s
perm.i
EndStructure
Enumeration cli_handler_infos 1 Enumeration cli_handler_infos 1
#get_handler_procedure ;Funktion die Aufgerufen werden muss #get_handler_procedure ;Funktion die Aufgerufen werden muss
#get_handler_prototype ;Welcher Prototype #get_handler_prototype ;Welcher Prototype
@ -694,6 +700,9 @@ Module lhs_web
ldl::Logging("Empty accesslog:["+AccessLog+"]") ldl::Logging("Empty accesslog:["+AccessLog+"]")
EndIf EndIf
;TODO: Header Handler
; ex. Cookie: #http_head_cookie
Select Header(#http_head_method) Select Header(#http_head_method)
Case #http_method_get Case #http_method_get
;******************************** ;********************************
@ -1070,6 +1079,12 @@ Module lhs_web
EndIf EndIf
If thread_redirect = #True If thread_redirect = #True
Header(#http_head_redirect) = file_check(thread_requested, m_clients(Str(thread_cli_id))\host_id) 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") Header(#http_head_status) = status_get_header("303")
Else Else
Header(#http_head_content_length) = Str(thread_data_size) Header(#http_head_content_length) = Str(thread_data_size)

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 6.04 LTS (Linux - x64)"> <project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 6.12 LTS (Linux - x64)">
<section name="config"> <section name="config">
<options closefiles="1" openmode="0" name="LiHaSo Webserver Modul"/> <options closefiles="1" openmode="0" name="LiHaSo Webserver Modul"/>
<comment>Projekt ist inklusive Beispiel Code</comment> <comment>Projekt ist inklusive Beispiel Code</comment>
@ -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="2024-03-13 07:44" user="renlin" host="renlin-office"/> <lastopen date="2024-09-23 05:54" user="renlin" host="renlin-home"/>
</section> </section>
<section name="files"> <section name="files">
<file name="build_tools/src/default_host_xml_export.pb"> <file name="build_tools/src/default_host_xml_export.pb">
@ -29,66 +29,66 @@
</file> </file>
<file name="inc/lweb_header_privat.pbi"> <file name="inc/lweb_header_privat.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="5" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="5" panelstate="+-"/>
<fingerprint md5="c4a9ada9f85b43584cc6e154d6465fdf"/> <fingerprint md5="7881b6857cdf512fa97b58e5a1f030c7"/>
</file> </file>
<file name="inc/lweb_helper.pbi"> <file name="inc/lweb_helper.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="6" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="6" panelstate="+-"/>
<fingerprint md5="e6b5d486bd08b6de7f34a94316df2543"/> <fingerprint md5="e6b5d486bd08b6de7f34a94316df2543"/>
</file> </file>
<file name="inc/lweb_helper_header.pbi"> <file name="inc/lweb_helper_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="7" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="8" panelstate="+-"/>
<fingerprint md5="6ea3e5baa62f8e66063e3b45e17d7e91"/> <fingerprint md5="6ea3e5baa62f8e66063e3b45e17d7e91"/>
</file> </file>
<file name="inc/lweb_http.pbi"> <file name="inc/lweb_http.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="8" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="9" panelstate="+-"/>
<fingerprint md5="a42cddb6a1102779589facc17ba96cd8"/> <fingerprint md5="a42cddb6a1102779589facc17ba96cd8"/>
</file> </file>
<file name="inc/lweb_http_header.pbi"> <file name="inc/lweb_http_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="9" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="10" panelstate="+-"/>
<fingerprint md5="d7df8e152291b0f91e8316ad8e00191c"/> <fingerprint md5="d7df8e152291b0f91e8316ad8e00191c"/>
</file> </file>
<file name="inc/lweb_http_status.pbi"> <file name="inc/lweb_http_status.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="10" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="11" panelstate="+-"/>
<fingerprint md5="84fe14cca9af928faee3869b6c3d079f"/> <fingerprint md5="6f3a4e08bf4318407b547cb5ca794260"/>
</file> </file>
<file name="inc/lweb_http_status_header.pbi"> <file name="inc/lweb_http_status_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="11" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="12" panelstate="+-"/>
<fingerprint md5="ad8d9313172646d803164eaa5431d2f4"/> <fingerprint md5="6fd5131bd1dc2558e3abf2160fbef98c"/>
</file> </file>
<file name="inc/lweb_http_status_header_private.pbi"> <file name="inc/lweb_http_status_header_private.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="12" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="13" panelstate="+-"/>
<fingerprint md5="c7736a7cdc87c1ed676b17d9757ba135"/> <fingerprint md5="c7736a7cdc87c1ed676b17d9757ba135"/>
</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" sortindex="13" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="14" panelstate="+-"/>
<fingerprint md5="502f26844f0a4b7d7f25924f76b17473"/> <fingerprint md5="502f26844f0a4b7d7f25924f76b17473"/>
</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" sortindex="14" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="15" panelstate="+-"/>
<fingerprint md5="636558037ff2cab03552fb129e2a4f52"/> <fingerprint md5="636558037ff2cab03552fb129e2a4f52"/>
</file> </file>
<file name="inc/lweb_server_cfg.pbi"> <file name="inc/lweb_server_cfg.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="15" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="16" panelstate="+-"/>
<fingerprint md5="16d83dbd505bc2f267b630b9e2d173d1"/> <fingerprint md5="4ef74f56126e4dcbb66e51ac1fe2d605"/>
</file> </file>
<file name="inc/lweb_server_cfg_header.pbi"> <file name="inc/lweb_server_cfg_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="16" panelstate="+-"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="17" panelstate="+-"/>
<fingerprint md5="57787e1e3db6c77d81fc5576e124beae"/> <fingerprint md5="57787e1e3db6c77d81fc5576e124beae"/>
</file> </file>
<file name="installation.pb"> <file name="installation.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="17" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="18" panelstate="+"/>
<fingerprint md5="b5ba175b6bddf19d7c039396199911fd"/> <fingerprint md5="b5ba175b6bddf19d7c039396199911fd"/>
</file> </file>
<file name="lhs_lib/NET/lhs_net_socket.pbi"> <file name="lhs_lib/NET/lhs_net_socket.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="18" panelstate="+--"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="19" panelstate="+--"/>
<fingerprint md5="09f5575be4e23abbb593d2f735a795ae"/> <fingerprint md5="9fc8219dabd4ed47be5289b435d089d6"/>
</file> </file>
<file name="lhs_lib/NET/lhs_net_tls.pbi"> <file name="lhs_lib/NET/lhs_net_tls.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="19" panelstate="+--"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="20" panelstate="+--"/>
<fingerprint md5="c586d25a1493f437c7461374a891a715"/> <fingerprint md5="c586d25a1493f437c7461374a891a715"/>
</file> </file>
<file name="lhs_lib/NET/lhs_web_helper.pbi"> <file name="lhs_lib/NET/lhs_web_helper.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="20" panelstate="+--"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="7" panelstate="+--"/>
<fingerprint md5="52ed1675b88a463b7ada8cf2003430e1"/> <fingerprint md5="52ed1675b88a463b7ada8cf2003430e1"/>
</file> </file>
<file name="lhs_lib/SYS/lhs_log_ext.pbi"> <file name="lhs_lib/SYS/lhs_log_ext.pbi">
@ -105,7 +105,7 @@
</file> </file>
<file name="lweb.pbi"> <file name="lweb.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="24" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="24" panelstate="+"/>
<fingerprint md5="719ce9141b0a0c8a3729465a411a4c90"/> <fingerprint md5="77f20440d446be67de4e5ebd91e513b6"/>
</file> </file>
<file name="lweb_header.pbi"> <file name="lweb_header.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="25" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="25" panelstate="+"/>
@ -113,7 +113,7 @@
</file> </file>
<file name="server_example.pb"> <file name="server_example.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="26" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="26" panelstate="+"/>
<fingerprint md5="bb89312c572cb9d1d3c81349252f0f4f"/> <fingerprint md5="02bd1b26234f33a366ee312164beb638"/>
</file> </file>
<file name="server_example_function.pbi"> <file name="server_example_function.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="27" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="27" panelstate="+"/>
@ -121,7 +121,7 @@
</file> </file>
<file name="server_example_function_library.pb"> <file name="server_example_function_library.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="28" panelstate="+"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="28" panelstate="+"/>
<fingerprint md5="89b911359d8203d81c3aabbbd6f0dcf1"/> <fingerprint md5="bdf6276db9ea8921c3ef06ba10afdbb3"/>
</file> </file>
<file name="build_tools/src/default_config_xml_export.pb"> <file name="build_tools/src/default_config_xml_export.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="0" sortindex="999" panelstate="+--"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0" sortindex="999" panelstate="+--"/>
@ -133,21 +133,21 @@
</file> </file>
</section> </section>
<section name="targets"> <section name="targets">
<target name="Standard-Ziel" enabled="1" default="1"> <target name="Standard-Ziel" enabled="1" default="0">
<inputfile value="server_example.pb"/> <inputfile value="server_example.pb"/>
<outputfile value="server_example"/> <outputfile value="server_example"/>
<compiler version="PureBasic 6.01 LTS - C Backend (Linux - x64)"/> <compiler version="PureBasic 6.12 LTS - C Backend (Linux - x64)"/>
<executable value="server_example"/> <executable value="server_example"/>
<options thread="1" xpskin="1" debug="1" optimizer="0"/> <options thread="1" xpskin="1" debug="1" optimizer="0"/>
<format exe="console" cpu="0"/> <format exe="console" cpu="0"/>
<debugger custom="1" type="ide"/> <debugger custom="1" type="ide"/>
</target> </target>
<target name="lhttpd" enabled="1" default="0"> <target name="lhttpd" enabled="1" default="1">
<inputfile value="lhttpd.pb"/> <inputfile value="lhttpd.pb"/>
<outputfile value="lhttpd"/> <outputfile value="lhttpd"/>
<compiler version="PureBasic 6.01 LTS - C Backend (Linux - x64)"/> <compiler version="PureBasic 6.12 LTS - C Backend (Linux - x64)"/>
<executable value="lhttpd"/> <executable value="lhttpd"/>
<options thread="1" optimizer="0"/> <options thread="1" debug="1" optimizer="0"/>
<format exe="console" cpu="0"/> <format exe="console" cpu="0"/>
<debugger custom="1" type="standalone"/> <debugger custom="1" type="standalone"/>
</target> </target>