Class: TestServer::StreamingController

Inherits:
ApplicationController show all
Includes:
ActionController::Live
Defined in:
app/controllers/test_server/streaming_controller.rb

Instance Method Summary collapse

Methods included from WebHelper

#configure_caching, #encode, #generate_eicar, #generate_random_string, #generate_string

Instance Method Details

#eicarObject



23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/test_server/streaming_controller.rb', line 23

def eicar
  generate_eicar.each do |c|
    response.stream.write(
      encode(params) { c }
    )

    sleep(params[:wait].to_f / 1_000.0)
  end

  response.stream.close
end

#indexObject



9
10
# File 'app/controllers/test_server/streaming_controller.rb', line 9

def index
end

#plainObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/test_server/streaming_controller.rb', line 12

def plain
  params[:count].to_i.times do |n|
    response.stream.write(
      encode(params) { "#{n + 1}: data" }
    )
    sleep(params[:wait].to_f / 1_000.0)
  end

  response.stream.close
end

#randomObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/test_server/streaming_controller.rb', line 35

def random
  params[:count].to_i.times do |n|
    
    response.stream.write(
      encode(params) { generate_random_string(1) }
    )
    sleep(params[:wait].to_f / 1_000.0)
  end

  response.stream.close
end