Tcl Source Code

Artifact [5dcaa6a76f]
Login

Artifact 5dcaa6a76fc00d4a364e17e8460607ef1f626199:

Attachment "3391977.patch" to ticket [3391977fff] added by dkf 2011-08-31 19:25:40.
Index: library/http/http.tcl
===================================================================
--- library/http/http.tcl
+++ library/http/http.tcl
@@ -672,10 +672,11 @@
         }
         if {[info exists phost] && ($phost ne "") && $state(-keepalive)} {
 	    puts $sock "Proxy-Connection: Keep-Alive"
         }
         set accept_encoding_seen 0
+	set content_type_done 0
 	foreach {key value} $state(-headers) {
 	    if {[string equal -nocase $key "host"]} {
 		continue
 	    }
 	    if {[string equal -nocase $key "accept-encoding"]} {
@@ -684,10 +685,13 @@
 	    set value [string map [list \n "" \r ""] $value]
 	    set key [string trim $key]
 	    if {[string equal -nocase $key "content-length"]} {
 		set contDone 1
 		set state(querylength) $value
+	    }
+	    if {[string equal -nocase $key "content-type"]} {
+		set content_type_done 1
 	    }
 	    if {[string length $key]} {
 		puts $sock "$key: $value"
 	    }
 	}
@@ -727,11 +731,13 @@
 	# the same, and none behave all that well in any case. Servers should
 	# always read their POST data if they expect the client to read their
 	# response.
 
 	if {$isQuery || $isQueryChannel} {
-	    puts $sock "Content-Type: $state(-type)"
+	    if {!$content_type_done} {
+		puts $sock "Content-Type: $state(-type)"
+	    }
 	    if {!$contDone} {
 		puts $sock "Content-Length: $state(querylength)"
 	    }
 	    puts $sock ""
 	    fconfigure $sock -translation {auto binary}