diff options
author | kjnash <k.j.nash@usa.net> | 2018-03-27 08:08:19 (GMT) |
---|---|---|
committer | kjnash <k.j.nash@usa.net> | 2018-03-27 08:08:19 (GMT) |
commit | 97721e9675b4ddd37cd3d9a8ad151961e778fee3 (patch) | |
tree | 1b61a02362369f3423f8611eea87c2df3654e2f2 /library | |
parent | d88d33f74d687fe01610c0d278a4ce228898c7f5 (diff) | |
download | tcl-97721e9675b4ddd37cd3d9a8ad151961e778fee3.zip tcl-97721e9675b4ddd37cd3d9a8ad151961e778fee3.tar.gz tcl-97721e9675b4ddd37cd3d9a8ad151961e778fee3.tar.bz2 |
Add parentheses to some "if" tests; transform one test without changing its outcome.
Diffstat (limited to 'library')
-rw-r--r-- | library/http/http.tcl | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl index db3c044..16e0c19 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -209,7 +209,7 @@ proc http::Finish {token {errormsg ""} {skipCB 0}} { set state(error) [list $errormsg $errorInfo $errorCode] set state(status) "error" } - if { ($state(status) eq "timeout") + if { ($state(status) eq "timeout") || ($state(status) eq "error") || ([info exists state(-keepalive)] && !$state(-keepalive)) || ([info exists state(connection)] && ($state(connection) eq "close")) @@ -219,8 +219,8 @@ proc http::Finish {token {errormsg ""} {skipCB 0}} { if {[info exists state(after)]} { after cancel $state(after) } - if {[info exists state(-command)] && !$skipCB - && ![info exists state(done-command-cb)]} { + if {[info exists state(-command)] && (!$skipCB) + && (![info exists state(done-command-cb)])} { set state(done-command-cb) yes if {[catch {eval $state(-command) {$token}} err] && $errormsg eq ""} { set state(error) [list $err $errorInfo $errorCode] @@ -715,7 +715,7 @@ proc http::Connected {token proto phost srvurl} { fconfigure $state(-querychannel) -blocking 1 -translation binary set contDone 0 } - if {[info exists state(-method)] && $state(-method) ne ""} { + if {[info exists state(-method)] && ($state(-method) ne "")} { set how $state(-method) } # We cannot handle chunked encodings with -handler, so force HTTP/1.0 @@ -737,10 +737,10 @@ proc http::Connected {token proto phost srvurl} { puts $sock "Host: $host:$port" } puts $sock "User-Agent: $http(-useragent)" - if {$state(-protocol) == 1.0 && $state(-keepalive)} { + if {($state(-protocol) == 1.0) && $state(-keepalive)} { puts $sock "Connection: keep-alive" } - if {$state(-protocol) > 1.0 && !$state(-keepalive)} { + if {($state(-protocol) > 1.0) && !$state(-keepalive)} { puts $sock "Connection: close" ;# RFC2616 sec 8.1.2.1 } if {[info exists phost] && ($phost ne "") && $state(-keepalive)} { @@ -779,7 +779,7 @@ proc http::Connected {token proto phost srvurl} { if {!$accept_encoding_seen && ![info exists state(-handler)]} { puts $sock "Accept-Encoding: gzip,deflate,compress" } - if {$isQueryChannel && $state(querylength) == 0} { + if {$isQueryChannel && ($state(querylength) == 0)} { # Try to determine size of data in channel. If we cannot seek, the # surrounding catch will trap us @@ -1050,15 +1050,26 @@ proc http::Event {sock token} { return } - # For non-chunked transfer we may have no body - in this case we - # may get no further file event if the connection doesn't close - # and no more data is sent. We can tell and must finish up now - - # not later. - if { - !(([info exists state(connection)] - && ($state(connection) eq "close")) - || [info exists state(transfer)]) - && ($state(totalsize) == 0) + # - For non-chunked transfer we may have no body - in this case we + # may get no further file event if the connection doesn't close + # and no more data is sent. We can tell and must finish up now - + # not later - the alternative would be to wait until the server + # times out. + # - In this case, the server has NOT told the client it will close + # the connection, AND it has NOT indicated the resource length + # EITHER by setting the Content-Length (totalsize) OR by using + # chunked Transer-Encoding. + # - Do not worry here about the case (Connection: close) because + # the server should close the connection. + # - IF (NOT Connection: close) AND (NOT chunked encoding) AND + # (totalsize == 0). + + if { (!( [info exists state(connection)] + && ($state(connection) eq "close") + ) + ) + && (![info exists state(transfer)]) + && ($state(totalsize) == 0) } { Log "body size is 0 and no events likely - complete." Eof $token |