Http async: Difference between revisions

From EggWiki
Jump to navigation Jump to search
(Created page with "The ::http::geturl command blocks until the operation completes, unless the -command option specifies a callback that is invoked when the HTTP transaction completes. <pre> package require http proc httpCallback {token} { regexp {(?i)<title>([^<>]+)} [http::data $token] -> title http::cleanup $token puts "Title was \"$title\"" } set token [::http::geturl http://netbsd.org -timeout 10000 -command httpCallback] <pre>")
 
(No difference)

Latest revision as of 20:58, 4 May 2024

The ::http::geturl command blocks until the operation completes, unless the -command option specifies a callback that is invoked when the HTTP transaction completes.

package require http

proc httpCallback {token} {
  regexp {(?i)<title>([^<>]+)} [http::data $token] -> title
  http::cleanup $token
  puts "Title was \"$title\""
}

set token [::http::geturl http://netbsd.org -timeout 10000 -command httpCallback]