Methods
B
C
D
E
I
O
R
S
T
W
Included Modules
Attributes
[RW] error_latch
[RW] latch
[RW] tc
Class Public methods
controller_path()
# File actionpack/test/controller/live_stream_test.rb, line 117
def self.controller_path
  'test'
end
Instance Public methods
bad_request_error()
# File actionpack/test/controller/live_stream_test.rb, line 192
def bad_request_error
  raise ActionController::BadRequest
end
basic_stream()
# File actionpack/test/controller/live_stream_test.rb, line 136
def basic_stream
  response.headers['Content-Type'] = 'text/event-stream'
  %w{ hello world }.each do |word|
    response.stream.write word
  end
  response.stream.close
end
blocking_stream()
# File actionpack/test/controller/live_stream_test.rb, line 144
def blocking_stream
  response.headers['Content-Type'] = 'text/event-stream'
  %w{ hello world }.each do |word|
    response.stream.write word
    latch.wait
  end
  response.stream.close
end
default_header()
# File actionpack/test/controller/live_stream_test.rb, line 131
def default_header
  response.stream.write "<html><body>hi</body></html>"
  response.stream.close
end
exception_in_controller()
# File actionpack/test/controller/live_stream_test.rb, line 188
def exception_in_controller
  raise Exception, 'Exception in controller'
end
exception_in_exception_callback()
# File actionpack/test/controller/live_stream_test.rb, line 196
def exception_in_exception_callback
  response.headers['Content-Type'] = 'text/event-stream'
  response.stream.on_error do
    raise 'We need to go deeper.'
  end
  response.stream.write ''
  response.stream.write params[:widget][:didnt_check_for_nil]
end
exception_in_view()
# File actionpack/test/controller/live_stream_test.rb, line 167
def exception_in_view
  render 'doesntexist'
end
exception_in_view_after_commit()
# File actionpack/test/controller/live_stream_test.rb, line 171
def exception_in_view_after_commit
  response.stream.write ""
  render 'doesntexist'
end
exception_with_callback()
# File actionpack/test/controller/live_stream_test.rb, line 176
def exception_with_callback
  response.headers['Content-Type'] = 'text/event-stream'

  response.stream.on_error do
    response.stream.write %Q(data: "500 Internal Server Error"\n\n)
    response.stream.close
  end

  response.stream.write "" # make sure the response is committed
  raise 'An exception occurred...'
end
ignore_client_disconnect()
# File actionpack/test/controller/live_stream_test.rb, line 230
def ignore_client_disconnect
  response.stream.ignore_disconnect = true

  response.stream.write '' # commit

  # These writes will be ignored
  15.times do
    response.stream.write 'x'
  end

  logger.info 'Work complete'
  latch.count_down
end
overfill_buffer_and_die()
# File actionpack/test/controller/live_stream_test.rb, line 205
def overfill_buffer_and_die
  logger = ActionController::Base.logger || Logger.new($stdout)
  response.stream.on_error do
    logger.warn 'Error while streaming.'
    error_latch.count_down
  end

  # Write until the buffer is full. It doesn't expose that
  # information directly, so we must hard-code its size:
  10.times do
    response.stream.write '.'
  end
  # .. plus one more, because the #each frees up a slot:
  response.stream.write '.'

  latch.count_down

  # This write will block, and eventually raise
  response.stream.write 'x'

  20.times do
    response.stream.write '.'
  end
end
render_text()
# File actionpack/test/controller/live_stream_test.rb, line 127
def render_text
  render plain: 'zomg'
end
thread_locals()
# File actionpack/test/controller/live_stream_test.rb, line 153
def thread_locals
  tc.assert_equal 'aaron', Thread.current[:setting]

  response.headers['Content-Type'] = 'text/event-stream'
  %w{ hello world }.each do |word|
    response.stream.write word
  end
  response.stream.close
end
with_stale()
# File actionpack/test/controller/live_stream_test.rb, line 163
def with_stale
  render plain: 'stale' if stale?(etag: "123", template: false)
end