Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 176361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:51:46+00:00 2026-05-11T13:51:46+00:00

Has anyone tried streaming html/text/content from webrick? I’ve tried assigning an IO to the

  • 0

Has anyone tried streaming html/text/content from webrick? I’ve tried assigning an IO to the response body, but webrick is waiting for the stream to be closed first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:51:47+00:00Added an answer on May 11, 2026 at 1:51 pm

    found this link by accident (http://redmine.ruby-lang.org/attachments/download/161) which contains webrick patch

    # Copyright (C) 2008 Brian Candler, released under Ruby Licence. # # A collection of small monkey-patches to webrick.  require 'webrick'  module WEBrick    class HTTPRequest     # Generate HTTP/1.1 100 continue response. See     # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/18459     def continue       if self['expect'] == '100-continue' && @config[:HTTPVersion] >= '1.1'         @socket.write 'HTTP/#{@config[:HTTPVersion]} 100 continue\r\n\r\n'         @header.delete('expect')       end     end   end    class HTTPResponse     alias :orig_setup_header :setup_header     # Correct termination of streamed HTTP/1.1 responses. See     # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/18454 and     # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/18565     def setup_header       orig_setup_header       unless chunked? || @header['content-length']         @header['connection'] = 'close'         @keep_alive = false       end     end      # Allow streaming of zipfile entry. See     # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/18460     def send_body(socket)       if @body.respond_to?(:read) then send_body_io(socket)       elsif @body.respond_to?(:call) then send_body_proc(socket)       else send_body_string(socket)       end     end      # If the response body is a proc, then we invoke it and pass in     # an object which supports 'write' and '<<' methods. This allows     # arbitary output streaming.     def send_body_proc(socket)       if @request_method == 'HEAD'         # do nothing       elsif chunked?         @body.call(ChunkedWrapper.new(socket, self))         _write_data(socket, '0#{CRLF}#{CRLF}')       else         size = @header['content-length'].to_i         @body.call(socket)   # TODO: StreamWrapper which supports offset, size         @sent_size = size       end     end      class ChunkedWrapper       def initialize(socket, resp)         @socket = socket         @resp = resp       end       def write(buf)         return if buf.empty?         data = ''         data << format('%x', buf.size) << CRLF         data << buf << CRLF         socket = @socket         @resp.instance_eval {           _write_data(socket, data)           @sent_size += buf.size         }       end       alias :<< :write     end   end end  if RUBY_VERSION < '1.9'   old_verbose, $VERBOSE = $VERBOSE, nil   # Increase from default of 4K for efficiency, similar to   # http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/net/protocol.rb?r1=11708&r2=12092   # In trunk the default is 64K and can be adjusted using :InputBufferSize,   # :OutputBufferSize   WEBrick::HTTPRequest::BUFSIZE = 16384   WEBrick::HTTPResponse::BUFSIZE = 16384   $VERBOSE = old_verbose end 

    to use simply pass a proc to as the response body, like so

    res.body = proc { |w|   10.times do     w << Time.now.to_s     sleep(1)   end } 

    woot!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone tried using $(html, body).animate({scrollTop:0}, 'slow'); on Opera browser? It does a weird
Has anyone tried taking a video from the camera and then using the video
Has anyone tried migrating from ScrewTurn to Confluence ? I'm hoping that I can
Has anyone tried accessing bungie.net reach stats api (statistics from Halo Matchmaking)? As described
Has anyone tried reading and writing data to/from COM ports in webpages. I am
Has anyone tried to build an e-commerce site atop MS Dynamics, using the new
Has anyone tried to back up a SharePoint web application using forms based authentication
Has anyone tried automatic Java to C++ conversion for speed improvements? Is it a
Has anyone tried out working with the Delete and update command of SPDataSource used
Has Anyone tried using PDF in iPad Application, using CGPDf functions. I have used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.