Method: Tipi::HTTP2StreamHandler#initialize
- Defined in:
- lib/tipi/http2_stream.rb
#initialize(adapter, stream, conn, first, &block) ⇒ HTTP2StreamHandler
Returns a new instance of HTTP2StreamHandler.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tipi/http2_stream.rb', line 11 def initialize(adapter, stream, conn, first, &block) @adapter = adapter @stream = stream @conn = conn @first = first @connection_fiber = Fiber.current @stream_fiber = spin { run(&block) } # Stream callbacks occur on the connection fiber (see HTTP2Adapter#each). # The request handler is run on a separate fiber for each stream, allowing # concurrent handling of incoming requests on the same HTTP/2 connection. # # The different stream adapter APIs suspend the stream fiber, waiting for # stream callbacks to be called. The callbacks, in turn, transfer control to # the stream fiber, effectively causing the return of the adapter API calls. # # Note: the request handler is run once headers are received. Reading the # request body, if present, is at the discretion of the request handler. # This mirrors the behaviour of the HTTP/1 adapter. stream.on(:headers, &method(:on_headers)) stream.on(:data, &method(:on_data)) stream.on(:half_close, &method(:on_half_close)) end |