Module: Veewee::Provider::Core::Helper::Web
- Included in:
- Box
- Defined in:
- lib/veewee/provider/core/helper/web.rb
Instance Method Summary collapse
-
#allow_for_http_request(filename, urlname, options) ⇒ Object
start in new thread.
- #server_for_http_request(filename, urlname, options = {:timeout => 10, :port => 7125, :threaded => false}) ⇒ Object
-
#wait_for_http_request(filename, urlname, options) ⇒ Object
original blocking.
Instance Method Details
#allow_for_http_request(filename, urlname, options) ⇒ Object
start in new thread
48 49 50 51 |
# File 'lib/veewee/provider/core/helper/web.rb', line 48 def allow_for_http_request(filename, urlname, ) # start in new thread s = server_for_http_request(filename, urlname, .merge({:threaded => false})) Thread.new { s.start } end |
#server_for_http_request(filename, urlname, options = {:timeout => 10, :port => 7125, :threaded => false}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/veewee/provider/core/helper/web.rb', line 53 def server_for_http_request(filename, urlname, ={:timeout => 10, :port => 7125, :threaded => false}) # Calculate the OS equivalent of /dev/null , on windows this is NUL: # http://www.ruby-forum.com/topic/115472 fn = test(?e, '/dev/null') ? '/dev/null' : 'NUL:' webrick_logger=WEBrick::Log.new(fn, WEBrick::Log::INFO) s= ::WEBrick::HTTPServer.new( :Port => [:port], :Logger => webrick_logger, :AccessLog => webrick_logger ) env.logger.debug("mounting file #{urlname}") s.mount("#{urlname}", Veewee::Provider::Core::Helper::Servlet::FileServlet, filename, ui, [:threaded]) trap("INT"){ s.shutdown ui.info "Stopping webserver" exit } s end |
#wait_for_http_request(filename, urlname, options) ⇒ Object
original blocking
43 44 45 46 |
# File 'lib/veewee/provider/core/helper/web.rb', line 43 def wait_for_http_request(filename, urlname, ) # original blocking s = server_for_http_request(filename, urlname, ) s.start end |