Tcl Source Code

Artifact [d25dbf9f7b]
Login

Artifact d25dbf9f7bb06e5d9fc2a5a958cbf7cceb037c21:

Attachment "http.diff" to ticket [928154ffff] added by davidw 2004-04-02 17:34:46.
--- /home/davidw/workshop/tcl/library/http/http.tcl	2004-04-02 12:15:34.000000000 +0200
+++ http.tcl	2004-04-02 12:11:42.000000000 +0200
@@ -25,7 +25,7 @@
 package require Tcl 8.2
 # keep this in sync with pkgIndex.tcl
 # and with the install directories in Makefiles
-package provide http 2.4.4
+package provide http 2.4.5
 
 namespace eval http {
     variable http
@@ -414,15 +414,20 @@
     if {[catch {
 	puts $s "$how $srvurl HTTP/1.0"
 	puts $s "Accept: $http(-accept)"
-	if {$port == $defport} {
+	array set hdrs $state(-headers)
+	if { [info exists hdrs(Host)] } {
+	    puts $s "Host: $hdrs(Host)"
+	} elseif {$port == $defport} {
 	    # Don't add port in this case, to handle broken servers.
 	    # [Bug #504508]
 	    puts $s "Host: $host"
 	} else {
 	    puts $s "Host: $host:$port"
 	}
+	unset hdrs
 	puts $s "User-Agent: $http(-useragent)"
 	foreach {key value} $state(-headers) {
+	    if { $key == "Host" } continue
 	    set value [string map [list \n "" \r ""] $value]
 	    set key [string trim $key]
 	    if {[string equal $key "Content-Length"]} {