Index: library/lib/nx-zip.tcl =================================================================== diff -u -r4f198095ea7d80ad414afda27850187f50716a49 -rd82ed6ca68ae65ca7864ed6c6770d1de974b023e --- library/lib/nx-zip.tcl (.../nx-zip.tcl) (revision 4f198095ea7d80ad414afda27850187f50716a49) +++ library/lib/nx-zip.tcl (.../nx-zip.tcl) (revision d82ed6ca68ae65ca7864ed6c6770d1de974b023e) @@ -80,12 +80,28 @@ "HTTP/1.0 200 OK\r\nContent-type: application/zip\r\n" \ "Content-Disposition: attachment;filename=\"$zipFileName\"\r\n" \ "\r\n" - - if {[info commands ns_connchan] != "" } { + # + # Check, if we have "ns_connchan status". If so, use ns_connchan + # to write to the client. This has the advantage that we can use + # the buffered "connchan write" method capable of handling + # partial writes also for HTTPS. + # + if {[info commands ::ns_connchan] ne "" + && [info commands ::acs::cmd_has_subcommand] ne "" + && [::acs::cmd_has_subcommand ns_connchan status]} { set channel [ns_connchan detach] - set :writer [list ns_connchan write $channel] - ns_connchan write $channel $header + set :writer [list ns_connchan write -buffered $channel] + ns_connchan write -buffered $channel $header :writeToStream $channel + while {1} { + set status [ns_connchan status $channel] + if {[dict get $status sendbuffer] > 0} { + ns_connchan write -buffered $channel "" + ns_sleep 1ms + } else { + break + } + } ns_connchan close $channel } else { ns_write $header