What: TclCurl: "curl" is a "command line tool for transferring files with URL syntax"
Where: (for TclCurl) (link broken 2013-10-20) (for curl, libcurl)
Description: Tcl binding for libcurl, a library for accessing internet resources of various types. Supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE, LDAP, LDAPS, IMAP, IMAPS, POP, POP3, SMTP, SMTPS and gopher. libcurl is currently at version 7.30.0 while minimum required version is 7.21.4 and TclCurl is currently at version 7.22.0.
Updated: 5/2013
Contact: fandom at (Andres Garcia)

More background is available in "curl Simplifies Web Retrieval" ( ). (link broken 2013-10-20. Try )

Note that at least according to the Wikipedia article ( ), " website is no longer active and the archives have been destroyed or hidden." Clicking the link redirects the browser to a different domain and incorrectly strips off the / after ".com" (which creates a nonexistent domain name).

The original site appears to be gone.

An up-to-date mirror is at

also here: , with some updates for Curl 7.80.0 ( per!topic/comp.lang.tcl/s4P05GDddl4 )

So, how is TclCurl better than the bare http (or ftp) package? A few examples should help make that clear [ WWW::Search::* analogue; HotMail mass downloader]. But, wouldn't either of those examples be just as feasible to implement with the http package?

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 -file index.html \
        -httpproxytunnel 1 -proxy

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

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 and

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


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 {
            <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature" 
              <zipcode xsi:type="xsd:string">11217</zipcode>


        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 \
        -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

APN For a single retrieval, the curl::transfer command may be simpler than using Curl handles. For example,

curl::transfer -url $url -bodyvar html

is equivalent to above http_get procedure.

  install TclCurl on CentOS6 64bit

HaO 2013-05-06: Install TclCurl 7.22.0 on: CentOS 6 64bit with '' from [L1 ].

The curl version provided by CentOS is 7.19.7 while TclCurl requires 7.21.4 -> install curl 8.30.0 first:

sudo make install

Installs libcurl '/usr/local/lib64/' and the development files in '/usr/local/include/curl'.

Now, compilation of TclCurl works fine:

./configure --with-tcl=/usr/local/lib64
sudo make install

Installs tclcurl in folder '/usr/local/lib64/TclCurl7.22.0'.

%package require TclCurl

  install TclCurl on Slackware 15.0

pi31415 2022-09-14: Install TclCurl 7.22.0 on Slackware 15.0

$ curl -o tclcurl.tgz gopher://

  • extract the archive
  • fetch and verify the distfile
  • run the SlackBuild script
  • install the resulting package