


| What:| tclfastme: tcl extension based on the FastME phylogeneric tree building program.|

| Where:|  http://www.lbgi.fr/~moumou/|

| Description:| Tcl binding for the FastME program [http://www.ncbi.nlm.nih.gov/CBBresearch/Desper/FastME.html][http://www.ncbi.nlm.nih.gov/pubmed/?term=Fast+and+Accurate+Phylogeny+Reconstruction+Algorithms+Based+on+the+Minimum-Evolution+Principle]. This is a rough tcl-ification of the FastME program, all options are not implemented yet.|

| Updated:| 11/2014|
| Contact:| luc.moulinier at unistra.fr|

----
''Description :''

You cannot GET a [https] page if you are sitting behind a [proxy] using the bare ''http'' package. 
I haven't tried TclCurl yet. '''[US]'''

----
   * [websearch], an initial WWW::Search like package (using the [http] package, though, not TclCurl)

----
Most of the time you are right, the http package is complete enough to satisfy most users, 
TclCurl does provide more features, but unless you need them, you'd better use 
the http package and forget about the lack of portability a [C] extension brings.

But as I said, TclCurl does have more features; for example,
you can [tunnel] non-http request through a http proxy.
I haven't tried it myself, but it should be something like:

 curl::transfer -url https://www.securedomain.com -file index.html \
        -httpproxytunnel 1 -proxy 192.168.0.1:80

I don't have a proxy to test this- could someone please check 
whether it works?

TclCurl supports http 1.1, including keep-alive and resumed transfers,
though there is work by Pat Thoyts to add 1.1 support to a new version of the http package, 
which you can get at http://tclsoap.sourceforge.net/http.html

As for the rest of the TclCurl features, some would be trivial to
implement in Tcl, like being able to follow redirections, some a little
bit harder, like cookie support, but the principle is always the same:
check the features you need and, if the http package offers them, use
it, but if it doesn't, check TclCurl.

Apart from http(s), TclCurl also offers support for other protocols,
like ldap, gopher, ftp, ...  but I have never used the pure Tcl
clients, so I have no idea how they compare.

Even though they have not been written with TclCurl in mind, you may
want to read http://curl.haxx.se/docs/httpscripting.shtml and 
http://curl.haxx.se/libcurl/c/the-guide.html

They will give you an idea of what can be done using TclCurl.

Andres 

----
I believe the TclCurl package would be more popular if there were more examples. 
Below is an example on how to manually package up a Soap XML envelope over http,
set http headers, and parse the Soap response using regexp. 
Overall, TclCurl's performance seems very fast.

Scott Nichols
scott dot nichols4 at comcast dot net

======
    if { [catch {

        package require TclCurl

        set soapEnv {
        <SOAP-ENV:Envelope 
          xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
          xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
          xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        >
            <SOAP-ENV:Body>
            <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature" 
                SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
              <zipcode xsi:type="xsd:string">11217</zipcode>
            </ns1:getTemp>
           </SOAP-ENV:Body>

        </SOAP-ENV:Envelope>}


        puts $soapEnv

        # Build Http Headers.
        set httpHeaders ""
        lappend httpHeaders "Content-Type: text/xml; charset=utf-8" 
        lappend httpHeaders "SoapAction: GetTemperature for zip"

        puts $httpHeaders

        set httpBody ""
        set response [::curl::transfer -url http://services.xmethods.net:80/soap/servlet/rpcrouter \
        -post 1 \
        -postfields $soapEnv \
        -httpheader $httpHeaders \
        -bodyvar httpBody]

        puts "Soap Response: $response"
        puts "Soap Body: $httpBody"

        set rExp {<return xsi:type="xsd:float">(.*?)</return>}

        set temp 0

        regexp $rExp $httpBody sMatch temp

        puts "Current Temp for zip 11217 is $temp degrees"

        puts "------------------------------------------------------------------------"

     } errorString] } {
        puts "Error: $errorString"
        set bSuccess 0
        puts "------------------------------------------------------------------------"
 }
======

----
Example procs to GET and POST ~ BvW

======
 proc http_get {url args} {
    set pairs {}
    foreach {name value} $args {
        lappend pairs "[curl::escape $name]=[curl::escape $value]"
    }
    append url ? [join $pairs &]

    set curlHandle [curl::init]
    $curlHandle configure -url $url -bodyvar html
    catch { $curlHandle perform } curlErrorNumber
    if { $curlErrorNumber != 0 } {
        error [curl::easystrerror $curlErrorNumber]
    }
    $curlHandle cleanup

    return $html
 }

 proc http_post {url args} {
    set pairs {}
    foreach {name value} $args {
        lappend pairs "[curl::escape $name]=[curl::escape $value]"
    }
    set data [join $pairs &]

    set curlHandle [curl::init]
    $curlHandle configure -url $url -bodyvar html -post 1 -postfields $data
    catch { $curlHandle perform } curlErrorNumber
    if { $curlErrorNumber != 0 } {
        error [curl::easystrerror $curlErrorNumber]
    }
    $curlHandle cleanup

    return $html
 }
======

-----
<<discussion>> install TclCurl on CentOS6 64bit
[HaO] 2013-05-06: Install TclCurl 7.22.0 on:
CentOS 6 64bit with 'config.site' from [http://wiki.tcl.tk/3298].

The curl version provided by CentOS is 7.19.7 while TclCurl requires 7.21.4 -> install curl 8.30.0 first:
======none
./configure
make
sudo make install
======
Installs libcurl '/usr/local/lib64/libcurl.so.4.3.0' and the development files in '/usr/local/include/curl'.

Now, compilation of TclCurl works fine:
======none
./configure --with-tcl=/usr/local/lib64
make
sudo make install
======

Installs tclcurl in folder '/usr/local/lib64/TclCurl7.22.0'.
======tcl
%package require TclCurl
7.22.0
======

<<discussion>>

<<categories>> Example | Internet | Package | Broken links