<div dir="ltr">Understand about chunks being synchronous. that helps me tremendously to understand how it works.<div><br></div><div>would you give me a sketchy example of how to use send_after in a loop handler? (sorry I am new to erlang)</div>
<div><br></div><div>Konstantin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/20 Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">chunk only returns when the client has received the chunk, so the timestamps solution should work.<br>
<br>
As for the timeout, you can simply use erlang:send_after or something like usual and the message will arrive in info/3.<div class="im"><br>
<br>
On 09/20/2013 08:54 PM, akonsu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
thanks!<br>
<br>
how to implement timeout callback manually? if I had receive then I<br>
would just use timeout clause there, but with the handler I do not know...<br>
<br>
I have doubts about validity of my question on the erlang list.  I later<br>
realised that there is no problem receiving messages in my handler from<br>
my upstream process, I can do it fast enough and shove everything to the<br>
response. my real problem is to determine if the http client is reading<br>
fast enough from the response...<br>
<br>
<br></div>
2013/9/20 Loïc Hoguin <<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a> <mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>>><div class="im"><br>
<br>
    Loop handlers close after a while regardless of what you send, it<br>
    only checks what the client sends. The best way for you would be to<br>
    disable that timeout and handle it manually.<br>
<br>
    As for the second question, I'm still reading the thread on<br>
    erlang-questions but I've seen some good ideas about timestamps so far.<br>
<br>
<br>
    On 09/20/2013 08:47 PM, akonsu wrote:<br>
<br>
        Hi,<br>
<br>
        I am using loop handler and I stream from it:<br>
<br>
        info({stream, Part}, Req, S) -><br>
              ok = cowboy_req:chunk(Part, Req),<br>
              {loop, Req, S, hibernate};<br>
<br>
        I have two questions:<br>
<br>
        1. on timeouts cowboy sends 204 No Content. In my case it is not the<br>
        right response because I may have already sent some data. Is<br>
        there a way<br>
        to send a custom response?<br>
<br>
        2. how to check if the client is too slow and is not reading the<br>
        response stream fast enough? If this happens, then I need to<br>
        disconnect.<br>
<br>
        I can live without 1. but I need to figure out 2. Please help.<br>
<br>
        thank you!<br>
        Konstantin<br>
<br>
<br>
<br></div>
        ______________________________<u></u>___________________<br>
        Extend mailing list<br>
        <a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a> <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.<u></u>ninenines.eu</a>><br>
        <a href="http://lists.ninenines.eu:81/__listinfo/extend" target="_blank">http://lists.ninenines.eu:81/_<u></u>_listinfo/extend</a><div class="im"><br>
        <<a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/<u></u>listinfo/extend</a>><br>
<br>
<br>
<br>
    --<br>
    Loďc Hoguin<br>
    Erlang Cowboy<br>
    Nine Nines<br>
    <a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br>
<br>
<br>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Loïc Hoguin</font></span><div class="HOEnZb"><div class="h5"><br>
Erlang Cowboy<br>
Nine Nines<br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br>
</div></div></blockquote></div><br></div>