Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

stream content with a timeout patch from Davide Marques

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1364 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
commit 3f6194f32292060f9da0235b1fad122f90deb711 1 parent 28d18e8
@klacke authored
View
2  c_src/yaws_sendfile_drv.c
@@ -179,6 +179,8 @@ static void yaws_sendfile_drv_output(ErlDrvData handle, char* buf, int buflen)
}
}
+
+
static void yaws_sendfile_drv_ready_output(ErlDrvData handle, ErlDrvEvent ev)
{
Desc* d = (Desc*)handle;
View
8 man/yaws_api.5
@@ -477,6 +477,14 @@ if the yaws code doesn't have access to all the data in one go. (Typically
if a file is very large or if data arrives from back end servers on the network.
.TP
+\fB{streamcontent_with_timeout, MimeType, FirstChunk, Timeout}\fR
+Similar to above, but with an explicit timeout. The deafult timeout
+is 30 secs. I.e if the application fails to deliver data to the
+Yaws process, the streaming will stop. This is often not the
+desired behaviour in Comet/Ajax applications. It's possible to
+provide 'infinity' as timeout.
+
+.TP
\fB{header, H}\fR
Accumulates a HTTP header. The trailing CRNL which is supposed
to end all HTTP headers must NOT be added. It is added by the server.
View
21 src/yaws_server.erl
@@ -2068,6 +2068,13 @@ deliver_dyn_part(CliSock, % essential params
Priv = deliver_accumulated(Arg, CliSock,
decide, undefined, stream),
stream_loop_send(Priv, CliSock);
+ % For other timeout's (other than 30 second) support
+ {streamcontent_with_timeout, MimeType, FirstChunk, TimeOut} ->
+ yaws:outh_set_content_type(MimeType),
+ accumulate_content(FirstChunk),
+ Priv = deliver_accumulated(Arg, CliSock,
+ decide, undefined, stream),
+ stream_loop_send(Priv, CliSock, TimeOut);
{streamcontent_with_size, Sz, MimeType, FirstChunk} ->
yaws:outh_set_content_type(MimeType),
accumulate_content(FirstChunk),
@@ -2148,7 +2155,9 @@ stream_loop_send(Priv, CliSock) ->
stream_loop_send(Priv, CliSock, FlushStatus) ->
TimeOut = case FlushStatus of
flushed -> 30000;
- unflushed -> 300
+ unflushed -> 300;
+ %% Other timeouts (including infinity) support
+ OtherTimeout -> OtherTimeout
end,
receive
{streamcontent, Cont} ->
@@ -2166,7 +2175,10 @@ stream_loop_send(Priv, CliSock, FlushStatus) ->
erlang:error(stream_timeout);
unflushed ->
P = sync_streamcontent(Priv, CliSock),
- stream_loop_send(P, CliSock, flushed)
+ stream_loop_send(P, CliSock, flushed);
+ % Other timeouts support
+ ElapsedTime ->
+ erlang:error({stream_timeout, ElapsedTime})
end
end.
@@ -2404,6 +2416,11 @@ handle_out_reply({streamcontent, MimeType, First},
yaws:outh_set_content_type(MimeType),
{streamcontent, MimeType, First};
+handle_out_reply({streamcontent_with_timeout, MimeType, First, Timeout},
+ _LineNo,_YawsFile, _UT, _ARG) ->
+ yaws:outh_set_content_type(MimeType),
+ {streamcontent_with_timeout, MimeType, First, Timeout};
+
handle_out_reply(Res = {page, _Page},
_LineNo,_YawsFile, _UT, _ARG) ->
Res;
Please sign in to comment.
Something went wrong with that request. Please try again.