Stream HTTP response
"Mark Kornfilt" <[email protected]> Tue, 14 Aug 2007 18:09:40 -0400
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_74598_7300691.1187129380245
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I am trying to stream an HTTP response.
The code appended at the end of this mail is an example of what I am trying
to do. It should write to the socket every second. Instead of that, it seems
to buffer the response and write only when it has the entire content.
Can anybody help on this?
Thanks,
Mark
#!/usr/local/bin/eruby
<%
require 'socket'
require 'net/http'
require 'cgi'
cgi = CGI.new
cgi.header("type" => "text/html")
begin
for index in (1 .. 10)
cgi.print(index.to_s + ":" + Time.new.to_s + "<br/>")
sleep(1)
end
rescue StandardError => error
print "Error running script: " + error
end
%>
------=_Part_74598_7300691.1187129380245
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi, <br><br>I am trying to stream an HTTP response.<br><br>The code appended at the end of this mail is an example of what I am trying to do. It should write to the socket every second. Instead of that, it seems to buffer the response and write only when it has the entire content.
<br><br>Can anybody help on this?<br><br>Thanks,<br><br>Mark<br><br><br>#!/usr/local/bin/eruby<br><%<br>require 'socket'<br>require 'net/http'<br>require 'cgi'<br><br>cgi = CGI.new<br><br>cgi.header
("type" => "text/html")<br><br>begin<br>for index in (1 .. 10)<br> cgi.print(index.to_s + ":" + Time.new.to_s + "<br/>")<br> sleep(1)<br>end<br>rescue StandardError => error
<br> print "Error running script: " + error<br>end<br>%>
------=_Part_74598_7300691.1187129380245--