diff options
author | kjnash <k.j.nash@usa.net> | 2020-08-11 18:30:03 (GMT) |
---|---|---|
committer | kjnash <k.j.nash@usa.net> | 2020-08-11 18:30:03 (GMT) |
commit | 4b9763f5f70210ad03fefd51d9f7b388309afcae (patch) | |
tree | 3e464d6e98a0f29922a2caadad0ced85b428414a /library/http/http.tcl | |
parent | 0e59966ac59400d43816bc360c74e5b9dfb49493 (diff) | |
parent | c07c2bb91ccfa02ec939148c02317d2e2978a4c2 (diff) | |
download | tcl-4b9763f5f70210ad03fefd51d9f7b388309afcae.zip tcl-4b9763f5f70210ad03fefd51d9f7b388309afcae.tar.gz tcl-4b9763f5f70210ad03fefd51d9f7b388309afcae.tar.bz2 |
Merge 8.6
Diffstat (limited to 'library/http/http.tcl')
-rw-r--r-- | library/http/http.tcl | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl index a93e67b..f9ec8ca 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -11,7 +11,7 @@ package require Tcl 8.6- # Keep this in sync with pkgIndex.tcl and with the install directories in # Makefiles -package provide http 2.9.2 +package provide http 2.9.3 namespace eval http { # Allow resourcing to not clobber existing data @@ -721,7 +721,7 @@ proc http::geturl {url args} { body {} status "" http "" - connection close + connection keep-alive } set state(-keepalive) $defaultKeepalive set state(-strict) $strict @@ -1037,7 +1037,7 @@ proc http::geturl {url args} { } # Do not automatically close the connection socket. - set state(connection) {} + set state(connection) keep-alive } } @@ -2688,8 +2688,31 @@ proc http::Event {sock token} { } proxy-connection - connection { - set state(connection) \ - [string trim [string tolower $value]] + set tmpHeader [string trim [string tolower $value]] + # RFC 7230 Section 6.1 states that a comma-separated + # list is an acceptable value. According to + # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection + # any comma-separated list implies keep-alive, but I + # don't see this in the RFC so we'll play safe and + # scan any list for "close". + if {$tmpHeader in {close keep-alive}} { + # The common cases, continue. + } elseif {[string first , $tmpHeader] == -1} { + # Not a comma-separated list, not "close", + # therefore "keep-alive". + set tmpHeader keep-alive + } else { + set tmpHeader keep-alive + set tmpCsl [split $tmpHeader ,] + # Optional whitespace either side of separator. + foreach el $tmpCsl { + if {[string trim $el] eq {close}} { + set tmpHeader close + break + } + } + } + set state(connection) $tmpHeader } } lappend state(meta) $key [string trim $value] |