#!/usr/local/bin/tclsh8.6

package require http
package require autoproxy
package require tls



proc init1 {} {
	set http_proxy_host "proxy"
	set http_proxy_port 8118
	::autoproxy::init
	::http::register https 443 [list ::autoproxy::tls_socket -ssl2 0 -ssl3 0 -tls1 1]
	::autoproxy::configure -proxy_host $http_proxy_host -proxy_port $http_proxy_port
}

proc init2 {} {
	::http::register https 443 ::tls::socket
}


proc scrape {} {
	set pageUrl "https://www.google.com/"
	set fp [::http::geturl $pageUrl -timeout 10000]
	set status [::http::status $fp]
	set ncode [::http::ncode $fp]
	set html [::http::data $fp]
	array set headers [::http::meta $fp]
	::http::cleanup $fp
}


init1
for {set i 0} {$i < 1000} {incr i} {
	puts "request $i"
	scrape
	puts [exec "/bin/ps" "auxw" "-p" [pid]]
}

