summaryrefslogtreecommitdiffstats
path: root/tests/http11.test
diff options
context:
space:
mode:
authorkjnash <k.j.nash@usa.net>2020-08-12 09:20:56 (GMT)
committerkjnash <k.j.nash@usa.net>2020-08-12 09:20:56 (GMT)
commitcc21b0be2ad2d9c16af8d9dbdf188110479ebfc7 (patch)
treeef18a0690d6a018f36620dab6a525741fb5b6377 /tests/http11.test
parentdddf36c195fb2a2339ff504255797b1a9f77bb0e (diff)
downloadtcl-cc21b0be2ad2d9c16af8d9dbdf188110479ebfc7.zip
tcl-cc21b0be2ad2d9c16af8d9dbdf188110479ebfc7.tar.gz
tcl-cc21b0be2ad2d9c16af8d9dbdf188110479ebfc7.tar.bz2
Bugfixes to the earlier fix of bug cb0373bb33, which broke HTTP/1.0 transactions in which the server indicates neither a Content-Length nor that it will close the socket on completion ("Connection: close"). The HTTP/1.1 rule is that the response header "Connection", if absent, must default to "keep-alive"; but this rule does not apply to HTTP/1.0. Add test http11-3.4 and bump version to 2.9.4.
Diffstat (limited to 'tests/http11.test')
-rw-r--r--tests/http11.test27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/http11.test b/tests/http11.test
index 762788e..240bfef 100644
--- a/tests/http11.test
+++ b/tests/http11.test
@@ -626,6 +626,33 @@ test http11-3.3 "-handler,keepalive,chunked" -setup {
halt_httpd
} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0}
+# http11-3.4
+# This test is a blatant attempt to confuse the client by instructing the server
+# to send neither "Connection: close" nor "Content-Length" when in non-chunked
+# mode.
+# The client has no way to know the response-body is complete unless the
+# server signals this by closing the connection.
+# In an HTTP/1.1 response the absence of "Connection: close" means
+# "Connection: keep-alive", i.e. the server will keep the connection
+# open. In HTTP/1.0 this is not the case, and this is a test that
+# the Tcl client assumes "Connection: close" by default in HTTP/1.0.
+test http11-3.4 "-handler,close,identity; HTTP/1.0 server does not send Connection: close header or Content-Length" -setup {
+ variable httpd [create_httpd]
+ set testdata ""
+} -body {
+ set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1&nosendclose=any \
+ -timeout 10000 -handler [namespace code [list handler testdata]]]
+ http::wait $tok
+ list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\
+ [meta $tok connection] [meta $tok content-encoding] \
+ [meta $tok transfer-encoding] \
+ [expr {[file size testdoc.html]-[string length $testdata]}]
+} -cleanup {
+ http::cleanup $tok
+ unset -nocomplain testdata
+ halt_httpd
+} -result {ok {HTTP/1.0 200 OK} ok {} {} {} 0}
+
test http11-4.0 "normal post request" -setup {
variable httpd [create_httpd]
} -body {