module Puma::Request

def fast_write_str(socket, str)

Raises:
  • (ConnectionError) -

Parameters:
  • str (String) -- the string written to the io
  • socket (#write_nonblock) -- the request/response socket
def fast_write_str(socket, str)
  n = 0
  byte_size = str.bytesize
  while n < byte_size
    begin
      n += socket.write_nonblock(n.zero? ? str : str.byteslice(n..-1))
    rescue Errno::EAGAIN, Errno::EWOULDBLOCK
      unless socket.wait_writable WRITE_TIMEOUT
        raise ConnectionError, SOCKET_WRITE_ERR_MSG
      end
      retry
    rescue  Errno::EPIPE, SystemCallError, IOError
      raise ConnectionError, SOCKET_WRITE_ERR_MSG
    end
  end
end