Http streaming using thin and eventmachine

I play with EM to achieve streaming and concurrency. I'm having a problem with streaming ... I am running the following rack application https://gist.github.com/1394840 using

$ rackup -s thin -p 3000 async_app.ru 

When tested with $ ab -c 10 -n 20 http://localhost:3000/ application seems to be accepting parellel requests. Excellent!

I expect it to reach streaming time. When I test it in Firefox8, it works so well. And using $ curl -i http://localhost:3000/ , the result will be transmitted exactly as expected!

But later, when tested in IE and Chrome, the streaming failed, i.e. three lines appeared only 5 seconds after starting the request ...

I doubted that if I miss something required by the browser? I noticed that the response headers did not Transfer-Encoding:chunked , does that really matter? If so, is this a subtle issue? How can I implement threads with thin or in Chrome?

Thanks!

+4
source share
1 answer

Obviously, browsers won't start rendering the page until they get a certain β€œamount” of response, as he indicated in this article . So I tried the following:

  body.call ["Hey!\n".ljust(1024)] 

I tested it with Safari 6, Chrome 22, and Firefox 14, and they all start working as expected when the first message is at least 1 KB. In fact, Safari began to print messages, even if the first one was more than 512 bytes.

0
source

Source: https://habr.com/ru/post/1383150/


All Articles