Class: Cybertrain::BodyWriter

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/http/body_writer.rb

Overview

What a streaming response carries instead of a body (docs/design.md D36): the Server sends the head, then calls #write_body on the connection’s thread with a Sink on the socket, then ends the response and closes the connection. A subclass overrides #write_body; the base is typed like Middleware so Spinel resolves the call statically (spikes/NOTES.md rule 3). Set one with Response#body_writer=, or in an action with Controller#stream.

Instance Method Summary collapse

Instance Method Details

#write_body(sink) ⇒ nil

Writes the body to sink and returns when it is done (or the client went away: Sink#closed?). An exception it raises is logged and ends the connection; unless it is one a client that went away causes (EOFError, IOError, Errno::ECONNRESET, Errno::EPIPE), the Server also hands it to the installed stream-failure sink (Cybertrain.stream_failure), which reports it to Cybertrain.error once cybertrain/error_reporter is loaded (as require "cybertrain/core" does).

Parameters:

Returns:

  • (nil)


25
26
27
# File 'cybertrain/http/body_writer.rb', line 25

def write_body(sink)
  nil
end