# -- binary file download
#
# 

set testfilename1 binary.rvt
set binaryfile AngeloFish.jpg

::tcltest::test binary-1.1 {binary data test} {
    set page [::http::geturl "${urlbase}$testfilename1?test1=1"]
    file stat $binaryfile fs
    set fl [open $binaryfile r]
    chan configure $fl -translation binary
    set fcontent [read $fl]
    close $fl

    set ret [string equal -length $fs(size) [::http::data $page] $fcontent]
    set ret
} 1

::tcltest::test binary-2.1 {binary data test with 'include'} {
    set page [ ::http::geturl "${urlbase}$testfilename1?test2=1" ]
    file stat $binaryfile fs
    set fl [open $binaryfile r]
    chan configure $fl -translation binary
    set fcontent [read $fl]
    close $fl

    set ret [string equal -length $fs(size) [::http::data $page] $fcontent]
    set ret
} 1

::tcltest::test binary-3.1 {scoped binary output restores stdout} {
    set page [::http::geturl "${urlbase}binaryscope.tcl"]
    set data [::http::data $page]
    ::http::cleanup $page
    binary encode hex $data
} 00fffe014f4b
