Page 1 of 2

POST command and timeout

Posted: Tue May 01, 2012 11:12 am
by tzenobite
hi to all
i'm having a BIG problem that has made my stack almost useless: POST command doesn't work as well
when i do the POST command to a website's REST service in order to get a text file, sometimes the POST command get only a part of the text, and every time it happens the chunk returned is different, longer or shorter :shock:
and more: i get the POST command, then i put "it" in a variable, "answer" the variable and then put the same variable in a field: the text in the answer dialog is shorter than the text in the field :shock: :shock:
i think it's a matter of the POST command's timeout but i can't figure out how to change the timeout value
please, help me, with this issue the stack is useless...

i've attached a small stack with only the POST thing in it
warning: the website hosts erotic short stories written in italian (not of mine)

many thanks!

Re: POST command and timeout

Posted: Tue May 01, 2012 2:30 pm
by bangkok
I can't open your stack.

Have you created it with LiveCode 5.5 ? I'm still with 5.2

Re: POST command and timeout

Posted: Tue May 01, 2012 2:58 pm
by sturgis
Just looked at it.'

There was a problem in the card script (typo of some type)

where
if trunc(i/2) = (i/2) then... The equal sign that should have been there wasn't so I fixed that.

Then instead I changed it to
if i mod 2 = 0 then which is basically the same check you were doing. Change the if before that to use mod also.

So, the fields populate correctly (the correct info was there before the correction)

Then I tried clicking the lines to see the response and everything seems to be working fine, I haven't been able to see a problem in it so far, can you provide more info on the problem? Maybe i'm just not looking at the right thing.

Re: POST command and timeout

Posted: Tue May 01, 2012 3:01 pm
by tzenobite
yes, i'm with 5.5
this is a copy to 2.7 version

Re: POST command and timeout

Posted: Tue May 01, 2012 3:13 pm
by tzenobite
thank you sturgis, i'm modified the script according to your post

the problem is visible this way:

click the first line (l'idraulico) and you will see both in the answer box and in the field at the bottom of the card the same text ending with 22\/04\/2012"}
click at other lines, like the fourth (alieno 5) or the ninth (la svolta), and you'll see that both the answer box and the field have only a chunck of text: the text end at two different point and both texts are truncated before their ends
some links works good, others don't
if you click at the same bad line you have a chunck of text, if you close the stack and open it again, if you click at the same line you'll get a different chunk of text (actually, a chunck in the asnwer box and another in the field), and so on

Re: POST command and timeout

Posted: Tue May 01, 2012 5:12 pm
by bangkok
The problem comes for your header !

With this one :

Code: Select all

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
TImeout: 1000
Connection: keep-alive
Content-Type: application/xml
I receive all the text (with date and the tag at the end </RaccontoDTO>), for each of the "book" ( :) )

(by the way, your stack is a very good example of "webservice")

Re: POST command and timeout

Posted: Tue May 01, 2012 5:37 pm
by tzenobite
thanks twice, for the advice and for the appreciation :-)

i'll try now :)

edit: it works! thanks, this is really a good place :-)
maybe this is the bigger difference with when i started with hypercard: in 1990's there's no internet forums like this :wink:

edit two: the whole stack gets a list or available files on the website using a REST service, then (if the user's subscription is working) gets the selected file and pass it to a simple ereader-like card, with a scrolling field and adjustable font type, font size and colors
i still have to build a good set of backup routines to refill each cards if the user go home (to fake the multitasking)

(i feel like more than 20 years ago :D :D :D)
:)

Re: POST command and timeout

Posted: Tue May 01, 2012 6:16 pm
by tzenobite
it stops working :shock: :shock: :shock:

please, it's possible to more of you to try my stack? i've changed the timeout in the headers, the stack works at first time but now it doesn't works again... i'm wondering if something else is wrong too :( :( :(

Re: POST command and timeout

Posted: Tue May 01, 2012 6:21 pm
by bangkok
With your original timeout (1000), the stack is still working fine.
I continue to receive the text correctly.

When do you say "not working", what do you mean ? Still the end of text missing ? Or something else ?

Actually, the stack is working even with minimal header

Code: Select all

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/xml

Re: POST command and timeout

Posted: Tue May 01, 2012 6:22 pm
by mwieder
Works for me. You changed the header custom property to remove the "Accept" line? The data posted into the message box is still the raw data, but the data in the field looks correct.

...and PLEASE don't put the authorization info in a field in plain text. Put it into the script (not a custom property) of a password-protected substack and get it from there.

Re: POST command and timeout

Posted: Tue May 01, 2012 6:25 pm
by sturgis
Just as a check you might ping the server from your system as well as running a traceroute and see if maybe your connect is having trouble. Dropped packets or an overloaded gateway somewhere between you and the server can cause problems.

Re: POST command and timeout

Posted: Tue May 01, 2012 6:45 pm
by bangkok
mwieder wrote:Put it into the script (not a custom property) of a password-protected substack and get it from there.
[custom properties are not crypted in a password protected stack ? and why use a substack in this case ? why not the main stack ?]

Re: POST command and timeout

Posted: Tue May 01, 2012 7:08 pm
by mwieder
[custom properties are not crypted in a password protected stack ?
That is correct. Password protection is for the script - custom properties are still available from the property inspector.

And I suggested protecting a substack so that we can still work with the main stack scripts until we've got this working. <g>
Otherwise we couldn't help out.

Re: POST command and timeout

Posted: Tue May 01, 2012 8:44 pm
by tzenobite
set the timeout to 10000, it seems to working for now... *hoping*
tomorrow i will try the app straight from the iphone (jailbreaked :roll:)

in the full stack the password is protected, anyway this is going to be an app for the iphone, so once the user give username and password the data is stored in a secure way inside he app itself :wink:

Re: POST command and timeout

Posted: Tue May 01, 2012 8:50 pm
by tzenobite
mwieder wrote:You changed the header custom property to remove the "Accept" line?
what do you mean?

i'm using this:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Timeout: 10000
Accept: */*
Connection: keep-alive
Content-Type: application/xml