summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-09-29 16:21:53 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-09-29 16:21:53 (GMT)
commit98a93d4ca72e9eb4dc7d6c33e9f75f2449cb01cf (patch)
treebc401be93afa1ba42e80d7b03237bbb6edc59bc0
parent2342babe990ebbf9e046143ce965996fc5701abc (diff)
parentaccd2800ecceb527ff9315ec011511b30f32a980 (diff)
downloadtcl-98a93d4ca72e9eb4dc7d6c33e9f75f2449cb01cf.zip
tcl-98a93d4ca72e9eb4dc7d6c33e9f75f2449cb01cf.tar.gz
tcl-98a93d4ca72e9eb4dc7d6c33e9f75f2449cb01cf.tar.bz2
Ticket [0063cbcada]: check http::geturl -headers parameter to be a dict
-rw-r--r--library/http/http.tcl6
-rw-r--r--tests/http.test3
2 files changed, 7 insertions, 2 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index eec05b8..2dfcb8b 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -746,6 +746,7 @@ proc http::geturl {url args} {
-strict boolean
-timeout integer
-validate boolean
+ -headers list
}
set state(charset) $defaultCharset
set options {
@@ -760,8 +761,9 @@ proc http::geturl {url args} {
if {[regexp -- $pat $flag]} {
# Validate numbers
if {
- [info exists type($flag)] &&
- ![string is $type($flag) -strict $value]
+ ([info exists type($flag)] &&
+ ![string is $type($flag) -strict $value]) ||
+ $flag eq "-headers" && [llength $value] %2 != 0
} {
unset $token
return -code error \
diff --git a/tests/http.test b/tests/http.test
index 7454ab8..b83ddef 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -444,6 +444,9 @@ test http-3.33 {http::geturl application/xml is text} -body {
} -cleanup {
catch { http::cleanup $token }
} -result {test 4660 /test}
+test http-3.34 {http::geturl -headers not a dict} -returnCodes error -body {
+ http::geturl http://test/t -headers NoDict
+} -result {Bad value for -headers (NoDict), must be list}
test http-4.1 {http::Event} -body {
set token [http::geturl $url -keepalive 0]