Tim Sutherland wrote:

> require 'stringio'
> def do_GET(req, res)
>  res["content-type"] = "text/plain"
>  res.chunked = true if res.keep_alive?
>  res.body = StringIO.new(@my_big_string)
> end

I'm afraid 'std::streamstring' was a red-herring; I'l ask a different way.

Suppose I use 'cgi.rb' and write a script for a CGI server to serve. It 
serves by collecting $stdout and pushing that out its port.

So I can cook a page like this:

  cookPage($stdout, query)

  def cookPage(out, query)
    ...
    out.write('<html/>')
  end

Inside that cookPage(), calls to out.write() immediately send characters out 
$stdout. Hence, these immediately pipe into the CGI server, who immediately 
pipes them out the TCP/IP port. All with minimal buffering.

(This is post-mature optimization, folks; web servers must be responsive!)

The problem with res.body = anything is that anything must already have 
contents, and this requires a big slow memory buffer, on this side, to store 
its contents. So is there some other architecture within Webrick to avoid 
slinging around this big buffer, while the actual port starves?

-- 
  Phlip
  http://www.greencheese.org/ZeekLand  <-- NOT a blog!!!