Added some extra accessors - in particular rawdata for fetching bytes instead of...
authorPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 13 Dec 2007 00:10:06 +0000 (00:10 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 13 Dec 2007 00:10:06 +0000 (00:10 +0000)
library/http.tcl

index d98fd6dc775abcb926fcff80afc431a435005693..6b89d951dd2fe1505503833b5d742dd1ed665635 100644 (file)
@@ -11,7 +11,7 @@
 package require tclole
 
 namespace eval ::ole::http {
-    variable version 1.0.0
+    variable version 1.1.0
     variable watchlist {}
     variable watchtimer {}
 
@@ -19,7 +19,7 @@ namespace eval ::ole::http {
 }
 
 proc ::ole::http::geturl {url args} {
-    variable uid
+    variable uid ; if {![info exists uid]} { set uid 0 }
     set token [namespace current]::http[incr uid]
     upvar #0 $token state
     array set state {method GET -query "" -command {} -timeout {} -progress {} -headers {}}
@@ -93,7 +93,6 @@ proc ::ole::http::Poll {} {
                             lappend state(meta) $h $v
                         }
                     }
-                    set state(body) [$state(xmlhttp) responseText]
                     if {$state(-command) ne ""} {
                         if {[catch {eval $state(-command) $token} err]} {
                             ::bgerror $err
@@ -128,7 +127,15 @@ proc ::ole::http::status {token} {
 }
 proc ::ole::http::data {token} {
     upvar #0 $token state
-    return $state(body)
+    return [$state(xmlhttp) responseText]
+}
+proc ::ole::http::rawdata {token} {
+    upvar #0 $token state
+    return [$state(xmlhttp) responseBody]
+}
+proc ::ole::http::xml {token} {
+    upvar #0 $token state
+    return [$state(xmlhttp) responseXml]
 }
 proc ::ole::http::ncode {token} {
     upvar #0 $token state