|
|
| Author |
Message |
|
| Guest |
Posted: Mon Sep 21, 2009 10:13 pm |
|
|
|
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 |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
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
|
|
|