Class: PumaPlus::WorkerThread::Hijack

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_plus/worker_thread.rb

Overview

The object behind env.

Per the Rack SPEC, calling it returns the IO and also sets env. Sending the HIJACK frame first is what tells Go to stop expecting frames -- if the app wrote to the socket before that frame went out, Go would try to parse the app's bytes as a response frame.

Instance Method Summary collapse

Constructor Details

#initialize(conn, env) ⇒ Hijack

Returns a new instance of Hijack.



300
301
302
303
304
# File 'lib/puma_plus/worker_thread.rb', line 300

def initialize(conn, env)
  @conn = conn
  @env = env
  @hijacked = false
end

Instance Method Details

#callObject



312
313
314
315
316
317
318
# File 'lib/puma_plus/worker_thread.rb', line 312

def call
  return @conn if @hijacked

  @conn.write Wire.frame(Wire::HIJACK)
  @hijacked = true
  @env["rack.hijack_io"] = @conn
end

#hijacked?Boolean

Returns:

  • (Boolean)


306
# File 'lib/puma_plus/worker_thread.rb', line 306

def hijacked? = @hijacked

#to_procObject



308
309
310
# File 'lib/puma_plus/worker_thread.rb', line 308

def to_proc
  method(:call).to_proc
end