Class: H2::Server

Inherits:
Reel::Server
  • Object
show all
Defined in:
lib/h2/server.rb,
lib/h2/server/https.rb,
lib/h2/server/stream.rb,
lib/h2/server/connection.rb,
lib/h2/server/push_promise.rb,
lib/h2/server/stream/request.rb,
lib/h2/server/stream/response.rb

Overview

base H2 server, a direct subclass of Reel::Server

Direct Known Subclasses

HTTP, HTTPS

Defined Under Namespace

Classes: Connection, HTTP, HTTPS, PushPromise, Stream

Instance Method Summary collapse

Constructor Details

#initialize(server, **options, &on_connection) ⇒ Server

Returns a new instance of Server.



27
28
29
30
# File 'lib/h2/server.rb', line 27

def initialize server, **options, &on_connection
  @on_connection = on_connection
  super server, options
end

Instance Method Details

#goaway(connection) ⇒ Object

async goaway



55
56
57
58
# File 'lib/h2/server.rb', line 55

def goaway connection
  sleep 0.25
  connection.parser.goaway unless connection.closed?
end

#handle_connection(socket) ⇒ Object

build a new connection object, run it through the given block, and start reading from the socket if still attached



35
36
37
38
39
# File 'lib/h2/server.rb', line 35

def handle_connection socket
  connection = H2::Server::Connection.new socket: socket, server: self
  @on_connection[connection]
  connection.read if connection.attached?
end

#handle_push_promise(push_promise) ⇒ Object

async push promise



49
50
51
# File 'lib/h2/server.rb', line 49

def handle_push_promise push_promise
  push_promise.keep
end

#handle_stream(stream) ⇒ Object

async stream handling



43
44
45
# File 'lib/h2/server.rb', line 43

def handle_stream stream
  stream.connection.each_stream[stream]
end