more attempts at chunked opkg

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@274 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-07-15 23:20:57 +00:00
parent 64b73ee14b
commit b2f5f2c48a
2 changed files with 17 additions and 8 deletions

View File

@ -4,19 +4,18 @@ package require cgi
source /mod/var/mongoose/lib/setup
require pkg.class chunked
puts "Content-Type: text/html"
puts "Transfer-Encoding: chunked"
puts ""
cgi_input
#cgi_dump
set cmd [cgi_get cmd update]
start_chunked
set bcmd "|/mod/var/mongoose/lib/opkg $cmd"
set fd [open $bcmd r]
while {[gets $fd line] >= 0} {
chunk "$line\r\n"
#chunk_pad
}
close $fd
@ -26,6 +25,5 @@ if {$cmd eq "update"} {
chunk "Done.\r\n"
}
chunk ""
puts "\r\n"
end_chunked

View File

@ -5,6 +5,17 @@ proc chunk {chk} {
flush stdout
}
# Kick the browser into life...
chunk [string range [format "%301d" 0] 1 end-1]
proc chunk_pad {{len 256}} {
incr len
chunk [string range [format "%${len}d" 0] 1 end-1]
}
proc start_chunked {{type "text/html"}} {
puts -nonewline "Content-Type: $type\r\n"
puts -nonewline "Transfer-Encoding: chunked\r\n\r\n"
}
proc end_chunked {} {
puts -nonewline "0\r\n\r\n\r\n"
}