summaryrefslogtreecommitdiffstats
path: root/library/http
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2011-09-16 08:34:20 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2011-09-16 08:34:20 (GMT)
commit9ca1f111a0ee7859fdec16b4f4d2f7fcf3530c35 (patch)
tree4b0ff5bd3951d7c8c1e8f87111de77ff825d1cf3 /library/http
parentef09f86d39a751b46143aa33f2ee808b31a6a984 (diff)
parentb70ab023a4e2ec3bfb8ebccf59b92519d5a5dbba (diff)
downloadtcl-9ca1f111a0ee7859fdec16b4f4d2f7fcf3530c35.zip
tcl-9ca1f111a0ee7859fdec16b4f4d2f7fcf3530c35.tar.gz
tcl-9ca1f111a0ee7859fdec16b4f4d2f7fcf3530c35.tar.bz2
[Bug 3391977]: Ensure that the -headers option to http::geturl overrides the
-type option (important because -type has a default that is not always appropriate, and the header must not be duplicated).
Diffstat (limited to 'library/http')
-rw-r--r--library/http/http.tcl8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index c636458..69817b8 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -684,6 +684,7 @@ proc http::geturl {url args} {
puts $sock "Proxy-Connection: Keep-Alive"
}
set accept_encoding_seen 0
+ set content_type_seen 0
foreach {key value} $state(-headers) {
if {[string equal -nocase $key "host"]} {
continue
@@ -691,6 +692,9 @@ proc http::geturl {url args} {
if {[string equal -nocase $key "accept-encoding"]} {
set accept_encoding_seen 1
}
+ if {[string equal -nocase $key "content-type"]} {
+ set content_type_seen 1
+ }
set value [string map [list \n "" \r ""] $value]
set key [string trim $key]
if {[string equal -nocase $key "content-length"]} {
@@ -733,7 +737,9 @@ proc http::geturl {url args} {
# response.
if {$isQuery || $isQueryChannel} {
- puts $sock "Content-Type: $state(-type)"
+ if {!$content_type_seen} {
+ puts $sock "Content-Type: $state(-type)"
+ }
if {!$contDone} {
puts $sock "Content-Length: $state(querylength)"
}