summaryrefslogtreecommitdiffstats
path: root/library/http/http.tcl
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-10 16:38:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-10 16:38:22 (GMT)
commit0a5154ce87f664c62309803df4d7b8ab14b4721d (patch)
treed5de294b7c5c75f2536f6693c40c5b31d513d3af /library/http/http.tcl
parent8fb96674b942e844b25d3e269a5715ebea33bc02 (diff)
downloadtcl-0a5154ce87f664c62309803df4d7b8ab14b4721d.zip
tcl-0a5154ce87f664c62309803df4d7b8ab14b4721d.tar.gz
tcl-0a5154ce87f664c62309803df4d7b8ab14b4721d.tar.bz2
Now we're on it, keep better track with state(host) and state(path). Backported from http 2.10
Diffstat (limited to 'library/http/http.tcl')
-rw-r--r--library/http/http.tcl12
1 files changed, 10 insertions, 2 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 92d3a5a..e754264 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -931,8 +931,12 @@ proc http::geturl {url args} {
}
return -code error "Illegal characters in URL path"
}
+ if {![regexp {^[^?#]+} $srvurl state(path)]} {
+ set state(path) /
+ }
} else {
set srvurl /
+ set state(path) /
}
if {$proto eq ""} {
set proto http
@@ -1409,12 +1413,16 @@ proc http::Connected {token proto phost srvurl} {
puts $sock "$how $srvurl HTTP/$state(-protocol)"
if {[dict exists $state(-headers) Host]} {
# Allow Host spoofing. [Bug 928154]
- puts $sock "Host: [dict get $state(-headers) Host]"
+ set hostHdr [dict get $state(-headers) Host]
+ regexp {^[^:]+} $hostHdr state(host)
+ puts $sock "Host: $hostHdr"
} elseif {$port == $defport} {
# Don't add port in this case, to handle broken servers. [Bug
# #504508]
+ set state(host) $host
puts $sock "Host: $host"
} else {
+ set state(host) $host
puts $sock "Host: $host:$port"
}
puts $sock "User-Agent: $http(-useragent)"
@@ -3175,7 +3183,7 @@ proc http::BlockingGets {sock} {
while 1 {
set count [gets $sock line]
set eof [eof $sock]
- if {$count > -1 || $eof} {
+ if {$count >= 0 || $eof} {
return $line
} else {
yield