Module: Veewee::Provider::Core::Helper::Web

Included in:
Box
Defined in:
lib/veewee/provider/core/helper/web.rb

Instance Method Summary collapse

Instance Method Details

#allow_for_http_request(filename, urlname, options) ⇒ Object

start in new thread


20
21
22
23
24
25
26
27
# File 'lib/veewee/provider/core/helper/web.rb', line 20

def allow_for_http_request(filename, urlname, options) # start in new thread
  thread = Thread.new do
    server_for_http_request(filename, urlname, options)
  end
  thread.abort_on_exception = true
  trap("INT") { thread.kill; exit }
  thread
end

#wait_for_http_request(filename, urlname, options) ⇒ Object

thread with timeout


11
12
13
14
15
16
17
18
# File 'lib/veewee/provider/core/helper/web.rb', line 11

def wait_for_http_request(filename, urlname, options) # thread with timeout
  thread  = allow_for_http_request(filename, urlname, options)
  timeout = options[:timeout] || 60
  thread.join(timeout) or begin
    thread.kill
    raise "File #{filename.inspect} was not requested as #{urlname.inspect} in #{timeout} seconds, are you using firewall blocking connections to port: #{options[:port]}?"
  end
end