From ce2a5d4e1ab14ab4ccd9115183ab4be871472dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Linder?= Date: Tue, 18 Jul 2023 08:59:36 +0200 Subject: [PATCH] Activate the new module --- lweb.pbi | 63 +++++++------------------------------------------------- lweb.pbp | 10 ++++++--- 2 files changed, 14 insertions(+), 59 deletions(-) diff --git a/lweb.pbi b/lweb.pbi index 3cc5e76..e44cdad 100644 --- a/lweb.pbi +++ b/lweb.pbi @@ -10,6 +10,9 @@ XIncludeFile "lhs_lib/NET/lhs_net_tls.pbi" XIncludeFile "lhs_lib/NET/lhs_net_socket.pbi" +XIncludeFile "inc/lweb_http_post_decoder.pbi" + + Module lhs_web ;******************************** @@ -211,8 +214,8 @@ Module lhs_web Declare call_request(RequestString.s, Info.i=#get_handler_procedure) Declare.s call_function(ToCallType.i, ToCall.i, Map Header.s(), PostMapString.s ="") Declare advanced_register_handler(RequesterString.s, Permament.i = 0, Library.s = "", Host.s = "") - Declare.s Work_Post_ToJSON_multipart_form_data(ContentLength.i, MemorSize.i, Memory.i) - Declare.s Work_Post_ToJSON_x_www_form_urlencoded(ContentLength.i, MemorSize.i, Memory.i) + ;Declare.s Work_Post_ToJSON_multipart_form_data(ContentLength.i, MemorSize.i, Memory.i) + ;Declare.s Work_Post_ToJSON_x_www_form_urlencoded(ContentLength.i, MemorSize.i, Memory.i) Declare count_client(Type.i, Countchange.i) XIncludeFile "inc/lweb_IP.pbi" @@ -872,7 +875,7 @@ Module lhs_web ;{ POST Content Type Decoder If LCase(Header(#http_head_content_type)) = #http_content_type_application_x_www_form_urlencoded - PostMapString = Work_Post_ToJSON_x_www_form_urlencoded(Val(Header(#http_head_content_length)), m_clients(Str(thread_cli_id))\datenbuffer()\Size, m_clients(Str(thread_cli_id))\datenbuffer()\Buffer) + PostMapString = lhs_web_post::mem_x_www_form_urlencoded(Val(Header(#http_head_content_length)), m_clients(Str(thread_cli_id))\datenbuffer()\Size, m_clients(Str(thread_cli_id))\datenbuffer()\Buffer) MyThreadJSON = ParseJSON(#PB_Any, PostMapString) If MyThreadJSON ClearMap(Post()) @@ -884,7 +887,7 @@ Module lhs_web Break 2 ; Kill Thread EndIf ElseIf Left(LCase(Header(#http_head_content_type)), Len(#http_content_type_multipart_form_data)) = #http_content_type_multipart_form_data - PostMapString = Work_Post_ToJSON_multipart_form_data(Val(Header(#http_head_content_length)), m_clients(Str(thread_cli_id))\datenbuffer()\Size, m_clients(Str(thread_cli_id))\datenbuffer()\Buffer) + PostMapString = lhs_web_post::mem_x_www_form_urlencoded(Val(Header(#http_head_content_length)), m_clients(Str(thread_cli_id))\datenbuffer()\Size, m_clients(Str(thread_cli_id))\datenbuffer()\Buffer) MyThreadJSON = ParseJSON(#PB_Any, PostMapString) If MyThreadJSON ClearMap(Post()) @@ -1352,58 +1355,6 @@ Module lhs_web ProcedureReturn Val(call_request_string(RequestString.s, Info.i)) EndProcedure - Procedure.s Work_Post_ToJSON_x_www_form_urlencoded(ContentLength.i, MemorSize.i, Memory.i) - Define.s JSONString, Working, ContentString - Define CountParams, Count, JSON - Protected NewMap Posts.s() - - If ContentLength > 0 - OffsetMemory = Memory + (MemorSize - ContentLength) - ContentString = PeekS(OffsetMemory, ContentLength, #PB_UTF8) - ;Zerlegen & - ;Mapname = Content - If Len(ContentString) > 0 - CountParams = CountString(ContentString,"&") - If CountParams = 0 - If CountString(ContentString, "=") - Posts(StringField(ContentString, 1, "=")) = StringField(ContentString,2, "=") - Else - ProcedureReturn "" - EndIf - ElseIf CountParams > 0 - Count = 0 - Repeat - Posts(StringField(StringField(ContentString, Count + 1, "&"),1,"=")) = StringField(StringField(ContentString, Count + 1, "&"),2,"=") - ;ldl::Logging("Worked Count:"+Str(Count)+" of: "+Str(CountParams)+":"+StringField(StringField(ContentString, Count + 1, "&"),1,"=")+" = "+StringField(StringField(ContentString, Count + 1, "&"),2,"=") - Count + 1 - Until Count > CountParams - Else - ProcedureReturn "" - EndIf - JSON = CreateJSON(#PB_Any) - If JSON - InsertJSONMap(JSONValue(JSON), Posts()) - JSONString = ComposeJSON(JSON) - FreeMap(Posts()) - FreeJSON(JSON) - ProcedureReturn JSONString.s - Else - ProcedureReturn #error_string - EndIf - Else - ProcedureReturn "" - EndIf - Else - ProcedureReturn "" - EndIf - - EndProcedure - - Procedure.s Work_Post_ToJSON_multipart_form_data(ContentLength.i, MemorySize.i, Memory.i) - - ProcedureReturn "NA" - EndProcedure - Procedure.s register_client_handler(Route.s, Callback.i, AppPrototype.i = #handler_proto_get, RouteType.i = #handler_sub, Host.s = "") If Len(Host) > 0 Host = "SpecServer:["+Host+"]" diff --git a/lweb.pbp b/lweb.pbp index 27565ed..90c672d 100644 --- a/lweb.pbp +++ b/lweb.pbp @@ -1,6 +1,6 @@ - +
Projekt ist inklusive Beispiel Code @@ -8,7 +8,7 @@
- +
@@ -113,7 +113,7 @@ - + @@ -131,6 +131,10 @@ + + + +