[Long] Moving a REST request from Desktop to Server
Andre Garzia
andre at andregarzia.com
Thu Mar 9 12:11:18 EST 2017
Hi,
I would shell() to curl or a shell script and parse the result.
om om
On Tue, Mar 7, 2017 at 8:56 PM, Malte Brill via use-livecode <
use-livecode at lists.runrev.com> wrote:
> Hi all,
>
> I am trying to move a request I do from a desktop app to a liveCode server
> script and am facing the problem that some of the stuff I use (most of it
> libURL stuff) is not available on the server. Now I wonder how I could
> translate it…
>
> Scenario is the following:
> Problem is libURLLastRHHeaders() is unavailable on server and can not
> easiely be copied from libURL
> Anyone got an idea?
>
> local sCookieHeader
>
> on mouseUp
> local tURL,tUser,tPassWord,tCookie,tSubmitId,tsubmit,tJson,
> tJsonArray
> local test
> try
> set the httpHeaders to empty
> put „aUser" into tUser
> put „aPassword" into tPassWord
> put "264812" into tSubmitID
> put "Log+in" into tSubmit
> get libURLFormData("userName", tUser,"password",
> tPassword,"submit",tSubmit,"submitID",tSubmitId) — not available on
> Server, but can be copied from libURL
> post it to url "http://test.com/login.php"
> _storeCookies libURLLastRHHeaders() — needed to
> authenticate. libURLLastRHHeaders unavailable
> set the httpHeaders to sCookieHeader
> put fld "URL" into tURL
> put URL tURL into tJson
> catch theErr
> put theErr
> end try
> end mouseUp
>
>
> ## Parse header returned from a server and create a cookie header that
> ## can be sent back: Cookie: cookie1;cookie2;cookie3;...
> private command _StoreCookies pHeader
> local theCharNo,theCookieLine,theLineNo,theOffset
> put empty into sCookieHeader
> put 0 into theOffset
> repeat forever
> put lineoffset("Set-Cookie:", pHeader, theOffset) into
> theLineNo
> if theLineNo > 0 then
> add theOffset to theLineNo
> put line theLineNo of pHeader into theCookieLine
> delete word 1 of theCookieLine ## Set-Cookie:
> put offset(";", theCookieLine) into theCharNo
> if theCharNo > 0 then
> delete char theCharNo to -1 of
> theCookieLine
> end if
> put theCookieLine & ";" after sCookieHeader
> put theLineNo into theOffset
> else
> exit repeat
> end if
> end repeat
> if the last char of sCookieHeader is ";" then
> delete the last char of sCookieHeader
> end if
> if sCookieHeader is not empty then
> put "Cookie: " before sCookieHeader
> end if
> return empty
> end _StoreCookies
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.
More information about the use-livecode
mailing list