;******************************** ;* ;* lweb_http_status.pbi ;* ;* LiHaSo Webserver Default status. ;* ;* Configuration Module for Configs. ;* ; configuration\status("number")\status = "200" ; configuration\status("number")\file = "" ; configuration\status("number")\header = "200 Ok" ; configuration\status("number")\message = "" ; configuration\status("number")\template = #False ; configuration\status("number")\content = #False ;* ;* Default status components ;* Please add here only rfc7231 codes. ;* Procedure status_defaults() ;Import XML cfg/default_http_status_codes.xml resp config Protected ReadedXML.s, FileHandle.i, XMLHandle.i FileHandle = ReadFile(#PB_Any, configuration\config_file("status_xml")\name) If IsFile(FileHandle) ReadedXML = ReadString(FileHandle, #PB_File_IgnoreEOL) CloseFile(FileHandle) XMLHandle = ParseXML(#PB_Any, ReadedXML) If XMLHandle And XMLStatus(XMLHandle) = #PB_XML_Success ExtractXMLMap(MainXMLNode(XMLHandle), configuration\status()) Else lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Info, "Import of the File:"+configuration\config_file("status_xml")\name+" failed.") EndIf Else lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Info, "Could not open File:"+configuration\config_file("status_xml")\name+" .") EndIf EndProcedure Procedure.s status_get_file(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\file EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\file Else ProcedureReturn "Internal" EndIf EndProcedure Procedure.s status_get_header(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\header EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\header Else ProcedureReturn "500 Internal Server Error" EndIf EndProcedure Procedure.s status_get_message(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\message EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\message Else ProcedureReturn "500 Internal Server Error" EndIf EndProcedure Procedure.s status_get_message_body(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\message_body EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\message_body Else ProcedureReturn "" EndIf EndProcedure Procedure status_get_template(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\template EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\template Else ProcedureReturn #True EndIf EndProcedure Procedure status_get_content(status.s, UUID.s="Default") If UUID <> "Default" If configuration\hosts(UUID)\status(status)\status = status ProcedureReturn configuration\hosts(UUID)\status(status)\content EndIf EndIf If configuration\status(status)\status = status ProcedureReturn configuration\status(status)\content Else ProcedureReturn #True 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