Http async

From EggWiki
Revision as of 20:58, 4 May 2024 by Mortmann (talk | contribs) (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>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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]