http: endToEndProxy without useSockThread bypasses the proxy
Opena976e76bafee1943af1045e0f7d8b87b72afece3Created 49 days agoUpdated 49 days ago
Descriptionwiki2026-10-14 13:42:29
[http::register] documents useSockThread and endToEndProxy as independent options, but endToEndProxy only works when useSockThread is also true. Otherwise the request does not go through the configured proxy at all: http connects directly to the target server.
package require http
namespace eval my {variable socketCmd ::socket}
proc mysock {args} {puts "openCmd: $args"; $::my::socketCmd {*}$args}
http::register xs 443 mysock ::my::socketCmd 0 1
http::config -proxyhost 127.0.0.1 -proxyport 3128
http::geturl xs://example.invalid/
This prints openCmd: -async example.invalid 443 and fails with couldn't open socket: Name or service not known: it tries to connect to the target host directly instead of to the proxy. With ... ::my::socketCmd 1 1 it sends CONNECT example.invalid:443 to the proxy as expected.
The cause: http::geturl passes -type $token to the socket command only if useSockThread is true (library/http/http.tcl, if {$useSockThread} before set state(openCmd)). Without the token, http::socketAsCallback cannot see state(protoProxyConn), treats the connection as not proxied and calls http::AltSocket.
Log in (anonymous is fine) to add a comment.