Index: openacs-4/packages/xotcl-core/tcl/message-relay-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/Attic/message-relay-procs.tcl,v diff -u -r1.1.2.7 -r1.1.2.8 --- openacs-4/packages/xotcl-core/tcl/message-relay-procs.tcl 12 Sep 2022 13:15:09 -0000 1.1.2.7 +++ openacs-4/packages/xotcl-core/tcl/message-relay-procs.tcl 26 Jan 2024 13:14:50 -0000 1.1.2.8 @@ -56,21 +56,28 @@ # Compose reply header. # if {$mode eq "scripted"} { + # + # Scripted streaming relies on an infinitely long request, + # providing chunks of javascript code conveying the + # message. Widely supported e.g. also by Internet Explorer, + # but not recommended on modern browsers. + # set content_type "text/html;charset=utf-8" set encoding "Cache-Control: no-cache\r\nTransfer-Encoding: chunked\r\n" set body "[string repeat { } 1024]\r\n" set body [format %x [string length $body]]\r\n$body\r\n + return "HTTP/1.1 200 OK\r\nContent-type: $content_type\r\n$encoding\r\n$body" } else { # - # Chrome refuses to expose partial response to ajax unless we - # set content_type to octet stream. Drawback is we have to - # force the translation on the channel. + # Other modes will use Server Sent Events. # - set content_type "application/octet-stream" - set encoding "" - set body "" + return [append _ \ + "HTTP/1.1 200 OK\r\n" \ + "Cache-Control: no-cache\r\n" \ + "X-Accel-Buffering': no\r\n" \ + "Content-type: text/event-stream\r\n" \ + "\r\n"] } - return "HTTP/1.1 200 OK\r\nContent-type: $content_type\r\n$encoding\r\n$body" } :public method encode_message {mode msg} { @@ -92,6 +99,8 @@ }] set msg [format %x [string length $jsMsg]]\r\n$jsMsg\r\n + } else { + set msg [string cat {data: } $msg \n\n] } #ns_log notice "#### [self] encode_message <$mode> returns <$msg>" return $msg