rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* partially send
@ 2010-07-29  7:33 DMG
  2010-07-29  8:45 ` Konstantin Haase
  0 siblings, 1 reply; 6+ messages in thread
From: DMG @ 2010-07-29  7:33 UTC (permalink / raw)
  To: Rack Development

Hi, is there any way to send response partially? In PHP you can flush
some data to the client.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: partially send
  2010-07-29  7:33 partially send DMG
@ 2010-07-29  8:45 ` Konstantin Haase
  2010-07-29  9:45   ` DMG
  2010-07-29 14:35   ` Toby Matejovsky
  0 siblings, 2 replies; 6+ messages in thread
From: Konstantin Haase @ 2010-07-29  8:45 UTC (permalink / raw)
  To: rack-devel


On Jul 29, 2010, at 09:33 , DMG wrote:

> Hi, is there any way to send response partially? In PHP you can flush
> some data to the client.

You have to return a body object, that responds to each and in there yields for every flush: http://stackoverflow.com/questions/3027435/is-there-a-way-to-flush-html-to-the-wire-in-sinatra/3028149#3028149 (that example is usable without Sinatra)

Konstantin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: partially send
  2010-07-29  8:45 ` Konstantin Haase
@ 2010-07-29  9:45   ` DMG
  2010-07-29 14:35   ` Toby Matejovsky
  1 sibling, 0 replies; 6+ messages in thread
From: DMG @ 2010-07-29  9:45 UTC (permalink / raw)
  To: Rack Development

Great, thanks :)


On Jul 29, 10:45 am, Konstantin Haase <k.ha...@finn.de> wrote:
> On Jul 29, 2010, at 09:33 , DMG wrote:
>
> > Hi, is there any way to send response partially? In PHP you can flush
> > some data to the client.
>
> You have to return a body object, that responds to each and in there yields for every flush:http://stackoverflow.com/questions/3027435/is-there-a-way-to-flush-ht...(that example is usable without Sinatra)
>
> Konstantin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: partially send
  2010-07-29  8:45 ` Konstantin Haase
  2010-07-29  9:45   ` DMG
@ 2010-07-29 14:35   ` Toby Matejovsky
  2010-07-29 14:52     ` Konstantin Haase
  1 sibling, 1 reply; 6+ messages in thread
From: Toby Matejovsky @ 2010-07-29 14:35 UTC (permalink / raw)
  To: rack-devel

That example from SO doesn't work for me on ruby 1.9.1p378, sinatra
1.0, rack 1.2.1, and thin 1.2.7 (it just pauses for a while and
returns the whole string). Same behavior on ruby1.8.7p299, sinatra
1.0, rack 1.2.1, and mongrel 1.1.5. Any obvious explanations?

-Toby



On Thu, Jul 29, 2010 at 4:45 AM, Konstantin Haase <k.haase@finn.de> wrote:
>
> On Jul 29, 2010, at 09:33 , DMG wrote:
>
>> Hi, is there any way to send response partially? In PHP you can flush
>> some data to the client.
>
> You have to return a body object, that responds to each and in there yields for every flush: http://stackoverflow.com/questions/3027435/is-there-a-way-to-flush-html-to-the-wire-in-sinatra/3028149#3028149 (that example is usable without Sinatra)
>
> Konstantin
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: partially send
  2010-07-29 14:35   ` Toby Matejovsky
@ 2010-07-29 14:52     ` Konstantin Haase
  2010-07-29 15:00       ` Toby Matejovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Konstantin Haase @ 2010-07-29 14:52 UTC (permalink / raw)
  To: rack-devel

But that's what the example does (the first one). Sleep 0.3 seconds, than flush.

Try this:

	# config.ru
	module Demo
		def self.each
			10.times do |i|
				yield(i.to_s << "\n")
				sleep 1
			end
		end
	end

	run proc { [200, {"Content-Type" => "text/plain"}, Demo]

Make sure to use Thin or something, not sure if it works in Webrick.

Konstantin

On Jul 29, 2010, at 16:35 , Toby Matejovsky wrote:

> That example from SO doesn't work for me on ruby 1.9.1p378, sinatra
> 1.0, rack 1.2.1, and thin 1.2.7 (it just pauses for a while and
> returns the whole string). Same behavior on ruby1.8.7p299, sinatra
> 1.0, rack 1.2.1, and mongrel 1.1.5. Any obvious explanations?
> 
> -Toby
> 
> 
> 
> On Thu, Jul 29, 2010 at 4:45 AM, Konstantin Haase <k.haase@finn.de> wrote:
>> 
>> On Jul 29, 2010, at 09:33 , DMG wrote:
>> 
>>> Hi, is there any way to send response partially? In PHP you can flush
>>> some data to the client.
>> 
>> You have to return a body object, that responds to each and in there yields for every flush: http://stackoverflow.com/questions/3027435/is-there-a-way-to-flush-html-to-the-wire-in-sinatra/3028149#3028149 (that example is usable without Sinatra)
>> 
>> Konstantin
>> 
>> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: partially send
  2010-07-29 14:52     ` Konstantin Haase
@ 2010-07-29 15:00       ` Toby Matejovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Toby Matejovsky @ 2010-07-29 15:00 UTC (permalink / raw)
  To: rack-devel

Right, I was running the example with the Crawler class that yields
(just had it sleep and return random string as a "search result").
Turns out this works fine with curl or Firefox, but not Chrome
(v5.0.375.125 for Mac). So it is actually an issue with Chrome, not
rack.

-Toby

On Thu, Jul 29, 2010 at 10:52 AM, Konstantin Haase <k.haase@finn.de> wrote:
> But that's what the example does (the first one). Sleep 0.3 seconds, than flush.
>
> Try this:
>
>        # config.ru
>        module Demo
>                def self.each
>                        10.times do |i|
>                                yield(i.to_s << "\n")
>                                sleep 1
>                        end
>                end
>        end
>
>        run proc { [200, {"Content-Type" => "text/plain"}, Demo]
>
> Make sure to use Thin or something, not sure if it works in Webrick.
>
> Konstantin
>
> On Jul 29, 2010, at 16:35 , Toby Matejovsky wrote:
>
>> That example from SO doesn't work for me on ruby 1.9.1p378, sinatra
>> 1.0, rack 1.2.1, and thin 1.2.7 (it just pauses for a while and
>> returns the whole string). Same behavior on ruby1.8.7p299, sinatra
>> 1.0, rack 1.2.1, and mongrel 1.1.5. Any obvious explanations?
>>
>> -Toby
>>
>>
>>
>> On Thu, Jul 29, 2010 at 4:45 AM, Konstantin Haase <k.haase@finn.de> wrote:
>>>
>>> On Jul 29, 2010, at 09:33 , DMG wrote:
>>>
>>>> Hi, is there any way to send response partially? In PHP you can flush
>>>> some data to the client.
>>>
>>> You have to return a body object, that responds to each and in there yields for every flush: http://stackoverflow.com/questions/3027435/is-there-a-way-to-flush-html-to-the-wire-in-sinatra/3028149#3028149 (that example is usable without Sinatra)
>>>
>>> Konstantin
>>>
>>>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-29 15:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-29  7:33 partially send DMG
2010-07-29  8:45 ` Konstantin Haase
2010-07-29  9:45   ` DMG
2010-07-29 14:35   ` Toby Matejovsky
2010-07-29 14:52     ` Konstantin Haase
2010-07-29 15:00       ` Toby Matejovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).