Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8c5b29629756779fe64ab9e9f38b8f81913cbe12c1be61802113bb7fb6d502dd
Ticket: a976e76bafee1943af1045e0f7d8b87b72afece3
http: endToEndProxy without useSockThread bypasses the proxy
User & Date: serhiy.storchaka on 2026-10-14 13:42:29
Changes

  1. cmimetype changed to: "text/x-fossil-wiki"
  2. comment changed to:
    <nowiki>[http::register]</nowiki> documents <i>useSockThread</i> and <i>endToEndProxy</i> as independent options, but <i>endToEndProxy</i> only works when <i>useSockThread</i> is also true. Otherwise the request does not go through the configured proxy at all: http connects directly to the target server.
    
    <verbatim>
    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/
    </verbatim>
    
    This prints <tt>openCmd: -async example.invalid 443</tt> and fails with <tt>couldn't open socket: Name or service not known</tt>: it tries to connect to the target host directly instead of to the proxy. With <tt>... ::my::socketCmd 1 1</tt> it sends <tt>CONNECT example.invalid:443</tt> to the proxy as expected.
    
    The cause: http::geturl passes <tt>-type $token</tt> to the socket command only if <i>useSockThread</i> is true (library/http/http.tcl, <tt>if {$useSockThread}</tt> before <tt>set state(openCmd)</tt>). Without the token, http::socketAsCallback cannot see state(protoProxyConn), treats the connection as not proxied and calls http::AltSocket.
    
  3. foundin changed to: "9.0.5, 9.1.0"
  4. login: "serhiy.storchaka"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. severity changed to: "Important"
  8. status changed to: "Open"
  9. submitter changed to: "serhiy.storchaka"
  10. subsystem changed to: "29. http Package"
  11. title changed to:
    http: endToEndProxy without useSockThread bypasses the proxy
    
  12. type changed to: "Bug"