Class: Daps::Server::ArchiveStreamer
- Inherits:
-
Cramp::Controller::Action
- Object
- Cramp::Controller::Action
- Daps::Server::ArchiveStreamer
- Defined in:
- lib/daps/server.rb
Constant Summary collapse
- @@activated =
false
Instance Method Summary collapse
- #open_stream ⇒ Object
- #render(data) ⇒ Object
- #respond_with ⇒ Object
- #terminate ⇒ Object
- #verify_token ⇒ Object
Instance Method Details
#open_stream ⇒ Object
45 46 47 48 |
# File 'lib/daps/server.rb', line 45 def open_stream puts "Transferring archive..." @pipe = EM.popen('tar -czf - .', Daps::Server::Pipe, self) end |
#render(data) ⇒ Object
59 60 61 62 63 |
# File 'lib/daps/server.rb', line 59 def render(data) term = "\r\n" size = Rack::Utils.bytesize(data) super([size.to_s(16), term, data, term].join) end |
#respond_with ⇒ Object
41 42 43 |
# File 'lib/daps/server.rb', line 41 def respond_with [200, {'Content-Type' => 'application/x-gzip', 'Transfer-Encoding' => 'chunked'}] end |
#terminate ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/daps/server.rb', line 50 def terminate @pipe.terminate if @pipe EM.next_tick { if @env['daps.token'] == @token EM.stop_event_loop end } end |
#verify_token ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/daps/server.rb', line 31 def verify_token @token = File.basename(@env['PATH_INFO']) if @env['daps.token'] != @token or @@activated halt 403, {'Content-Type' => 'text/html'}, 'back off!!' else @@activated = true yield end end |