diff --git a/library/http/http.tcl b/library/http/http.tcl index f7dae16f78b..26893fbe8f1 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -5359,10 +5359,10 @@ proc http::LoadThreadIfNeeded {} { set http(usingThread) 0 return } - if {[catch {package require Thread 2.8.9-}]} { + if {[catch {package require Thread}]} { if {$http(-threadlevel) == 2} { set msg {[http::config -threadlevel] has value 2,\ - but the Thread package (2.8.9 or above) is not available} + but the Thread package is not available} return -code error $msg } set http(usingThread) 0 @@ -5389,7 +5389,7 @@ proc http::LoadThreadIfNeeded {} { # ------------------------------------------------------------------------------ proc http::SockInThread {caller defcmd sockargs} { - package require Thread 2.8.9- + package require Thread set catchCode [catch {eval $defcmd $sockargs} sock errdict] if {$catchCode == 0} { diff --git a/tests/http.test b/tests/http.test index 4945574869b..f7bb7237b88 100644 --- a/tests/http.test +++ b/tests/http.test @@ -19,6 +19,9 @@ if {"::tcltest" ni [namespace children]} { package require http 2.10 #http::register http 80 ::socket +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + proc bgerror {args} { global errorInfo puts stderr "http.test bgerror" @@ -68,6 +71,11 @@ if {[catch {package present Thread}] == 0 && [file exists $httpdFile]} { set threadStack {} } +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -85,6 +93,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -162,7 +173,7 @@ test http-3.3.$ThreadLevel {http::geturl} -body { set token [http::geturl $url] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET /

@@ -182,7 +193,7 @@ test http-3.4.$ThreadLevel {http::geturl} -body { set token [http::geturl $url] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -197,7 +208,7 @@ test http-3.5.$ThreadLevel {http::geturl} -body { http::data $token } -cleanup { http::config -proxyfilter http::ProxyRequired - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET http:$url

@@ -208,7 +219,7 @@ test http-3.6.$ThreadLevel {http::geturl} -body { http::data $token } -cleanup { http::config -proxyfilter http::ProxyRequired - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -217,7 +228,7 @@ test http-3.7.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -headers {Pragma no-cache}] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -226,7 +237,7 @@ test http-3.8.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -query Name=Value&Foo=Bar -timeout 3000] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

POST $tail

@@ -240,7 +251,7 @@ test http-3.9.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -validate 1] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 200 OK" test http-3.10.$ThreadLevel {http::geturl queryprogress} -setup { set query foo=bar @@ -253,17 +264,17 @@ test http-3.10.$ThreadLevel {http::geturl queryprogress} -setup { set sep & } } -body { - proc postProgress {token x y} { + proc postProgress {tok x y} { global postProgress lappend postProgress $y } set postProgress {} - set t [http::geturl $posturl -keepalive 0 -query $query \ + set token [http::geturl $posturl -keepalive 0 -query $query \ -queryprogress postProgress -queryblocksize 16384] - http::wait $t - list [http::status $t] [string length $query] $postProgress [http::data $t] + http::wait $token + list [http::status $token] [string length $query] $postProgress [http::data $token] } -cleanup { - http::cleanup $t + catch {http::cleanup $token} } -result {ok 122879 {16384 32768 49152 65536 81920 98304 114688 122879} {Got 122879 bytes}} test http-3.11.$ThreadLevel {http::geturl querychannel with -command} -setup { set query foo=bar @@ -278,26 +289,26 @@ test http-3.11.$ThreadLevel {http::geturl querychannel with -command} -setup { set file [makeFile $query outdata] } -body { set fp [open $file] - proc asyncCB {token} { + proc asyncCB {tok} { global postResult - lappend postResult [http::data $token] + lappend postResult [http::data $tok] } 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]] + set token [http::geturl $posturl -querychannel $fp] + http::wait $token + set testRes [list [http::status $token] [string length $query] [http::data $token]] # Now do async - http::cleanup $t + http::cleanup $token close $fp set fp [open $file] - set t [http::geturl $posturl -querychannel $fp -command asyncCB] + set token [http::geturl $posturl -querychannel $fp -command asyncCB] set postResult [list PostStart] - http::wait $t + http::wait $token close $fp - lappend testRes [http::status $t] $postResult + lappend testRes [http::status $token] $postResult } -cleanup { removeFile outdata - http::cleanup $t + catch {http::cleanup $token} } -result {ok 122879 {Got 122880 bytes} ok {PostStart {Got 122880 bytes}}} # On Linux platforms when the client and server are on the same host, the # client is unable to read the server's response one it hits the write error. @@ -317,11 +328,11 @@ test http-3.12.$ThreadLevel {http::geturl querychannel with aborted request} -se set file [makeFile $query outdata] } -constraints {nonPortable} -body { set fp [open $file] - proc asyncCB {token} { + proc asyncCB {tok} { global postResult - lappend postResult [http::data $token] + lappend postResult [http::data $tok] } - proc postProgress {token x y} { + proc postProgress {tok x y} { global postProgress lappend postProgress $y } @@ -329,18 +340,18 @@ test http-3.12.$ThreadLevel {http::geturl querychannel with aborted request} -se # Now do async set postResult [list PostStart] if {[catch { - set t [http::geturl $badposturl -querychannel $fp -command asyncCB \ + set token [http::geturl $badposturl -querychannel $fp -command asyncCB \ -queryprogress postProgress] - http::wait $t - upvar #0 $t state + http::wait $token + upvar #0 $token state } err]} { puts $::errorInfo error $err } - list [http::status $t] [http::code $t] + list [http::status $token] [http::code $token] } -cleanup { removeFile outdata - http::cleanup $t + catch {http::cleanup $token} } -result {ok {HTTP/1.0 200 Data follows}} test http-3.13.$ThreadLevel {http::geturl socket leak test} { set chanCount [llength [file channels]] @@ -354,7 +365,7 @@ test http-3.14.$ThreadLevel "http::geturl $fullurl" -body { set token [http::geturl $fullurl -validate 1] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 200 OK" test http-3.15.$ThreadLevel {http::geturl parse failures} -body { http::geturl "{invalid}:url" @@ -393,7 +404,7 @@ test http-3.25.$ThreadLevel {http::meta} -setup { array set m [http::meta $token] lsort [array names m] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain m token } -result {content-length content-type date} test http-3.26.$ThreadLevel {http::meta} -setup { @@ -403,7 +414,7 @@ test http-3.26.$ThreadLevel {http::meta} -setup { array set m [http::meta $token] lsort [array names m] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain m token } -result {content-length content-type date x-check} test http-3.27.$ThreadLevel {http::geturl: -headers override -type} -body { @@ -411,7 +422,7 @@ test http-3.27.$ThreadLevel {http::geturl: -headers override -type} -body { -headers [list "Content-Type" "text/plain;charset=utf-8"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Content-Type {text/plain;charset=utf-8} @@ -424,7 +435,7 @@ test http-3.28.$ThreadLevel {http::geturl: -headers override -type default} -bod -headers [list "Content-Type" "text/plain;charset=utf-8"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Content-Type {text/plain;charset=utf-8} @@ -444,19 +455,19 @@ test http-3.29.$ThreadLevel {http::geturl IPv6 address} -body { } set error } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 0 test http-3.30.$ThreadLevel {http::geturl query without path} -body { set token [http::geturl $authorityurl?var=val] http::ncode $token } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 200 test http-3.31.$ThreadLevel {http::geturl fragment without path} -body { set token [http::geturl "$authorityurl#fragment42"] http::ncode $token } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 200 # Bug c11a51c482 test http-3.32.$ThreadLevel {http::geturl: -headers override -accept default} -body { @@ -464,7 +475,7 @@ test http-3.32.$ThreadLevel {http::geturl: -headers override -accept default} -b -headers [list "Accept" "text/plain,application/tcl-test-value"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Accept text/plain,application/tcl-test-value @@ -477,7 +488,7 @@ test http-3.33.$ThreadLevel {http::geturl application/xml is text} -body { set token [http::geturl "$xmlurl"] scan [http::data $token] "<%\[^>]>%c<%\[^>]>" } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result {test 4660 /test} test http-3.34.$ThreadLevel {http::geturl -headers not a list} -returnCodes error -body { http::geturl http://test/t -headers \" @@ -492,7 +503,7 @@ test http-4.1.$ThreadLevel {http::Event} -body { array set meta $data(meta) expr {($data(totalsize) == $meta(content-length))} } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result 1 test http-4.2.$ThreadLevel {http::Event} -body { set token [http::geturl $url] @@ -500,13 +511,13 @@ test http-4.2.$ThreadLevel {http::Event} -body { array set meta $data(meta) string compare $data(type) [string trim $meta(content-type)] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result 0 test http-4.3.$ThreadLevel {http::Event} -body { set token [http::geturl $url] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {HTTP/1.0 200 Data follows} test http-4.4.$ThreadLevel {http::Event} -setup { set testfile [makeFile "" testfile] @@ -520,7 +531,7 @@ test http-4.4.$ThreadLevel {http::Event} -setup { catch {close $in} catch {close $out} removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -536,7 +547,7 @@ test http-4.5.$ThreadLevel {http::Event} -setup { expr {$data(currentsize) == $data(totalsize)} } -cleanup { removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result 1 test http-4.6.$ThreadLevel {http::Event} -setup { set testfile [makeFile "" testfile] @@ -551,7 +562,7 @@ test http-4.6.$ThreadLevel {http::Event} -setup { catch {close $in} catch {close $out} removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result "$bindata[string trimleft $binurl /]" proc myProgress {token total current} { global progress httpLog @@ -568,25 +579,25 @@ test http-4.7.$ThreadLevel {http::Event} -body { set token [http::geturl $url -keepalive 0 -progress myProgress] return $progress } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {111 111} test http-4.8.$ThreadLevel {http::Event} -body { set token [http::geturl $url] http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {ok} test http-4.9.$ThreadLevel {http::Event} -body { set token [http::geturl $url -progress myProgress] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {HTTP/1.0 200 Data follows} test http-4.10.$ThreadLevel {http::Event} -body { set token [http::geturl $url -progress myProgress] http::size $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {111} # Timeout cases @@ -597,7 +608,7 @@ test http-4.11.$ThreadLevel {http::Event} -body { http::reset $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {reset} # Longer timeout with reset. @@ -606,7 +617,7 @@ test http-4.12.$ThreadLevel {http::Event} -body { http::reset $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {reset} # Medium timeout to working server that waits even longer. The timeout @@ -616,7 +627,7 @@ test http-4.13.$ThreadLevel {http::Event} -body { http::wait $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {timeout} # Longer timeout to good host, bad port, gets an error after the @@ -704,7 +715,7 @@ test http-6.1.$ThreadLevel {http::ProxyRequired} -body { set data(body) } -cleanup { http::config -proxyhost {} -proxyport {} - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET http:$url

@@ -1202,7 +1213,10 @@ if {[info exists removeHttpd]} { } rename bgerror {} -::tcltest::cleanupTests + +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} # Local variables: # mode: tcl diff --git a/tests/http11.test b/tests/http11.test index af35763e842..0b3c560b8ee 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -87,6 +87,14 @@ makeFile "test

this is a test

\n[st makeFile "test

this is a test

\n[string repeat {

This is a tcl test file.

} 5000]\n" largedoc.html +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -101,6 +109,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -116,7 +127,7 @@ test http11-1.0.$ThreadLevel "normal request for document " -setup { http::wait $tok list [http::status $tok] [http::code $tok] [check_crc $tok] [meta $tok connection] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close} @@ -130,7 +141,7 @@ test http11-1.1.$ThreadLevel "normal,gzip,non-chunked" -setup { [meta $tok content-encoding] [meta $tok transfer-encoding] \ [http::meta $tok content-encoding] [http::meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok gzip {} {content-encoding gzip} {}} @@ -143,7 +154,7 @@ test http11-1.2.$ThreadLevel "normal,deflated,non-chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate {}} @@ -156,7 +167,7 @@ test http11-1.2.1.$ThreadLevel "normal,deflated,non-chunked,msdeflate" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate {}} @@ -171,7 +182,7 @@ test http11-1.3.$ThreadLevel "normal,compressed,non-chunked" -constraints badCom list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok compress {}} @@ -184,7 +195,7 @@ test http11-1.4.$ThreadLevel "normal,identity,non-chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} {}} @@ -197,7 +208,7 @@ test http11-1.5.$ThreadLevel "normal request for document, unsupported coding" - list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {}} @@ -211,7 +222,7 @@ test http11-1.6.$ThreadLevel "normal, specify 1.1 " -setup { [meta $tok connection] [meta $tok transfer-encoding] \ [http::meta $tok connection] [http::meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close chunked {connection close} {transfer-encoding chunked}} @@ -224,7 +235,7 @@ test http11-1.7.$ThreadLevel "normal, 1.1 and keepalive " -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} chunked} @@ -237,7 +248,7 @@ test http11-1.8.$ThreadLevel "normal, 1.1 and keepalive, server close" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {}} @@ -250,7 +261,7 @@ test http11-1.9.$ThreadLevel "normal,gzip,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok gzip chunked} @@ -263,7 +274,7 @@ test http11-1.10.$ThreadLevel "normal,deflate,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate chunked} @@ -276,7 +287,7 @@ test http11-1.10.1.$ThreadLevel "normal,deflate,chunked,msdeflate" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate chunked} @@ -291,7 +302,7 @@ test http11-1.11.$ThreadLevel "normal,compress,chunked" -constraints badCompress list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok compress chunked} @@ -304,7 +315,7 @@ test http11-1.12.$ThreadLevel "normal,identity,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} chunked} @@ -325,8 +336,8 @@ test http11-1.13.$ThreadLevel "normal, 1.1 and keepalive as server default, no z [meta $toj connection] [meta $toj transfer-encoding] [state $toj reusing] [state $toj connection]] concat $res1 -- $res2 } -cleanup { - http::cleanup $tok - http::cleanup $toj + catch {http::cleanup $tok} + catch {http::cleanup $toj} halt_httpd http::config -zip $zipTmp } -result {ok {HTTP/1.1 200 OK} ok {} {} 0 keep-alive -- ok {HTTP/1.1 200 OK} ok {} {} 1 keep-alive} @@ -359,7 +370,7 @@ test http11-2.0.$ThreadLevel "-channel" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok $data]\ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -379,7 +390,7 @@ test http11-2.1.$ThreadLevel "-channel, encoding gzip" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] -- $diff bytes lost } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -403,7 +414,7 @@ test http11-2.1.1.$ThreadLevel "-channel, encoding gzip" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] -- $diff bytes lost } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -422,7 +433,7 @@ test http11-2.2.$ThreadLevel "-channel, encoding deflate" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -441,7 +452,7 @@ test http11-2.2.1.$ThreadLevel "-channel, encoding deflate,msdeflate" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -463,7 +474,7 @@ test http11-2.3.$ThreadLevel "-channel,encoding compress" -constraints badCompre [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -483,7 +494,7 @@ test http11-2.4.$ThreadLevel "-channel,encoding identity" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -508,7 +519,7 @@ test http11-2.4.1.$ThreadLevel "-channel,encoding identity with -progress" -setu [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $data]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -534,7 +545,7 @@ test http11-2.4.2.$ThreadLevel "-channel,encoding identity with -progress progre [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $data]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -555,7 +566,7 @@ test http11-2.5.$ThreadLevel "-channel,encoding unsupported" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -575,7 +586,7 @@ test http11-2.6.$ThreadLevel "-channel,encoding gzip,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -595,7 +606,7 @@ test http11-2.7.$ThreadLevel "-channel,encoding deflate,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -618,7 +629,7 @@ test http11-2.7.1.$ThreadLevel "-channel,encoding deflate,non-chunked,msdeflate" [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -640,7 +651,7 @@ test http11-2.8.$ThreadLevel "-channel,encoding compress,non-chunked" -constrain [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -660,7 +671,7 @@ test http11-2.9.$ThreadLevel "-channel,encoding identity,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -681,7 +692,7 @@ test http11-2.10.$ThreadLevel "-channel,deflate,keepalive" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -702,7 +713,7 @@ test http11-2.10.1.$ThreadLevel "-channel,deflate,keepalive,msdeflate" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -722,7 +733,7 @@ test http11-2.11.$ThreadLevel "-channel,identity,keepalive" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -742,7 +753,7 @@ test http11-2.12.$ThreadLevel "-channel,negotiate,keepalive" -setup { [meta $tok transfer-encoding] [meta $tok x-requested-encodings]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -788,7 +799,7 @@ test http11-3.0.$ThreadLevel "-handler,close,identity" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -806,7 +817,7 @@ test http11-3.1.$ThreadLevel "-handler,protocol1.0" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -824,7 +835,7 @@ test http11-3.2.$ThreadLevel "-handler,close,chunked" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -842,7 +853,7 @@ test http11-3.3.$ThreadLevel "-handler,keepalive,chunked" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -869,7 +880,7 @@ test http11-3.4.$ThreadLevel "-handler,close,identity; HTTP/1.0 server does not [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok {} {} {} 0} @@ -887,7 +898,7 @@ test http11-3.5.$ThreadLevel "-handler,close,identity as http11-3.0 but handlerP [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -908,7 +919,7 @@ test http11-3.6.$ThreadLevel "-handler,close,identity as http11-3.0 but with -pr [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} @@ -929,7 +940,7 @@ test http11-3.7.$ThreadLevel "-handler,close,identity as http11-3.0 but with -pr [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} @@ -950,7 +961,7 @@ test http11-3.8.$ThreadLevel "close,identity no -handler but with -progress" -se [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} @@ -971,7 +982,7 @@ test http11-3.9.$ThreadLevel "close,identity no -handler but with -progress prog [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} @@ -988,7 +999,7 @@ test http11-4.0.$ThreadLevel "normal post request" -setup { connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 7} @@ -1005,7 +1016,7 @@ test http11-4.1.$ThreadLevel "normal post request, check query length" -setup { connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 7} @@ -1022,7 +1033,7 @@ test http11-4.2.$ThreadLevel "normal post request, check long query length" -set connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 24576} @@ -1042,7 +1053,7 @@ test http11-4.3.$ThreadLevel "normal post request, check channel query length" - connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -1064,4 +1075,6 @@ removeFile testdoc.html removeFile largedoc.html unset -nocomplain httpd_port httpd p -::tcltest::cleanupTests +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} diff --git a/tests/httpPipeline.test b/tests/httpPipeline.test index 491aae09f03..ef62aa36331 100644 --- a/tests/httpPipeline.test +++ b/tests/httpPipeline.test @@ -19,6 +19,14 @@ package require http 2.10 # (0) Socket Creation in Thread, which triples the number of tests. # ------------------------------------------------------------------------------ +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -33,6 +41,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -889,4 +900,6 @@ unset header footer delay label suffix match cons name te namespace delete ::httpTest namespace delete ::httpTestScript -::tcltest::cleanupTests +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} diff --git a/tests/httpProxy.test b/tests/httpProxy.test index 24b6e8c5aaa..5fdc326d4d4 100644 --- a/tests/httpProxy.test +++ b/tests/httpProxy.test @@ -18,7 +18,17 @@ if {"::tcltest" ni [namespace children]} { } package require http 2.10 -#http::register http 80 ::socket + +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 +#testConstraint needsSquidNoAuth 0 +#testConstraint needsSquidAuth 0 +#testConstraint needsTclTls 0 +#testConstraint needsTwapi 0 +#testConstraint needsTwapiFull 0 +#testConstraint knownBug 0 +# +# The values of constraints needsTls, knownTwapiFullBugThreadlevelAny, knownTwapiFullBugThreadUsed are always generated by this script. proc bgerror {args} { global errorInfo @@ -30,9 +40,24 @@ proc bgerror {args} { proc stopMe {token} { set ${token}(z) done } -#set ThreadLevel 0 +proc putsBlurb {} { + puts {} + puts {- Constraints needsTls, knownTwapiFullBugThreadlevelAny, knownTwapiFullBugThreadUsed are} + puts { always set by the script, not by the caller.} + puts {- Set one of needsTclTls, needsTwapi, needsTwapiFull instead of needsTls.} + puts {- Set knownBug instead of knownTwapiFullBugThreadlevelAny, knownTwapiFullBugThreadUsed.} + puts {- If the caller sets constraint needsTwapi, the script forces needsSquidNoAuth and needsSquidAuth to 0.} + puts {} + return +} + +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { - if {[catch {package require Thread 2.8.9-}] == 0} { + if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} } else { set ValueRange {0 1} @@ -45,17 +70,16 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + putsBlurb + ::tcltest::cleanupTests + } return } catch {puts "==== Test with ThreadLevel $ThreadLevel ===="} http::config -threadlevel $ThreadLevel - -testConstraint needsSquidNoAuth 0 -testConstraint needsSquidAuth 0 -testConstraint needsTclTls 0 -testConstraint needsTwapi 0 -testConstraint needsTwapiFull 0 + testConstraint needsTls [expr { [testConstraint needsTclTls] || [testConstraint needsTwapi] || [testConstraint needsTwapiFull] @@ -65,6 +89,8 @@ if {[testConstraint needsTclTls]} { package require tls http::register https 443 [list ::tls::socket -ssl2 0 -ssl3 0 \ -tls1 0 -tls1.1 0 -tls1.2 1 -tls1.3 0 -autoservername 1] ::tls::socketCmd 1 1 + testConstraint knownTwapiFullBugThreadlevelAny 1 + testConstraint knownTwapiFullBugThreadUsed 1 } elseif {[testConstraint needsTwapi]} { # "Original" http::register with 3 arguments has the same capabilities as # in http 2.9 and earlier. This means that: @@ -76,6 +102,8 @@ if {[testConstraint needsTclTls]} { testConstraint needsSquidAuth 0 package require twapi http::register https 443 ::twapi::tls_socket + testConstraint knownTwapiFullBugThreadlevelAny 1 + testConstraint knownTwapiFullBugThreadUsed 1 } elseif {[testConstraint needsTwapiFull]} { # (Any revisions to TWAPI, and the contents/existence of the twapiTlsPlus # wrapper, can be negotiated if the bugs listed below can be fixed.) @@ -94,17 +122,39 @@ if {[testConstraint needsTclTls]} { # while executing # "http::geturl https://www.google.com/" # + source [file join [file dirname [info script]] twapiTlsPlus.tcl] package require twapiTlsPlus http::register https 443 ::twapiTlsPlus::socket ::twapiTlsPlus::socketCmd 1 1 + testConstraint knownTwapiFullBugThreadlevelAny [testConstraint knownBug] + + if {($ThreadLevel == 1)} { + if {[catch {package require Thread}]} { + set usingThread 0 + } else { + set usingThread 2 + } + } else { + set usingThread $ThreadLevel + } + if {$usingThread} { + testConstraint knownTwapiFullBugThreadUsed [testConstraint knownBug] + } else { + testConstraint knownTwapiFullBugThreadUsed 1 + } } else { } # Testing with Squid # - Example Squid configuration for Enterprise Linux 8 (Red Hat, Oracle, Rocky, # Alma, ...) is in file tests/httpProxySquidConfigForEL8.tar.gz. +# - Example Squid configuration for Diladele Squid on Windows is in +# file tests/httpProxySquidConfigForWindowsDiladele.zip. +# # - Two instances of Squid are launched, one that needs authentication and one # that does not. # - Each instance of Squid listens on IPv4 and IPv6, on different ports. +# - If only one instance of Squid can be launched at a time, use the separate +# constraints needsSquidNoAuth, needsSquidAuth when testing. # Instance of Squid that does not need authentication. set n4host 127.0.0.1 @@ -124,100 +174,135 @@ set aliceCreds {Basic YWxpY2U6YWxpY2lh} # concat Basic [base64::encode intruder:intruder] set badCreds {Basic aW50cnVkZXI6aW50cnVkZXI=} +# For the benefit of the target server, have a short delay between tests. +set fetchPause 200 + +foreach constr { + ThreadLevelSummary + needsSquidNoAuth + needsSquidAuth + needsTclTls + needsTwapi + needsTwapiFull + needsTls + knownTwapiFullBugThreadlevelAny + knownTwapiFullBugThreadUsed +} { + # For debugging. + # puts [list testConstraint $constr [testConstraint $constr]] +} +#putsBlurb + test httpProxy-1.1.$ThreadLevel {squid is running - ipv4 no-auth} -constraints {needsSquidNoAuth} -setup { } -body { + after $fetchPause + set token [http::geturl http://$n4host:$n4port/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed]" } -result {complete ok 400 -- none} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } test httpProxy-1.2.$ThreadLevel {squid is running - ipv6 no-auth} -constraints {needsSquidNoAuth} -setup { } -body { + after $fetchPause + set token [http::geturl http://\[$n6host\]:$n6port/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed]" } -result {complete ok 400 -- none} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } test httpProxy-1.3.$ThreadLevel {squid is running - ipv4 with-auth} -constraints {needsSquidAuth} -setup { } -body { + after $fetchPause + set token [http::geturl http://$a4host:$a4port/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed]" } -result {complete ok 400 -- none} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } test httpProxy-1.4.$ThreadLevel {squid is running - ipv6 with-auth} -constraints {needsSquidAuth} -setup { } -body { + after $fetchPause + set token [http::geturl http://\[$a6host\]:$a6port/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed]" } -result {complete ok 400 -- none} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } test httpProxy-2.1.$ThreadLevel {http no-proxy no-auth} -constraints {} -setup { http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } -test httpProxy-2.2.$ThreadLevel {https no-proxy no-auth} -constraints {needsTls} -setup { +test httpProxy-2.2.$ThreadLevel {https no-proxy no-auth} -constraints {needsTls knownTwapiFullBugThreadUsed} -setup { http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res } test httpProxy-2.3.$ThreadLevel {http with-proxy ipv4 no-auth} -constraints {needsSquidNoAuth} -setup { http::config -proxyhost $n4host -proxyport $n4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- HttpProxy -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res http::config -proxyhost {} -proxyport {} -proxynot {} } -test httpProxy-2.4.$ThreadLevel {https with-proxy ipv4 no-auth} -constraints {needsSquidNoAuth needsTls} -setup { +test httpProxy-2.4.$ThreadLevel {https with-proxy ipv4 no-auth} -constraints {needsSquidNoAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $n4host -proxyport $n4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- SecureProxy -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res http::config -proxyhost {} -proxyport {} -proxynot {} } @@ -225,27 +310,31 @@ test httpProxy-2.4.$ThreadLevel {https with-proxy ipv4 no-auth} -constraints {ne test httpProxy-2.5.$ThreadLevel {http with-proxy ipv6 no-auth} -constraints {needsSquidNoAuth} -setup { http::config -proxyhost $n6host -proxyport $n6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- HttpProxy -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res http::config -proxyhost {} -proxyport {} -proxynot {} } -test httpProxy-2.6.$ThreadLevel {https with-proxy ipv6 no-auth} -constraints {needsSquidNoAuth needsTls} -setup { +test httpProxy-2.6.$ThreadLevel {https with-proxy ipv6 no-auth} -constraints {needsSquidNoAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $n6host -proxyport $n6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set res "[dict get $ri stage] [dict get $ri status] [dict get $ri responseCode] --\ [dict get $ri proxyUsed] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- SecureProxy -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res http::config -proxyhost {} -proxyport {} -proxynot {} } @@ -253,6 +342,8 @@ test httpProxy-2.6.$ThreadLevel {https with-proxy ipv6 no-auth} -constraints {ne test httpProxy-3.1.$ThreadLevel {http no-proxy with-auth valid-creds-provided} -constraints {} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -261,14 +352,16 @@ test httpProxy-3.1.$ThreadLevel {http no-proxy with-auth valid-creds-provided} - [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.2.$ThreadLevel {https no-proxy with-auth valid-creds-provided} -constraints {needsTls} -setup { +test httpProxy-3.2.$ThreadLevel {https no-proxy with-auth valid-creds-provided} -constraints {needsTls knownTwapiFullBugThreadUsed} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -277,7 +370,7 @@ test httpProxy-3.2.$ThreadLevel {https no-proxy with-auth valid-creds-provided} [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -285,6 +378,8 @@ test httpProxy-3.2.$ThreadLevel {https no-proxy with-auth valid-creds-provided} test httpProxy-3.3.$ThreadLevel {http with-proxy ipv4 with-auth valid-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -293,14 +388,16 @@ test httpProxy-3.3.$ThreadLevel {http with-proxy ipv4 with-auth valid-creds-prov [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- HttpProxy 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.4.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.4.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -309,7 +406,7 @@ test httpProxy-3.4.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-pro [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- SecureProxy 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -317,6 +414,8 @@ test httpProxy-3.4.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-pro test httpProxy-3.5.$ThreadLevel {http with-proxy ipv6 with-auth valid-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -325,14 +424,16 @@ test httpProxy-3.5.$ThreadLevel {http with-proxy ipv6 with-auth valid-creds-prov [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- HttpProxy 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.6.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.6.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -341,7 +442,7 @@ test httpProxy-3.6.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-pro [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- SecureProxy 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -349,8 +450,11 @@ test httpProxy-3.6.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-pro test httpProxy-3.7.$ThreadLevel {http with-proxy ipv4 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -365,8 +469,8 @@ test httpProxy-3.7.$ThreadLevel {http with-proxy ipv4 with-auth valid-creds-prov [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -375,10 +479,13 @@ test httpProxy-3.7.$ThreadLevel {http with-proxy ipv4 with-auth valid-creds-prov test httpProxy-3.7x.$ThreadLevel {http with-proxy ipv4 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] http::config -proxyauth $aliceCreds } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -393,18 +500,21 @@ test httpProxy-3.7x.$ThreadLevel {http with-proxy ipv4 with-auth 1st request no- [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.8.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.8.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $aliceCreds + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -421,20 +531,23 @@ test httpProxy-3.8.$ThreadLevel {https with-proxy ipv4 with-auth valid-creds-pro [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- SecureProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.8x.$ThreadLevel {https with-proxy ipv4 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.8x.$ThreadLevel {https with-proxy ipv4 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] http::config -proxyauth $aliceCreds } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -451,8 +564,8 @@ test httpProxy-3.8x.$ThreadLevel {https with-proxy ipv4 with-auth 1st request no [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- SecureProxy 0 0 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -461,8 +574,11 @@ test httpProxy-3.8x.$ThreadLevel {https with-proxy ipv4 with-auth 1st request no test httpProxy-3.9.$ThreadLevel {http with-proxy ipv6 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -477,8 +593,8 @@ test httpProxy-3.9.$ThreadLevel {http with-proxy ipv6 with-auth valid-creds-prov [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -488,9 +604,13 @@ test httpProxy-3.9p.$ThreadLevel {http with-proxy ipv6 with-auth valid-creds-pro array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] after idle { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -508,8 +628,8 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -518,10 +638,13 @@ after idle { test httpProxy-3.9x.$ThreadLevel {http with-proxy ipv6 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] http::config -proxyauth $aliceCreds } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -536,18 +659,21 @@ test httpProxy-3.9x.$ThreadLevel {http with-proxy ipv6 with-auth 1st request no- [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.10.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.10.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -564,20 +690,24 @@ test httpProxy-3.10.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-pr [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- SecureProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.10p.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works, pipelining requested and possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.10p.$ThreadLevel {https with-proxy ipv6 with-auth valid-creds-provided; check that 2nd valid request with creds is possible, and keep-alive works, pipelining requested and possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $aliceCreds } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] after idle { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -597,20 +727,24 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- SecureProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-3.10x.$ThreadLevel {https with-proxy ipv6 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-3.10x.$ThreadLevel {https with-proxy ipv6 with-auth 1st request no-creds-provided; check that 2nd request with creds is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} + after $fetchPause + set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] http::config -proxyauth $aliceCreds } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -627,8 +761,8 @@ test httpProxy-3.10x.$ThreadLevel {https with-proxy ipv6 with-auth 1st request n [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 200 -- SecureProxy 0 0 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -637,6 +771,8 @@ test httpProxy-3.10x.$ThreadLevel {https with-proxy ipv6 with-auth 1st request n test httpProxy-4.1.$ThreadLevel {http no-proxy with-auth no-creds-provided} -constraints {} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -645,14 +781,16 @@ test httpProxy-4.1.$ThreadLevel {http no-proxy with-auth no-creds-provided} -con [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.2.$ThreadLevel {https no-proxy with-auth no-creds-provided} -constraints {needsTls} -setup { +test httpProxy-4.2.$ThreadLevel {https no-proxy with-auth no-creds-provided} -constraints {needsTls knownTwapiFullBugThreadUsed} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -661,7 +799,7 @@ test httpProxy-4.2.$ThreadLevel {https no-proxy with-auth no-creds-provided} -co [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -669,6 +807,8 @@ test httpProxy-4.2.$ThreadLevel {https no-proxy with-auth no-creds-provided} -co test httpProxy-4.3.$ThreadLevel {http with-proxy ipv4 with-auth no-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -677,14 +817,16 @@ test httpProxy-4.3.$ThreadLevel {http with-proxy ipv4 with-auth no-creds-provide [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- HttpProxy 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.4.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-4.4.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -693,7 +835,7 @@ test httpProxy-4.4.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- SecureProxyFailed 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -701,6 +843,8 @@ test httpProxy-4.4.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provid test httpProxy-4.5.$ThreadLevel {http with-proxy ipv6 with-auth no-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -709,14 +853,16 @@ test httpProxy-4.5.$ThreadLevel {http with-proxy ipv6 with-auth no-creds-provide [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- HttpProxy 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.6.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-4.6.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -725,7 +871,7 @@ test httpProxy-4.6.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- SecureProxyFailed 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -733,8 +879,11 @@ test httpProxy-4.6.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provid test httpProxy-4.7.$ThreadLevel {http with-proxy ipv4 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -749,18 +898,21 @@ test httpProxy-4.7.$ThreadLevel {http with-proxy ipv4 with-auth no-creds-provide [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.8.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-4.8.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -777,8 +929,8 @@ test httpProxy-4.8.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 0 0 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -787,8 +939,11 @@ test httpProxy-4.8.$ThreadLevel {https with-proxy ipv4 with-auth no-creds-provid test httpProxy-4.9.$ThreadLevel {http with-proxy ipv6 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -803,8 +958,8 @@ test httpProxy-4.9.$ThreadLevel {http with-proxy ipv6 with-auth no-creds-provide [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -814,9 +969,13 @@ test httpProxy-4.9p.$ThreadLevel {http with-proxy ipv6 with-auth no-creds-provid array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] after idle { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token0; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -834,18 +993,21 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 0 0 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.10.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-4.10.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -862,21 +1024,24 @@ test httpProxy-4.10.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provi [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 0 0 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-4.10p.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided; check that 2nd request is possible, pipelining requested but not possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-4.10p.$ThreadLevel {https with-proxy ipv6 with-auth no-creds-provided; check that 2nd request is possible, pipelining requested but not possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth {} } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] - after idle { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -896,8 +1061,8 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 0 0 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -906,6 +1071,8 @@ after idle { test httpProxy-5.1.$ThreadLevel {http no-proxy with-auth bad-creds-provided} -constraints {} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -914,14 +1081,16 @@ test httpProxy-5.1.$ThreadLevel {http no-proxy with-auth bad-creds-provided} -co [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.2.$ThreadLevel {https no-proxy with-auth bad-creds-provided} -constraints {needsTls} -setup { +test httpProxy-5.2.$ThreadLevel {https no-proxy with-auth bad-creds-provided} -constraints {needsTls knownTwapiFullBugThreadUsed} -setup { http::config -proxyhost {} -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -930,7 +1099,7 @@ test httpProxy-5.2.$ThreadLevel {https no-proxy with-auth bad-creds-provided} -c [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 200 -- none 0 0 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -938,6 +1107,8 @@ test httpProxy-5.2.$ThreadLevel {https no-proxy with-auth bad-creds-provided} -c test httpProxy-5.3.$ThreadLevel {http with-proxy ipv4 with-auth bad-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -946,14 +1117,16 @@ test httpProxy-5.3.$ThreadLevel {http with-proxy ipv4 with-auth bad-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- HttpProxy 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.4.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-5.4.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -962,7 +1135,7 @@ test httpProxy-5.4.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provi [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- SecureProxyFailed 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -970,6 +1143,8 @@ test httpProxy-5.4.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provi test httpProxy-5.5.$ThreadLevel {http with-proxy ipv6 with-auth bad-creds-provided} -constraints {needsSquidAuth} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl http://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -978,14 +1153,16 @@ test httpProxy-5.5.$ThreadLevel {http with-proxy ipv6 with-auth bad-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- HttpProxy 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.6.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provided} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-5.6.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provided} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set token [http::geturl https://www.google.com/] set ri [http::responseInfo $token] set pos1 [lsearch -exact [string tolower [set ${token}(requestHeaders)]] proxy-authorization] @@ -994,7 +1171,7 @@ test httpProxy-5.6.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provi [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*]" } -result {complete ok 407 -- SecureProxyFailed 1 1 -- -1} -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain token ri res pos1 pos2 http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } @@ -1002,8 +1179,11 @@ test httpProxy-5.6.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provi test httpProxy-5.7.$ThreadLevel {http with-proxy ipv4 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -1018,8 +1198,8 @@ test httpProxy-5.7.$ThreadLevel {http with-proxy ipv4 with-auth bad-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -1029,10 +1209,14 @@ test httpProxy-5.7p.$ThreadLevel {http with-proxy ipv4 with-auth bad-creds-provi array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] # Use the same caution as for the corresponding https test. after idle { + after $fetchPause + set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] vwait ${token}(z) @@ -1049,18 +1233,21 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.8.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-5.8.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -1077,23 +1264,27 @@ test httpProxy-5.8.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provi [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 1 1 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.8p.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided; check that 2nd request is possible, pipelining requested but not possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-5.8p.$ThreadLevel {https with-proxy ipv4 with-auth bad-creds-provided; check that 2nd request is possible, pipelining requested but not possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a4host -proxyport $a4port -proxynot {127.0.0.1 localhost} -proxyauth $badCreds } -body { + after $fetchPause + set can0 [after 6000 {http::reset $token0; set ${token0}(z) timeout}] set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. after idle { + after $fetchPause + set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] vwait ${token}(z) @@ -1110,8 +1301,8 @@ after idle { [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 1 1 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can0 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} @@ -1120,8 +1311,11 @@ after idle { test httpProxy-5.9.$ThreadLevel {http with-proxy ipv6 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $badCreds + after $fetchPause set token0 [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # Use the same caution as for the corresponding https test. set can [after 6000 {http::reset $token; set ${token}(z) timeout}] set token [http::geturl http://www.google.com/ -keepalive 1 -timeout 5000 -command stopMe] @@ -1136,18 +1330,21 @@ test httpProxy-5.9.$ThreadLevel {http with-proxy ipv6 with-auth bad-creds-provid [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- HttpProxy 1 1 -- -1 done 1} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } -test httpProxy-5.10.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls} -setup { +test httpProxy-5.10.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-provided; check that 2nd request is possible} -constraints {needsSquidAuth needsTls knownTwapiFullBugThreadlevelAny} -setup { array unset ::http::socketMapping http::config -proxyhost $a6host -proxyport $a6port -proxynot {::1 localhost} -proxyauth $badCreds + after $fetchPause set token0 [http::geturl https://www.google.com/ -keepalive 1 -timeout 5000] } -body { + after $fetchPause + # If a bug passes the socket of a failed CONNECT to the main request, an infinite # wait can occur despite -timeout. Fix this with http::reset; to do this the call # to http::geturl must be async so we have $token for use as argument of reset. @@ -1164,20 +1361,24 @@ test httpProxy-5.10.$ThreadLevel {https with-proxy ipv6 with-auth bad-creds-prov [dict get $ri proxyUsed] [expr {$pos1 > -1}] [expr {$pos2 > -1}] --\ [lsearch -glob [array get ::http::socketMapping] HTTP_PLACEHOLDER_*] [set ${token}(z)] $same" } -result {complete ok 407 -- SecureProxyFailed 1 1 -- -1 done 0} -cleanup { - http::cleanup $token0 - http::cleanup $token + catch {http::cleanup $token0} + catch {http::cleanup $token} unset -nocomplain token0 token ri res pos1 pos2 can same array unset ::http::socketMapping http::config -proxyhost {} -proxyport {} -proxynot {} -proxyauth {} } # cleanup -unset -nocomplain n4host n6host n4port n6port a4host a6host a4port a6port aliceCreds badCreds +unset -nocomplain n4host n6host n4port n6port a4host a6host a4port a6port aliceCreds badCreds fetchPause rename bgerror {} rename stopMe {} -::tcltest::cleanupTests +if {[testConstraint ThreadLevelSummary]} { + putsBlurb + ::tcltest::cleanupTests + rename putsBlurb {} +} # Local variables: # mode: tcl diff --git a/tests/httpProxySquidConfigForWindowsDiladele.zip b/tests/httpProxySquidConfigForWindowsDiladele.zip new file mode 100644 index 00000000000..714baa14134 Binary files /dev/null and b/tests/httpProxySquidConfigForWindowsDiladele.zip differ diff --git a/tests/twapiTlsPlus.tcl b/tests/twapiTlsPlus.tcl new file mode 100644 index 00000000000..d254e86498b --- /dev/null +++ b/tests/twapiTlsPlus.tcl @@ -0,0 +1,48 @@ +# Module twapiTlsPlus +# +# Temporary wrapper for package twapi, to expose the same API as package tls. +# - Command twapiTlsPlus::socket, cf. tls::socket, replacement for ::socket, for +# use with http::register. +# - Variable twapiTlsPlus::socketCmd, cf. tls::socketCmd, holds the value of the +# callback command used by twapi to open a socket. +# +# Intended to allow twapi TLS to use an https proxy server, and a background +# thread for evaluation of ::socket. +# +# For twapiTlsPlus to work correctly, twapi*/tls.tcl must be edited so that +#- set so [$socketcmd {*}$socket_args {*}$args] +#+ set so [{*}$socketcmd {*}$socket_args {*}$args] + +package require http +package require twapi + +namespace eval twapiTlsPlus { + variable socketCmd [::twapi::tls_socket_command] + namespace export socket +} + +# Proc twapiTlsPlus::socket +# Replacement for ::socket, use with http::register. + +proc twapiTlsPlus::socket {args} { + variable socketCmd + + set targ [lsearch -exact $args -type] + if {$targ != -1} { + set token [lindex $args $targ+1] + set args [lreplace $args $targ $targ+1 -socketcmd [list {*}$socketCmd -type $token]] + } + ::twapi::tls_socket {*}$args +} + +# Variable twapi::tls::_socket_cmd does it. + +proc twapiTlsPlus::TraceSocketCmd {args} { + variable socketCmd + ::twapi::tls_socket_command $socketCmd + return +} + +trace add variable ::twapiTlsPlus::socketCmd write ::twapiTlsPlus::TraceSocketCmd + +package provide twapiTlsPlus 0.1