Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  streaming content from a process

Guest
Posted: Mon Sep 21, 2009 10:13 pm Reply with quote
Guest
Inspired by some Comet-related messages I've seen here lately, I added a feature to Yaws over the weekend that allows you to stream content from an application process. This is somewhat different from the current streaming capabilities, where delivery is always HTTP chunked mode transfer. With the new capability, you can do either direct writes to the socket of non-chunked data or still send chunked data, as you wish.

If you return {streamcontent_from_pid, MimeType, Pid} from your out/1 function, it tells yaws that process Pid wants to write to the client socket. Yaws does some housekeeping and then sends a message to Pid, either {ok, YawsPid} to inform it that it can start delivering data, or {discard, YawsPid} to tell it that it should not send any data (for example, if the request was a HEAD request, there's no response body needed). From then Pid can call yaws_api:stream_process_deliver(Socket, IoList) to send data to the socket for non-chunked delivery, which basically just calls gen_tcp:send, or it can call yaws_api:stream_process_deliver_chunk(Socket, IoList) for chunked transfer, and yaws will do all the HTTP chunk formatting. If performing chunked transfer, Pid has to call

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum