1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<tt>
<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><br>
<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:[email protected]" target="_blank">[email protected]</a>></span><br><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>
<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>
<br><br>
On 09/20/2013 08:54 PM, akonsu wrote:<br><br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
thanks!<br><br>
<br><br>
how to implement timeout callback manually? if I had receive then I<br><br>
would just use timeout clause there, but with the handler I do not know...<br><br>
<br><br>
I have doubts about validity of my question on the erlang list. I later<br><br>
realised that there is no problem receiving messages in my handler from<br><br>
my upstream process, I can do it fast enough and shove everything to the<br><br>
response. my real problem is to determine if the http client is reading<br><br>
fast enough from the response...<br><br>
<br><br>
<br></div><br>
2013/9/20 Loïc Hoguin <<a href="mailto:[email protected]" target="_blank">[email protected]</a> <mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>>><div class="im"><br><br>
<br><br>
Loop handlers close after a while regardless of what you send, it<br><br>
only checks what the client sends. The best way for you would be to<br><br>
disable that timeout and handle it manually.<br><br>
<br><br>
As for the second question, I'm still reading the thread on<br><br>
erlang-questions but I've seen some good ideas about timestamps so far.<br><br>
<br><br>
<br><br>
On 09/20/2013 08:47 PM, akonsu wrote:<br><br>
<br><br>
Hi,<br><br>
<br><br>
I am using loop handler and I stream from it:<br><br>
<br><br>
info({stream, Part}, Req, S) -><br><br>
ok = cowboy_req:chunk(Part, Req),<br><br>
{loop, Req, S, hibernate};<br><br>
<br><br>
I have two questions:<br><br>
<br><br>
1. on timeouts cowboy sends 204 No Content. In my case it is not the<br><br>
right response because I may have already sent some data. Is<br><br>
there a way<br><br>
to send a custom response?<br><br>
<br><br>
2. how to check if the client is too slow and is not reading the<br><br>
response stream fast enough? If this happens, then I need to<br><br>
disconnect.<br><br>
<br><br>
I can live without 1. but I need to figure out 2. Please help.<br><br>
<br><br>
thank you!<br><br>
Konstantin<br><br>
<br><br>
<br><br>
<br></div><br>
______________________________<u></u>___________________<br><br>
Extend mailing list<br><br>
<a href="mailto:[email protected]" target="_blank">[email protected]</a> <mailto:<a href="mailto:[email protected]" target="_blank">Extend@lists.<u></u>ninenines.eu</a>><br><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><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><br>
<br><br>
--<br><br>
Loďc Hoguin<br><br>
Erlang Cowboy<br><br>
Nine Nines<br><br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br><br>
<br><br>
<br><br>
</div></blockquote><span class="HOEnZb"><font color="#888888"><br>
<br><br>
<br><br>
-- <br><br>
Loïc Hoguin</font></span><div class="HOEnZb"><div class="h5"><br><br>
Erlang Cowboy<br><br>
Nine Nines<br><br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br><br>
</div></div></blockquote></div><br></div><br>
</tt>
|