Activate the new module
This commit is contained in:
parent
ce41a4cd23
commit
ce2a5d4e1a
2 changed files with 14 additions and 59 deletions
63
lweb.pbi
63
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+"]"
|
||||
|
|
10
lweb.pbp
10
lweb.pbp
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 6.02 LTS (Linux - x64)">
|
||||
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 6.03 beta 3 LTS (Linux - x64)">
|
||||
<section name="config">
|
||||
<options closefiles="1" openmode="0" name="LiHaSo Webserver Modul"/>
|
||||
<comment>Projekt ist inklusive Beispiel Code</comment>
|
||||
|
@ -8,7 +8,7 @@
|
|||
<section name="data">
|
||||
<explorer view="../../../bin/purebasic/examples/" pattern="0"/>
|
||||
<log show="1"/>
|
||||
<lastopen date="2023-07-07 15:22" user="renlin" host="renlin-office"/>
|
||||
<lastopen date="2023-07-18 08:57" user="renlin" host="localhost.localdomain"/>
|
||||
</section>
|
||||
<section name="files">
|
||||
<file name="installation.pb">
|
||||
|
@ -113,7 +113,7 @@
|
|||
</file>
|
||||
<file name="lweb.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="26" panelstate="+"/>
|
||||
<fingerprint md5="1a0fcb4cf90a344c342ba86840365bf6"/>
|
||||
<fingerprint md5="e3243900ab7a7478fce202e60875e752"/>
|
||||
</file>
|
||||
<file name="inc/lweb_helper_header.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="27" panelstate="+-"/>
|
||||
|
@ -131,6 +131,10 @@
|
|||
<config load="0" scan="1" panel="1" warn="1" lastopen="0" sortindex="999" panelstate="+-"/>
|
||||
<fingerprint md5="3228c16f329808e2e6e3c6866861ae59"/>
|
||||
</file>
|
||||
<file name="inc/lweb_http_post_decoder.pbi">
|
||||
<config load="0" scan="1" panel="1" warn="1" lastopen="1" sortindex="29" panelstate="+-"/>
|
||||
<fingerprint md5="f05103675e4b6921ea9f745a1344d6cd"/>
|
||||
</file>
|
||||
</section>
|
||||
<section name="targets">
|
||||
<target name="Standard-Ziel" enabled="1" default="0">
|
||||
|
|
Loading…
Reference in a new issue