Sha256: 0183711d2d3873bb02127ef8c17637c57bc03345ba3868af1c791a5ba6a787cf

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

# WebROaR - Ruby Application Server - http://webroar.in/
# Copyright (C) 2009  Goonj LLC
#
# This file is part of WebROaR.
#
# WebROaR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# WebROaR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WebROaR.  If not, see <http://www.gnu.org/licenses/>.

# RequestBody class based on ebb server's http://github.com/ry/ebb/tree/v0.1.0
require 'stringio'
module Webroar
  class RequestBody
    def initialize(client)
      @client = client
    end
    
    def read(len = nil, s = '')
      if @io
        @io.read(len)
      else
        if len.nil?          
          while(chunk = read(10*1024))
            s << chunk
          end
          s
        else
          s = Webroar::read_request(@client, len)
        end
      end
    end
    
    def gets
      io.gets
    end
    
    def each(&block)
      io.each(&block)
    end
    
    def io
      @io ||= StringIO.new(read)
    end
    
    # Adding rewind method to meet Rack specification.
    def rewind
      @io.rewind if @io
    end
  end # RequestBody
end # Webroar

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
webroar-0.7.0 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.6.1 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.5.0 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.4.0 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.3.1 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.3.0 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.2.6 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.2.5 src/ruby_lib/ruby_interface/request_body.rb
webroar-0.2.4 src/ruby_lib/ruby_interface/request_body.rb