Class: Async::HTTP::Protocol::HTTP1x
- Inherits:
-
IO::Protocol::Line
- Object
- IO::Protocol::Line
- Async::HTTP::Protocol::HTTP1x
- Defined in:
- lib/async/http/protocol/http1x.rb
Overview
A server that supports both HTTP1.0 and HTTP1.1 semantics by detecting the version of the request.
Constant Summary collapse
Instance Method Summary collapse
- #create_handler(version) ⇒ Object
-
#initialize(stream, handlers: HANDLERS) ⇒ HTTP1x
constructor
A new instance of HTTP1x.
- #receive_requests(&block) ⇒ Object
- #send_request(request, &block) ⇒ Object
Constructor Details
Instance Method Details
#create_handler(version) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/async/http/protocol/http1x.rb', line 42 def create_handler(version) if klass = @handlers[version] klass.new(@stream) else raise RuntimeError, "Unsupported protocol version #{version}" end end |
#receive_requests(&block) ⇒ Object
50 51 52 53 54 |
# File 'lib/async/http/protocol/http1x.rb', line 50 def receive_requests(&block) method, path, version = self.peek_line.split(/\s+/, 3) create_handler(version).receive_requests(&block) end |
#send_request(request, &block) ⇒ Object
56 57 58 |
# File 'lib/async/http/protocol/http1x.rb', line 56 def send_request(request, &block) create_handler(request.version).send_request(request, &block) end |