Class: Async::HTTP::Protocol::HTTP2::Server
- Inherits:
-
HTTP::Protocol::HTTP2::Server
- Object
- HTTP::Protocol::HTTP2::Server
- Async::HTTP::Protocol::HTTP2::Server
- Includes:
- Connection
- Defined in:
- lib/async/http/protocol/http2/server.rb
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
Attributes included from Connection
Instance Method Summary collapse
- #create_stream(stream_id) ⇒ Object
- #each ⇒ Object
-
#initialize(stream) ⇒ Server
constructor
A new instance of Server.
- #stop_connection(error) ⇒ Object
Methods included from Connection
#close, #connected?, #multiplex, #peer, #read_in_background, #reusable?, #start_connection, #version
Constructor Details
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
44 45 46 |
# File 'lib/async/http/protocol/http2/server.rb', line 44 def requests @requests end |
Instance Method Details
#create_stream(stream_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/async/http/protocol/http2/server.rb', line 46 def create_stream(stream_id) request = Request.new(self, stream_id) return request.stream end |
#each ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/async/http/protocol/http2/server.rb', line 58 def each while request = @requests.dequeue @count += 1 # We need to close the stream if the user code blows up while generating a response: response = begin response = yield(request) rescue request.stream.send_reset_stream(::HTTP::Protocol::HTTP2::INTERNAL_ERROR) Async.logger.error(request) {$!} else request.send_response(response) end end end |
#stop_connection(error) ⇒ Object
52 53 54 55 56 |
# File 'lib/async/http/protocol/http2/server.rb', line 52 def stop_connection(error) super @requests.enqueue nil end |