method

read_body

Importance_0

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v1_9_3_392) is shown here.

These similar methods exist in v2_5_5:

read_body(socket, block) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/webrick/httprequest.rb, line 345
    def read_body(socket, block)
      return unless socket
      if tc = self['transfer-encoding']
        case tc
        when /chunked/o then read_chunked(socket, block)
        else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
        end
      elsif self['content-length'] || @remaining_size
        @remaining_size ||= self['content-length'].to_i
        while @remaining_size > 0
          sz = [@buffer_size, @remaining_size].min
          break unless buf = read_data(socket, sz)
          @remaining_size -= buf.bytesize
          block.call(buf)
        end
        if @remaining_size > 0 && @socket.eof?
          raise HTTPStatus::BadRequest, "invalid body size."
        end
      elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
        raise HTTPStatus::LengthRequired
      end
      return @body
    end
Register or log in to add new notes.