[Q] Problem with post form to URL and keep connected

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
infantilo
Posts: 12
Joined: Sat Aug 10, 2013 5:16 pm

[Q] Problem with post form to URL and keep connected

Post by infantilo » Sat Aug 10, 2013 5:26 pm

Hi,
i need to login to a wegpage by posting an form, after that i should be able to get other webpage from the server, but sadly it seams as if each time using

Code: Select all

post postVars to URL "xxxxxx"
opens a new connection.
How can i ceep the connection for further calls???

thanks for advice

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [Q] Problem with post form to URL and keep connected

Post by FourthWorld » Sat Aug 10, 2013 5:34 pm

HTTP is generally considered a stateless protocol, so the socket is closed once the transfer has been successfully completed. What is your goal with keeping the socket open? Perhaps there's another way to meet that need.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

infantilo
Posts: 12
Joined: Sat Aug 10, 2013 5:16 pm

Re: [Q] Problem with post form to URL and keep connected

Post by infantilo » Sat Aug 10, 2013 5:44 pm

thanks for quick reply,

in b4a i had to do it this way:

Code: Select all

Dim myHttpRequest As HttpRequest 
url = "https://yourURLhere.html"
Dim str() As Byte
Dim form As String
form = "usernme=max&Country=Vienna&Telephone=123456"
myhttprequest.InitializePost2(url,str)
myHttpRequest.Timeout = 5000
If sock.Execute(myHttpRequest,1) = False Then
          'Something went wrong
         Return      
End If
then , for every request, i had to use the same socket.
can i do the same with lc.

the server connection is https.

i've tried to use a socket, but have no idea how to connetc to https using open socket. Always getting not a valid port

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [Q] Problem with post form to URL and keep connected

Post by FourthWorld » Sat Aug 10, 2013 6:13 pm

My (admittedly limited) understanding from the RFC is that HTTP 1.1 can support persistent connections with the addition of a connection-token element in the header. I'm certainly no BASIC4Android expert, but I'm not seeing where the header is modified at all - does B4A do that by default?

It may be possible to use the libUrlSetCustomHttpHeaders command to do what you need, but I've not needed persistent connections myself so beyond that we'd have to rely on the experience of someone else here who may have done this.

I'm still curious, though: what is the goal with this? Do you have concerns about server load? What's on the back side handling the request?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

infantilo
Posts: 12
Joined: Sat Aug 10, 2013 5:16 pm

Re: [Q] Problem with post form to URL and keep connected

Post by infantilo » Sun Aug 11, 2013 10:05 am

i'm getting my workorder from an webserver. to that, i first need to load the main page, grab an token, send an form (method post) to an other page and grab the maintoken from the repled html page. then i can call the page i really want, by including the maintoken. I've done this in realbasic and b4a.
i'm goona check the libUrlSetCustomHttpHeaders command and will give report. MANY thanks.

infantilo
Posts: 12
Joined: Sat Aug 10, 2013 5:16 pm

Re: [Q] Problem with post form to URL and keep connected

Post by infantilo » Tue Aug 13, 2013 6:39 am

MANY thanks.... works like charm!!!!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: [Q] Problem with post form to URL and keep connected

Post by FourthWorld » Tue Aug 13, 2013 7:32 am

Glad that worked out. In case anyone here needs to do that, what specific changes did you make to the headers?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply