src/ruby_supportlib/phusion_passenger/message_channel.rb
# Read an array message from the underlying file descriptor.
# Returns the array message as an array, or nil when end-of-stream has
# been reached.
#
# Might raise SystemCallError, IOError or SocketError when something
# goes wrong.
Read an array message from the underlying file descriptor.
Returns the array message as an array, or nil when end-of-stream has
been reached.

Might raise SystemCallError, IOError or SocketError when something
goes wrong.
Read an array message from the underlying file descriptor . Returns the array message as an array or nil when end - of - stream has been reached . Might raise SystemCallError IOError or SocketError when something goes wrong .
def read
      buffer = new_buffer
      if !@io.read(HEADER_SIZE, buffer)
        return nil
      end
      while buffer.size < HEADER_SIZE
        tmp = @io.read(HEADER_SIZE - buffer.size)
        if tmp.empty?
          return nil
        else
          buffer << tmp
        end
      end
      chunk_size = buffer.unpack(UINT16_PACK_FORMAT)[0]
      if !@io.read(chunk_size, buffer)
        return nil
      end
      while buffer.size < chunk_size
        tmp = @io.read(chunk_size - buffer.size)
        if tmp.empty?
          return nil
        else
          buffer << tmp
        end
      end
      message = []
      offset = 0
      delimiter_pos = buffer.index(DELIMITER, offset)
      while !delimiter_pos.nil?
        if delimiter_pos == 0
          message << ""
        else
          message << buffer[offset .. delimiter_pos - 1]
        end
        offset = delimiter_pos + 1
        delimiter_pos = buffer.index(DELIMITER, offset)
      end
      return message
    rescue Errno::ECONNRESET
      return nil
    end
def read buffer = new_buffer if ! @io . read ( HEADER_SIZE , buffer ) return nil end while buffer . size < HEADER_SIZE tmp = @io . read ( HEADER_SIZE - buffer . size ) if tmp . empty? return nil else buffer << tmp end end chunk_size = buffer . unpack ( UINT16_PACK_FORMAT ) [ 0 ] if ! @io . read ( chunk_size , buffer ) return nil end while buffer . size < chunk_size tmp = @io . read ( chunk_size - buffer . size ) if tmp . empty? return nil else buffer << tmp end end message = [ ] offset = 0 delimiter_pos = buffer . index ( DELIMITER , offset ) while ! delimiter_pos . nil? if delimiter_pos == 0 message << "" else message << buffer [ offset .. delimiter_pos - 1 ] end offset = delimiter_pos + 1 delimiter_pos = buffer . index ( DELIMITER , offset ) end return message rescue Errno :: ECONNRESET return nil end
Read an array message from the underlying file descriptor.
Read an array message from the underlying file descriptor .