Recent

Author Topic: cURL / Synapse  (Read 10987 times)

trentbogner

  • Newbie
  • Posts: 3
cURL / Synapse
« on: April 01, 2012, 06:31:32 pm »
I just started out with Lazarus coming from a C/C++ background. I have only coded console apps and DLLs. I have found coding GUIs in C++ too complex and decided to take the plunge and learn FreePascal and Lazarus. So far I am very impressed, much better than wxWidgets.

Anyway, one app I want to create needs multi-threading and form filling. The standard on the web seems to be cURL (curlpas), but I cannot get it to install correctly, perhaps because it is too old (2005). I have looked at Synapse as well, but I cannot really figure out how it fills forms and if I can do it in several threads.

Does anyone have any experience with cURL and Ararat Synapse, especially when it comes to form filling? Which is the best choice? Any other solutions?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8718
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: cURL / Synapse
« Reply #1 on: April 01, 2012, 07:49:53 pm »
cURL and Synapse are networking libraries, not related to multithreading. Both the documentation and wiki have explanation on them.

I don't quite understand with your term of "form filling". Could you be clearer?

trentbogner

  • Newbie
  • Posts: 3
Re: cURL / Synapse
« Reply #2 on: April 01, 2012, 08:19:56 pm »
What I refer to when I say multi-threading is for example cURL multi functions. To fill forms on the web one could use curl_addform(), but perhaps that's the same as httpsend of Synapse.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8718
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: cURL / Synapse
« Reply #3 on: April 01, 2012, 11:46:53 pm »
Quote
What I refer to when I say multi-threading is for example cURL multi functions.
I have no idea for this one, never used any of the multi interface. I guess you have to manually manage the the multithreading.
Quote
To fill forms on the web one could use curl_addform(), but perhaps that's the same as httpsend of Synapse.
I see, you mean sending HTTP POST? It's here, HttpPostURL seems like what you're looking for.

trentbogner

  • Newbie
  • Posts: 3
Re: cURL / Synapse
« Reply #4 on: April 01, 2012, 11:52:24 pm »
OK, I think I now understand how Synapse work. Quite different from cURL. Probably have to use 'Live Headers' to figure out exactly what is sent. I will try to use cURL.exe as well and compare.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: cURL / Synapse
« Reply #5 on: April 02, 2012, 09:36:37 am »
Posting a form is very easy with synapse. In httpsend you have function HttpPostURL(const URL, URLData: string; const Data: TStream): Boolean;
Take the login form used for this form as an example:
- URL is the url for the form submit (http://forum.lazarus.freepascal.org/index.php?action=login2)
- URLData is an URLEncoded string that lists the input elements and their values: 'user=xyz&passwrd=&cookieneverexp=on&hash_passwrd=49c415cdb02aa4adb9b1116d0b9e4d5cf84a9220'.
- so the command to send this form is
Code: [Select]
HttpPostURL('http://forum.lazarus.freepascal.org/index.php?action=login2', 'user=xyz&passwrd=&cookieneverexp=on&hash_passwrd=49c415cdb02aa4adb9b1116d0b9e4d5cf84a9220',Data);Resulting html is returned in the stream Data.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: cURL / Synapse
« Reply #6 on: April 21, 2012, 08:45:45 am »
I have a example in Synapse of how to send form fields to a CGI,PHP,python script.
And yes you can use Synapse in threads with out any issue.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

 

TinyPortal © 2005-2018