home *** CD-ROM | disk | FTP | other *** search
/ Practical Programming in Tcl & Tk (4th Edition) / TCLBOOK4.BIN / pc / exsource.old / 17_10.tcl < prev    next >
Text File  |  2003-04-15  |  377b  |  22 lines

  1. #
  2. # Example 17-10
  3. # HttpGetText reads text URLs.
  4. #
  5.  
  6. proc HttpGetText {url} {
  7.     upvar #0 $url state
  8.     if {[eof $state(sock)]} {
  9.         # Content complete
  10.         set state(status) done
  11.         close $state(sock)
  12.     } elseif {[catch {read $state(sock)} block]} {
  13.         set state(status) error
  14.         lappend state(headers) [list error $block]
  15.         close $state(sock)
  16.     } else {
  17.         append state(body) $block
  18.     }
  19. }
  20.  
  21.  
  22.