]> git.sven.stormbind.net Git - sven/tclcurl.git/blob - tests/bodyVar.tcl
releasing package tclcurl version 7.22.0+hg20160822-2
[sven/tclcurl.git] / tests / bodyVar.tcl
1 package require TclCurl
2
3 # These tests has some urls that don't exists outside my system,
4 # so IT WON'T WORK FOR YOU unless you change them.
5
6 set curlHandle [curl::init]
7 $curlHandle configure -url "127.0.0.1" -bodyvar body -noprogress 1 
8 $curlHandle perform
9
10 $curlHandle configure -url "127.0.0.1/~andres/" -bodyvar newBody
11 $curlHandle perform
12
13 $curlHandle cleanup
14
15 puts "First page:"
16 puts $body
17
18 puts "Second page:"
19 puts $newBody
20
21 # You can also use it for binary transfers
22
23 curl::transfer \
24         -url {127.0.0.1/~andres/HomePage/getleft/images/getleft.png} \
25         -bodyvar image -noprogress 1 -verbose 1
26
27 if [catch {open "getleft.png" w} out] {
28     puts "Could not open $out."
29     exit
30 }
31
32 fconfigure $out -translation binary
33 puts  $out $image
34 close $out
35
36