2023-03-30 08:28:45 +02:00
|
|
|
;************************
|
|
|
|
;* server_example_function_library.pb
|
|
|
|
;*
|
|
|
|
;* Test library for the lweb server.
|
|
|
|
;*
|
|
|
|
;* Created and develobed by Linder Hard- und Software
|
|
|
|
;*
|
|
|
|
;*
|
2023-03-29 20:02:31 +02:00
|
|
|
|
2023-03-30 08:28:45 +02:00
|
|
|
XIncludeFile "lhs_lib/NET/lhs_web_helper.pbi"
|
2023-03-29 20:02:31 +02:00
|
|
|
|
|
|
|
Global.s ZumSenden
|
|
|
|
|
|
|
|
ProcedureCDLL post_test(handler_Map_JSON.s, ContentData.s)
|
|
|
|
Define *Text
|
|
|
|
Define.s Encoded, TBD, Text, JSONStringToMap
|
|
|
|
Define MyThreadJSON, File
|
|
|
|
NewMap Header.s()
|
2024-09-23 05:57:51 +02:00
|
|
|
File = CreateFile(#PB_Any, "/var/log/lhttpd/post_test.log")
|
2023-03-29 20:02:31 +02:00
|
|
|
WriteStringN(File, "handler_Map_JSON:")
|
|
|
|
WriteStringN(File, handler_Map_JSON)
|
|
|
|
WriteStringN(File, "Content Data:")
|
|
|
|
WriteStringN(File, ContentData)
|
|
|
|
|
|
|
|
JSONStringToMap = handler_Map_JSON
|
|
|
|
If JSONStringToMap <> lhs_web_helper::#error_string
|
|
|
|
MyThreadJSON = ParseJSON(#PB_Any, JSONStringToMap)
|
|
|
|
If MyThreadJSON
|
|
|
|
ClearMap(Header())
|
|
|
|
ExtractJSONMap(JSONValue(MyThreadJSON), Header())
|
|
|
|
FreeJSON(MyThreadJSON)
|
|
|
|
EndIf
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
NewMap Response.s()
|
|
|
|
TBD="<div><div><h1>FormularPost</h1></div><br/>"+#CRLF$
|
|
|
|
ResetMap(Header())
|
|
|
|
While NextMapElement(Header())
|
|
|
|
TBD = TBD+"<div>"+MapKey(Header())+" : "+Header()+" </div><br/>"+#CRLF$
|
|
|
|
Wend
|
|
|
|
ContentData = URLDecoder(ContentData, #PB_UTF8)
|
|
|
|
Text = ~"<html lang=\"de\">" +
|
|
|
|
"<head>" +
|
|
|
|
~"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>" +
|
2024-09-23 05:57:51 +02:00
|
|
|
"<title>Alle Client Headers</title></header><body>"+TBD+"<hr/><br/><h1>Conent in JSON Format</h1><br/>"+ContentData+"</body></html>"
|
2023-03-29 20:02:31 +02:00
|
|
|
*Text = AllocateMemory(StringByteLength(Text, #PB_UTF8))
|
|
|
|
PokeS(*Text, Text, -1, #PB_UTF8)
|
|
|
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
|
|
|
Response(lhs_web_helper::#cha_R_ResponseContentType) = lhs_web_helper::#response_string
|
|
|
|
Response(lhs_web_helper::#cha_R_StringBase64) = Encoded
|
|
|
|
Response(lhs_web_helper::#cha_R_ResponseType) = lhs_web_helper::mimetype("html")
|
|
|
|
Response(lhs_web_helper::#cha_R_http_head_status) = "200 Ok"
|
|
|
|
|
|
|
|
ZumSenden = lhs_web_helper::MapToJSONString(Response())
|
|
|
|
WriteStringN(File, "ZumSenden:")
|
|
|
|
WriteStringN(File, ZumSenden)
|
|
|
|
CloseFile(File)
|
|
|
|
ProcedureReturn @ZumSenden
|
|
|
|
|
|
|
|
EndProcedure
|