: <i>geturl fails on https requests if a proxy server is used</i> plus 8 other changes
by
.
D 2022-10-26T12:56:58.794
J closedate 2459879.03956938
J closer kjnash
J comment Package\srequire\shttp\r\nI\stried\sto\suse\shttp::geturl\son\san\shttps\surl\swith\sa\sproxy\s\r\nserver,\sand\sI\skept\sgetting\stimeouts\s(or\sran\sforever\swhen\s\r\nno\stimeout\swas\sspecified).\r\n\r\npackage\srequire\shttp\r\npackage\srequire\stls\r\nhttp::config\s-proxyhost\s<my-squid-host>\s-proxyport\s<my-\r\nsquid-port>\s\r\nhttp::register\shttps\s443\s::tls::socket\shttp::geturl\s\r\nhttps://<server>:443/<path>\s-timeout\s30000\r\n\r\nCurrently,\sthe\shttp\spackage\swill\suse\sa\sGET\srequest\svia\s\r\nHTTPS\sto\sa\sweb\sserver\soutside\smy\sfirewall\svia\sa\sweb\s\r\nproxy\sserver\sinside\smy\sfirewall.\s\sI\sam\ssure\sthat\sthe\sweb\r\nproxy\sserver\sworks\sbecause\sI\scan\suse\sit\sto\smake\sthe\s\r\nsame\srequest\sthrough\smy\sbrowser.\s\sThe\sproblem\sis\sthat\s\r\nhttp\spackage\sneeds\sto\smake\sa\s"CONNECT"\srequest\sto\s\r\nthe\sproxy\sbefore\smaking\sthe\sGET\srequest.\s\sI\sbelieve\sthat\s\r\nhttp\sversion\s2.4\sis\saffected\sin\sthe\ssame\sway.\s\sHere's\sa\s\r\ndescription\sof\sthe\sfix\sthat\sI\sused:\r\n\r\n1)\sreplace\sthe\sfollowing\sline\sin\shttp.tcl:\r\n\r\n\s\s\s\s\s\s\s\sset\sconStat\s[catch\s{eval\s$defcmd\s$async\s{$phost\s\r\n$pport}}\ss]\r\n\r\nwith:\r\n\r\n\s\s\s\s\s\s\s\sif\s{[string\sequal\s-nocase\s$proto\s"https"]\s\\\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s&&\s[string\smatch\s"*tls::socket"\s$defcmd]}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\s#\sUse\s"connect"\sto\sinitiate\shttps\sconnection\svia\s\r\nweb\sproxy.\s\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\sconStat\s[catch\s{SecureProxyConnect\s\r\n$phost\s$pport\s$host\s$port}\ss]\r\n\s\s\s\s\s\s\s\s}\selse\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\sconStat\s[catch\s{eval\s$defcmd\s$async\s\r\n{$phost\s$pport}}\ss]\r\n\s\s\s\s\s\s\s\s}\r\n\r\n2)\sAdd\sthe\sSecureProxyConnect\sprocedure:\r\n\r\n#\sInternal\sprocedure\sto\sinitiate\shttps\sconnection\svia\s\r\nproxy\sserver.\r\nproc\shttp::SecureProxyConnect\s{proxyserver\sproxyport\s\r\nwebserver\swebserverport}\s{\r\n\s\s\s\s\sset\ssock\s[socket\s$proxyserver\s$proxyport]\r\n\s\s\s\s\sfconfigure\s$sock\s-blocking\s0\s-buffering\sline\s-\r\ntranslation\scrlf\r\n\r\n\s\s\s\s\sputs\s$sock\s"CONNECT\s$webserver:$webserverport\s\r\nHTTP/1.1"\r\n\s\s\s\s\sputs\s$sock\s"Host:\s$webserver"\r\n\s\s\s\s\sputs\s$sock\s"User-Agent:\s[http::config\s-useragent]"\r\n\s\s\s\s\sputs\s$sock\s"Proxy-Connection:\skeep-alive"\r\n\s\s\s\s\sputs\s$sock\s"Connection:\skeep-alive"\r\n\s\s\s\s\sputs\s$sock\s""\r\n\r\n\s\s\s\s\sfileevent\s$sock\sreadable\s{set\sproxy_readable\s""}\r\n\s\s\s\s\sglobal\sproxy_readable\r\n\s\s\s\s\svwait\sproxy_readable\r\n\s\s\s\s\sfileevent\s$sock\sreadable\s{}\r\n\r\n\s\s\s\s\sset\sblock\s[read\s$sock]\r\n\s\s\s\s\sset\sresult\s[lindex\s[split\s$block\s\\n]\s0]\r\n\s\s\s\s\sset\scode\s[lindex\s[split\s$result\s{\s}]\s1]\r\n\s\s\s\s\sfconfigure\s$sock\s-blocking\s1\s-translation\sbinary\s-\r\nbuffering\snone\r\n\r\n\s\s\s\s\sif\s{$code\s>=\s200\s&&\s$code\s<\s300}\s{\r\n\s\s\s\s\s\s\s\s\stls::import\s$sock\r\n\s\s\s\s\s}\selse\s{\r\n\s\s\s\s\s\s\s\s\serror\s"proxy\sconnect\sfailed:\s$block"\r\n\s\s\s\s\s}\r\n\s\s\s\s\sreturn\s$sock\r\n}
J icomment This\sis\snow\sfixed\sin\sTcl\s8.7,\sfossil\sbranch\score-8-branch,\scommit\s[f0cf5f7866].\s\sThe\sfix\sis\sbased\son\sthe\schanges\sproposed\sabove,\splus\sproxy\sauthentication\sas\sused\sin\s(Tcllib)\sautoproxy,\sand\shandling\sof\sproxy\serrors\sby\sreturning\sthe\sproxy's\sHTTP\sresponse.
J login kjnash
J mimetype text/x-fossil-plain
J resolution Fixed
J severity Minor
J status Closed
K 1173760fffffffffffffffffffffffffffffffff
U kjnash
Z f0c33d6307043f3e237d55073867acca