summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-09-29 08:15:32 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-09-29 08:15:32 (GMT)
commit43e27f10a51ad6b206f06c50ea0cd4653bba694a (patch)
tree0b0cdf09f3f9ef51aa78d2bd02005b7e2d5fde0b
parent38b30033c88080b592fdbc043f295bc9b4e97b5d (diff)
downloadtcl-43e27f10a51ad6b206f06c50ea0cd4653bba694a.zip
tcl-43e27f10a51ad6b206f06c50ea0cd4653bba694a.tar.gz
tcl-43e27f10a51ad6b206f06c50ea0cd4653bba694a.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.test6
2 files changed, 10 insertions, 2 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index cce1828..abef596 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -733,6 +733,7 @@ proc http::geturl {url args} {
-strict boolean
-timeout integer
-validate boolean
+ -headers list
}
set state(charset) $defaultCharset
set options {
@@ -747,8 +748,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 636a651..bd776c6 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -448,6 +448,12 @@ 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-3.2 {http::geturl} -returnCodes error -body {
+ http::geturl http:junk
+} -result {Unsupported URL: http:junk}
test http-4.1 {http::Event} -body {
set token [http::geturl $url -keepalive 0]