Class: Async::HTTP::Protocol::HTTP2::Server
- Inherits:
-
Protocol::HTTP2::Server
- Object
- Protocol::HTTP2::Server
- Async::HTTP::Protocol::HTTP2::Server
show all
- Includes:
- Connection
- Defined in:
- lib/async/http/protocol/http2/server.rb
Instance Attribute Summary collapse
Attributes included from Connection
#count, #promises, #stream
Instance Method Summary
collapse
Methods included from Connection
#concurrency, #http1?, #http2?, #peer, #read_in_background, #reusable?, #start_connection, #to_s, #version, #viable?, #write_frame, #write_frames
Constructor Details
#initialize(stream) ⇒ Server
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/async/http/protocol/http2/server.rb', line 35
def initialize(stream)
@stream = stream
framer = ::Protocol::HTTP2::Framer.new(stream)
super(framer)
@requests = Async::Queue.new
end
|
Instance Attribute Details
#requests ⇒ Object
Returns the value of attribute requests.
46
47
48
|
# File 'lib/async/http/protocol/http2/server.rb', line 46
def requests
@requests
end
|
Instance Method Details
#accept_stream(stream_id) ⇒ Object
48
49
50
51
52
|
# File 'lib/async/http/protocol/http2/server.rb', line 48
def accept_stream(stream_id)
super do
Request::Stream.create(self, stream_id)
end
end
|
#close(error = nil) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/async/http/protocol/http2/server.rb', line 54
def close(error = nil)
if @requests
@requests.enqueue(nil)
@requests = nil
end
super
end
|
#each(task: Task.current) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/async/http/protocol/http2/server.rb', line 64
def each(task: Task.current)
task.annotate("Reading #{version} requests for #{self.class}.")
@requests&.async do |task, request|
task.annotate("Incoming request: #{request.method} #{request.path.inspect}.")
@count += 1
begin
response = yield(request)
rescue
request.stream.send_reset_stream(::Protocol::HTTP2::INTERNAL_ERROR)
raise
else
request.send_response(response)
end
end
end
|