Skip to content
Tcl Source Code History Of Ticket 1173760fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1173760fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1173760fffffffffffffffffffffffffffffffff

  1. Ticket change [e33e69f6c1] (rid 87760) by melissachawla on 2005-03-31 01:40:24:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Package require http
      I tried to use http::geturl on an https url with a proxy 
      server, and I kept getting timeouts (or ran forever when 
      no timeout was specified).
      
      package require http
      package require tls
      http::config -proxyhost <my-squid-host> -proxyport <my-
      squid-port> 
      http::register https 443 ::tls::socket http::geturl 
      https://<server>:443/<path> -timeout 30000
      
      Currently, the http package will use a GET request via 
      HTTPS to a web server outside my firewall via a web 
      proxy server inside my firewall.  I am sure that the web
      proxy server works because I can use it to make the 
      same request through my browser.  The problem is that 
      http package needs to make a "CONNECT" request to 
      the proxy before making the GET request.  I believe that 
      http version 2.4 is affected in the same way.  Here's a 
      description of the fix that I used:
      
      1) replace the following line in http.tcl:
      
              set conStat [catch {eval $defcmd $async {$phost 
      $pport}} s]
      
      with:
      
              if {[string equal -nocase $proto "https"] \
                      && [string match "*tls::socket" $defcmd]} {
                  # Use "connect" to initiate https connection via 
      web proxy. 
                  set conStat [catch {SecureProxyConnect 
      $phost $pport $host $port} s]
              } else {
                  set conStat [catch {eval $defcmd $async 
      {$phost $pport}} s]
              }
      
      2) Add the SecureProxyConnect procedure:
      
      # Internal procedure to initiate https connection via 
      proxy server.
      proc http::SecureProxyConnect {proxyserver proxyport 
      webserver webserverport} {
           set sock [socket $proxyserver $proxyport]
           fconfigure $sock -blocking 0 -buffering line -
      translation crlf
      
           puts $sock "CONNECT $webserver:$webserverport 
      HTTP/1.1"
           puts $sock "Host: $webserver"
           puts $sock "User-Agent: [http::config -useragent]"
           puts $sock "Proxy-Connection: keep-alive"
           puts $sock "Connection: keep-alive"
           puts $sock ""
      
           fileevent $sock readable {set proxy_readable ""}
           global proxy_readable
           vwait proxy_readable
           fileevent $sock readable {}
      
           set block [read $sock]
           set result [lindex [split $block \n] 0]
           set code [lindex [split $result { }] 1]
           fconfigure $sock -blocking 1 -translation binary -
      buffering none
      
           if {$code >= 200 && $code < 300} {
               tls::import $sock
           } else {
               error "proxy connect failed: $block"
           }
           return $sock
      }
      
      
    4. foundin initialized to: "obsolete: 8.3.4"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "melissachawla"
    9. subsystem initialized to: "29. http Package"
    10. title initialized to:
      geturl fails on https requests if a proxy server is used
      
    11. type initialized to: "Bug"
  2. Ticket change [602af6169f] (rid 115948) by dkf on 2009-12-13 01:52:31:

    1. assignee changed to: "patthoyts"
  3. Ticket change [2e2db1be48] (rid 206050) by kjnash on 2022-10-26 12:56:58:

    1. closedate changed to: "2459879.03956938"
    2. closer changed to: "kjnash"
    3. comment changed to:
      Package require http
      I tried to use http::geturl on an https url with a proxy 
      server, and I kept getting timeouts (or ran forever when 
      no timeout was specified).
      
      package require http
      package require tls
      http::config -proxyhost <my-squid-host> -proxyport <my-
      squid-port> 
      http::register https 443 ::tls::socket http::geturl 
      https://<server>:443/<path> -timeout 30000
      
      Currently, the http package will use a GET request via 
      HTTPS to a web server outside my firewall via a web 
      proxy server inside my firewall.  I am sure that the web
      proxy server works because I can use it to make the 
      same request through my browser.  The problem is that 
      http package needs to make a "CONNECT" request to 
      the proxy before making the GET request.  I believe that 
      http version 2.4 is affected in the same way.  Here's a 
      description of the fix that I used:
      
      1) replace the following line in http.tcl:
      
              set conStat [catch {eval $defcmd $async {$phost 
      $pport}} s]
      
      with:
      
              if {[string equal -nocase $proto "https"] \
                      && [string match "*tls::socket" $defcmd]} {
                  # Use "connect" to initiate https connection via 
      web proxy. 
                  set conStat [catch {SecureProxyConnect 
      $phost $pport $host $port} s]
              } else {
                  set conStat [catch {eval $defcmd $async 
      {$phost $pport}} s]
              }
      
      2) Add the SecureProxyConnect procedure:
      
      # Internal procedure to initiate https connection via 
      proxy server.
      proc http::SecureProxyConnect {proxyserver proxyport 
      webserver webserverport} {
           set sock [socket $proxyserver $proxyport]
           fconfigure $sock -blocking 0 -buffering line -
      translation crlf
      
           puts $sock "CONNECT $webserver:$webserverport 
      HTTP/1.1"
           puts $sock "Host: $webserver"
           puts $sock "User-Agent: [http::config -useragent]"
           puts $sock "Proxy-Connection: keep-alive"
           puts $sock "Connection: keep-alive"
           puts $sock ""
      
           fileevent $sock readable {set proxy_readable ""}
           global proxy_readable
           vwait proxy_readable
           fileevent $sock readable {}
      
           set block [read $sock]
           set result [lindex [split $block \n] 0]
           set code [lindex [split $result { }] 1]
           fconfigure $sock -blocking 1 -translation binary -
      buffering none
      
           if {$code >= 200 && $code < 300} {
               tls::import $sock
           } else {
               error "proxy connect failed: $block"
           }
           return $sock
      }
      
    4. icomment:
      This is now fixed in Tcl 8.7, fossil branch core-8-branch, commit [f0cf5f7866].  The fix is based on the changes proposed above, plus proxy authentication as used in (Tcllib) autoproxy, and handling of proxy errors by returning the proxy's HTTP response.
      
    5. login: "kjnash"
    6. mimetype: "text/x-fossil-plain"
    7. resolution changed to: "Fixed"
    8. severity changed to: "Minor"
    9. status changed to: "Closed"