summaryrefslogtreecommitdiffstats
path: root/tests/http.test
diff options
context:
space:
mode:
authorsandeep <sandeep>2000-03-19 22:32:25 (GMT)
committersandeep <sandeep>2000-03-19 22:32:25 (GMT)
commit442e6551351a2b2547562fcb091d24518900f248 (patch)
tree13ce9084d6c41a10a178d38efb3ce76757fc4f2d /tests/http.test
parent467352f3a6c9e72a15442c938d97adf75c80e247 (diff)
downloadtcl-442e6551351a2b2547562fcb091d24518900f248.zip
tcl-442e6551351a2b2547562fcb091d24518900f248.tar.gz
tcl-442e6551351a2b2547562fcb091d24518900f248.tar.bz2
* library/http2.1/http.tcl: Added -querychannel option and altered
some of Brent's modifications to allow asynchronous posts (via -command). Also modified -queryprogress so that it calls the query callback as <callback> <token> <total size> <current size> to be consistent with -progress. Added -queryblocksize option with default 8192 bytes for post blocksize. Fixed a bunch of potential memory leaks for the case when geturl receives bad args or can't open a socket, etc. Overall, the package really rocks now. * doc/http.n: Added -queryblocksize, -querychannel, and -queryprogress. Also, changed the description of -blocksize, which states that the -progress callback will be called for each block, to now qualify that with an "if -progress is specified". * tests/http.test: Added a querychannel test for synchronous and asynchronous posts, altered the queryprogress test such that the callback conforms to the -progress format. Also, had to use the -queryblocksize option to do the post 16K at a time to match Brent's expected results (and to test that -queryblocksize works).
Diffstat (limited to 'tests/http.test')
-rw-r--r--tests/http.test42
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/http.test b/tests/http.test
index af231d7..c242ae0 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -12,7 +12,7 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#
-# RCS: @(#) $Id: http.test,v 1.15 2000/03/17 02:15:18 welch Exp $
+# RCS: @(#) $Id: http.test,v 1.16 2000/03/19 22:32:26 sandeep Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -194,14 +194,48 @@ test http-3.10 {http::geturl queryprogress} {
proc postProgress {token x y} {
global postProgress
- lappend postProgress $x
+ lappend postProgress $y
}
set postProgress {}
set t [http::geturl $posturl -query $query \
- -queryprogress postProgress]
+ -queryprogress postProgress -queryblocksize 16384]
http::wait $t
list [http::status $t] [string length $query] $postProgress [http::data $t]
-} {ok 122879 {16384 32768 49152 65536 81920 98304 114688 131072} {Got 122879 bytes}}
+} {ok 122879 {16384 32768 49152 65536 81920 98304 114688 122879} {Got 122879 bytes}}
+
+test http-3.11 {http::geturl querychannel with -command} {
+ set query foo=bar
+ set sep ""
+ set i 0
+ # Create about 120K of query data
+ while {$i < 14} {
+ incr i
+ append query $sep$query
+ set sep &
+ }
+ ::tcltest::makeFile $query outdata
+ set fp [open outdata]
+
+ proc asyncCB {token} {
+ global postResult
+ lappend postResult [http::data $token]
+ }
+ set postResult [list ]
+ set t [http::geturl $posturl -querychannel $fp]
+ http::wait $t
+ set testRes [list [http::status $t] [string length $query] [http::data $t]]
+
+ # Now do async
+ http::cleanup $t
+ close $fp
+ set fp [open outdata]
+ set t [http::geturl $posturl -querychannel $fp -command asyncCB]
+ set postResult [list PostStart]
+ http::wait $t
+
+ lappend testRes [http::status $t] $postResult
+ set testRes
+} {ok 122879 {Got 122880 bytes} ok {PostStart {Got 122880 bytes}}}
test http-4.1 {http::Event} {