Class: Cloudflare::RawResponse

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

Overview

RawResponse wraps an already-constructed JS ‘Response` so routes can return it through Sinatra and have `build_js_response` pass it through to the Workers runtime untouched. Needed when the Response carries runtime-only properties that would disappear if reconstructed — e.g. a 101 upgrade Response with `.webSocket`. Unlike `BinaryBody`, no new Response is constructed; the stored JS object is returned as-is.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(js_response) ⇒ RawResponse

Returns a new instance of RawResponse.



498
499
500
# File 'lib/cloudflare_workers.rb', line 498

def initialize(js_response)
  @js_response = js_response
end

Instance Attribute Details

#js_responseObject (readonly)

Returns the value of attribute js_response.



496
497
498
# File 'lib/cloudflare_workers.rb', line 496

def js_response
  @js_response
end

Instance Method Details

#closeObject



506
# File 'lib/cloudflare_workers.rb', line 506

def close; end

#eachObject

Rack body contract — yield nothing. The bytes never flow through Ruby; the JS Response goes straight to the runtime.



504
# File 'lib/cloudflare_workers.rb', line 504

def each; end

#raw_response?Boolean

Returns:

  • (Boolean)


508
509
510
# File 'lib/cloudflare_workers.rb', line 508

def raw_response?
  true
end