108 lines
5.7 KiB
Text
108 lines
5.7 KiB
Text
|
Procedure.s Sample_Header(Map Header.s())
|
||
|
Define *Text
|
||
|
Define.s Encoded, ZumSenden, TBD, Text
|
||
|
NewMap Response.s()
|
||
|
If Header("cookie:") <> ""
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"A Cookie is set :" + Header("cookie:"))
|
||
|
Else
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"No Cookie.")
|
||
|
EndIf
|
||
|
|
||
|
TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$
|
||
|
ResetMap(Header())
|
||
|
While NextMapElement(Header())
|
||
|
TBD = TBD+"<div>"+MapKey(Header())+" "+Header()+" </div><br/>"+#CRLF$
|
||
|
Wend
|
||
|
|
||
|
Text = "<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"</body></html>"
|
||
|
*Text = AllocateMemory(StringByteLength(Text))
|
||
|
PokeS(*Text, Text)
|
||
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Encoded: " + Encoded)
|
||
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||
|
Response(lhs_web::#cha_R_http_head_status) = lhs_web::status_get_header("200")
|
||
|
If Header("cookie:") = ""
|
||
|
Response(lhs_web::#http_head_set_cookie) = "session=this will be after second call here"
|
||
|
EndIf
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Status Header get: " + lhs_web::status_get_header("200"))
|
||
|
|
||
|
ZumSenden = lhs_web::MapToJSONString(Response())
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"ZumSenden: " + ZumSenden)
|
||
|
ProcedureReturn ZumSenden
|
||
|
EndProcedure
|
||
|
|
||
|
Procedure.s Formular_Test(Map Header.s(), ContentData.s)
|
||
|
Define *Text
|
||
|
Define.s Encoded, ZumSenden, TBD, Text
|
||
|
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
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"TBD:"+TBD)
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"contentData:"+ContentData)
|
||
|
ContentData = URLDecoder(ContentData, #PB_UTF8)
|
||
|
Text = ~"<html lang=\"de\">" +
|
||
|
"<head>" +
|
||
|
~"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>" +
|
||
|
"<title>Alle Client Headers</title></header><body>"+TBD+"<hr/><br/><h1>ConentJSON</h1><br/>"+ContentData+"</body></html>"
|
||
|
*Text = AllocateMemory(StringByteLength(Text, #PB_UTF8))
|
||
|
PokeS(*Text, Text, -1, #PB_UTF8)
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Unencoded:"+PeekS(*Text, -1 , #PB_UTF8))
|
||
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Encoded: " + Encoded)
|
||
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||
|
Response(lhs_web::#cha_R_http_head_status) = lhs_web::status_get_header("200")
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Status Header get: " + lhs_web::status_get_header("200"))
|
||
|
|
||
|
ZumSenden = lhs_web::MapToJSONString(Response())
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"ZumSenden: " + ZumSenden)
|
||
|
ProcedureReturn ZumSenden
|
||
|
|
||
|
EndProcedure
|
||
|
|
||
|
Procedure.s Php_Test(Map Header.s(), ContentData.s)
|
||
|
Define *Text, Php
|
||
|
Define.s Execute, Phpresult, Encoded, ZumSenden, Text
|
||
|
NewMap Response.s()
|
||
|
|
||
|
Execute = lhs_web::get_config(lhs_web::#conf_basedir) + Header(lhs_web::#http_head_request)
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"To Execute:" + Execute)
|
||
|
Php = RunProgram("php", Execute, "", #PB_Program_Open | #PB_Program_Read)
|
||
|
Phpresult = ""
|
||
|
If Php
|
||
|
While ProgramRunning(Php)
|
||
|
If AvailableProgramOutput(Php)
|
||
|
Phpresult + ReadProgramString(Php) + #CRLF$
|
||
|
EndIf
|
||
|
Wend
|
||
|
CloseProgram(Php) ; Schließt die Verbindung zum Programm
|
||
|
EndIf
|
||
|
Text = Phpresult
|
||
|
*Text = AllocateMemory(StringByteLength(Text, #PB_UTF8))
|
||
|
PokeS(*Text, Text, -1, #PB_UTF8)
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Unencoded:"+PeekS(*Text, -1 , #PB_UTF8))
|
||
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Encoded: " + Encoded)
|
||
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||
|
Response(lhs_web::#cha_R_http_head_status) = lhs_web::status_get_header("200")
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"Status Header get: " + lhs_web::status_get_header("200"))
|
||
|
ZumSenden = lhs_web::MapToJSONString(Response())
|
||
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"ZumSenden: " + ZumSenden)
|
||
|
ProcedureReturn ZumSenden
|
||
|
EndProcedure
|
||
|
|
||
|
|
||
|
lhs_web::register_client_handler("/server/show_client_headers", @Sample_Header(),lhs_web::#handler_proto_get, lhs_web::#handler_sub)
|
||
|
|
||
|
lhs_web::register_client_handler("/post_test", @Formular_Test(),lhs_web::#handler_proto_post, lhs_web::#handler_sub) ;Im zusammenspiel mit einem Formular
|
||
|
|
||
|
lhs_web::register_client_handler("php", @Php_Test(),lhs_web::#handler_proto_universal, lhs_web::#handler_type)
|