http server push
Igor Wojnicki <[email protected]> Fri, 11 Apr 2014 11:50:07 +0200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | KIS, AGH |
| Message-ID | <[email protected]> |
Hello,
I'm trying to implement a server push based communication: a http
connection remains open as long as possible while the client generates
content gradually.
I ran into some buffering issues. Here is a toy example:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- http_handler(root(longpoll), longpoll, [time_limit(5)]).
longpoll(Request) :-
format('Content-type: text/plain~n~n'),
format('testing~n'),
sleep(2),
format('testing~n').
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expected behavior upon connecting tho /longpoll resource is:
testing
... 2 seconds later
testing
but instead of the above I'm getting:
... 2 seconds delay
testing
testing
Using flush_output/0, ttyflush/0 does not help.
I guess that it has something to do with server-side buffering mentioned
in sect. 3.1 of the http module documentation
(http://www.swi-prolog.org/pldoc/package/http.html) saying that:
"The goal is called with the parsed request (see section 3.11) as
argument and current_output set to a temporary buffer."
However I couldn't find any way to flush this "temporary buffer" -
assuming that it would help.
Any suggestions?
--
Igor Wojnicki