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.



540
541
542
# File 'lib/cloudflare_workers.rb', line 540

def initialize(js_response)
  @js_response = js_response
end

Instance Attribute Details

#js_responseObject (readonly)

Returns the value of attribute js_response.



538
539
540
# File 'lib/cloudflare_workers.rb', line 538

def js_response
  @js_response
end

Instance Method Details

#closeObject



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

def close; end

#eachObject

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



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

def each; end

#raw_response?Boolean

Returns:

  • (Boolean)


550
551
552
# File 'lib/cloudflare_workers.rb', line 550

def raw_response?
  true
end