Class: Cloudflare::BinaryBody
- Inherits:
-
Object
- Object
- Cloudflare::BinaryBody
- Defined in:
- lib/cloudflare_workers.rb
Overview
BinaryBody wraps a JS ReadableStream (from R2, fetch, etc.) so it can flow through the Rack/Sinatra body pipeline without being converted to an Opal String (which would mangle the bytes). ‘build_js_response` detects BinaryBody and passes the stream directly to `new Response`.
Instance Attribute Summary collapse
-
#cache_control ⇒ Object
readonly
Returns the value of attribute cache_control.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #close ⇒ Object
-
#each ⇒ Object
Rack body contract — yield nothing so Sinatra’s content-length calculation skips this body.
-
#initialize(stream, content_type = 'application/octet-stream', cache_control = nil) ⇒ BinaryBody
constructor
A new instance of BinaryBody.
Constructor Details
#initialize(stream, content_type = 'application/octet-stream', cache_control = nil) ⇒ BinaryBody
Returns a new instance of BinaryBody.
520 521 522 523 524 |
# File 'lib/cloudflare_workers.rb', line 520 def initialize(stream, content_type = 'application/octet-stream', cache_control = nil) @stream = stream @content_type = content_type @cache_control = cache_control end |
Instance Attribute Details
#cache_control ⇒ Object (readonly)
Returns the value of attribute cache_control.
518 519 520 |
# File 'lib/cloudflare_workers.rb', line 518 def cache_control @cache_control end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
518 519 520 |
# File 'lib/cloudflare_workers.rb', line 518 def content_type @content_type end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
518 519 520 |
# File 'lib/cloudflare_workers.rb', line 518 def stream @stream end |
Instance Method Details
#close ⇒ Object
530 |
# File 'lib/cloudflare_workers.rb', line 530 def close; end |
#each ⇒ Object
Rack body contract — yield nothing so Sinatra’s content-length calculation skips this body. The real bytes go through JS.
528 |
# File 'lib/cloudflare_workers.rb', line 528 def each; end |