POST command and timeout

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

POST command and timeout

Post by tzenobite » Tue May 01, 2012 11:12 am

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!
Attachments
post.livecode.zip
(8.86 KiB) Downloaded 436 times
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: POST command and timeout

Post by bangkok » Tue May 01, 2012 2:30 pm

I can't open your stack.

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

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: POST command and timeout

Post by sturgis » Tue May 01, 2012 2:58 pm

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.

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 3:01 pm

yes, i'm with 5.5
this is a copy to 2.7 version
Attachments
boh27.livecode.zip
(8.84 KiB) Downloaded 420 times
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 3:13 pm

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
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: POST command and timeout

Post by bangkok » Tue May 01, 2012 5:12 pm

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")

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 5:37 pm

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)
:)
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 6:16 pm

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 :( :( :(
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: POST command and timeout

Post by bangkok » Tue May 01, 2012 6:21 pm

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
Last edited by bangkok on Tue May 01, 2012 6:24 pm, edited 1 time in total.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: POST command and timeout

Post by mwieder » Tue May 01, 2012 6:22 pm

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.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: POST command and timeout

Post by sturgis » Tue May 01, 2012 6:25 pm

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.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: POST command and timeout

Post by bangkok » Tue May 01, 2012 6:45 pm

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 ?]

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: POST command and timeout

Post by mwieder » Tue May 01, 2012 7:08 pm

[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.

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 8:44 pm

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:
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: POST command and timeout

Post by tzenobite » Tue May 01, 2012 8:50 pm

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
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

Post Reply