Paste: chunked.cgi
| Author: | Serre |
| Mode: | factor |
| Date: | Fri, 6 Mar 2026 11:24:33 |
Plain Text |
#!/usr/bin/env factor-vm
USING: assocs calendar environment formatting io
io.encodings.string io.encodings.utf8 kernel literals math
math.parser prettyprint sequences threads vocabs ;
IN: chunked-cgi
: send-chunk ( string -- )
[ utf8 encode length >hex print ] keep print flush ;
: tick-loop ( n -- )
[ "This page will self-destruct in %.1f seconds.<br/>"
sprintf send-chunk ]
[ 0.5 dup seconds sleep - ] bi
[ 0 <= ] 1check [ drop ] [ tick-loop ] if ;
"Content-type: text/html; charset=utf8" print
"Transfer-Encoding: chunked\r\n" print
8 tick-loop "*Ka-Boom*" send-chunk "0\r\n" print
| Author: | Serre |
| Mode: | factor |
| Date: | Fri, 6 Mar 2026 12:31:38 |
Plain Text |
: tick-loop ( n -- )
0 swap 0.5 <range> [ reverse ] keep zip
[ first2 seconds sleep
"This page will self-destruct in %.1f seconds.<br/>"
sprintf send-chunk ]
parallel-each ;
| Author: | Serre |
| Mode: | factor |
| Date: | Fri, 6 Mar 2026 12:47:38 |
Plain Text |
: tick-loop ( n -- )
0 swap 0.5 [ <range> reverse ] keep
[ seconds sleep "This page will self-destruct in
%.1f seconds.<br/>" sprintf send-chunk ] curry each ;
New Annotation