From b2f5f2c48ad8267b95ae76f6072b8e7158ae617c Mon Sep 17 00:00:00 2001 From: hummypkg Date: Fri, 15 Jul 2011 23:20:57 +0000 Subject: [PATCH] more attempts at chunked opkg git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@274 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/opkg.jim | 10 ++++------ var/mongoose/lib/chunked | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/var/mongoose/cgi-bin/opkg.jim b/var/mongoose/cgi-bin/opkg.jim index 0fe5a7d..366581b 100755 --- a/var/mongoose/cgi-bin/opkg.jim +++ b/var/mongoose/cgi-bin/opkg.jim @@ -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 diff --git a/var/mongoose/lib/chunked b/var/mongoose/lib/chunked index b439018..5ff5392 100755 --- a/var/mongoose/lib/chunked +++ b/var/mongoose/lib/chunked @@ -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" +}