Index: doc/tls.html ================================================================== --- doc/tls.html +++ doc/tls.html @@ -691,16 +691,19 @@ The use of the variable tls::debug is not recommended. It may be removed from future releases.

+ +

Debug Examples

+ +

These examples use the default Unix platform SSL certificates. For standard +installations, -cadir and -cafile should not be needed. If your certificates +are in non-standard locations, update -cadir or use -cafile as needed.


Example #1: Use HTTP package -

This example uses the default Unix platform SSL certificates. For standard -installations, -cadir and -cafile should not be needed. Update -cadir or -replace with -cafile if your platform differs.


 package require http
 package require tls
 set url "https://www.tcl.tk/"
@@ -750,13 +753,15 @@
 

HTTPS EXAMPLE

-

This example uses the default Unix platform SSL certificates. For standard -installations, -cadir and -cafile should not be needed. Update -cadir or -replace with -cafile if your platform differs.

+

These examples use the default Unix platform SSL certificates. For standard +installations, -cadir and -cafile should not be needed. If your certificates +are in non-standard locations, update -cadir or use -cafile as needed.

+ +Example #1: Get web page

 package require http
 package require tls
 set url "https://www.tcl.tk/"
@@ -769,13 +774,33 @@
     puts [format "Error %s" [http::status $token]]
 }
 
 # Get web page
 set data [http::data $token]
-puts [string length $data]
+puts $data
+
+# Cleanup
+::http::cleanup $token
+
+ +Example #2: Download file + +

+package require http
+package require tls
+
+set url "https://wiki.tcl-lang.org/sitemap.xml"
+set filename [file tail $url]
+
+http::register https 443 [list ::tls::socket -autoservername true -require true -cadir /etc/ssl/certs]
+
+# Get file
+set ch [open $filename wb]
+set token [::http::geturl $url -blocksize 65536 -channel $ch]
 
 # Cleanup
+close $ch
 ::http::cleanup $token
 

SPECIAL CONSIDERATIONS

@@ -785,16 +810,17 @@ Use the tls::protocols commands to obtain the supported protocol versions.

SEE ALSO

-

socket, fileevent, OpenSSL

+

socket, fileevent, http, +OpenSSL


 Copyright © 1999 Matt Newman.
 Copyright © 2004 Starfish Systems.
+Copyright © 2023 Brian O'Hagan.