Class: Async::WebSocket::Request
- Inherits:
-
Object
- Object
- Async::WebSocket::Request
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/async/websocket/request.rb
Instance Attribute Summary collapse
-
#authority ⇒ Object
Returns the value of attribute authority.
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(connection) ⇒ Object
Send the request to the given connection.
- #idempotent? ⇒ Boolean
-
#initialize(scheme = nil, authority = nil, path = nil, headers = nil, **options, &block) ⇒ Request
constructor
A new instance of Request.
- #protocol ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(scheme = nil, authority = nil, path = nil, headers = nil, **options, &block) ⇒ Request
Returns a new instance of Request.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/async/websocket/request.rb', line 19 def initialize(scheme = nil, = nil, path = nil, headers = nil, **, &block) @scheme = scheme = @path = path @headers = headers = @body = nil end |
Instance Attribute Details
#authority ⇒ Object
Returns the value of attribute authority.
35 36 37 |
# File 'lib/async/websocket/request.rb', line 35 def end |
#body ⇒ Object
Returns the value of attribute body.
39 40 41 |
# File 'lib/async/websocket/request.rb', line 39 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
37 38 39 |
# File 'lib/async/websocket/request.rb', line 37 def headers @headers end |
#path ⇒ Object
Returns the value of attribute path.
36 37 38 |
# File 'lib/async/websocket/request.rb', line 36 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
34 35 36 |
# File 'lib/async/websocket/request.rb', line 34 def scheme @scheme end |
Class Method Details
.websocket?(request) ⇒ Boolean
15 16 17 |
# File 'lib/async/websocket/request.rb', line 15 def self.websocket?(request) Array(request.protocol).include?(PROTOCOL) end |
Instance Method Details
#call(connection) ⇒ Object
Send the request to the given connection.
42 43 44 45 46 47 48 49 50 |
# File 'lib/async/websocket/request.rb', line 42 def call(connection) if connection.http1? return UpgradeRequest.new(self, **).call(connection) elsif connection.http2? return ConnectRequest.new(self, **).call(connection) end raise UnsupportedVersionError, "Unsupported HTTP version: #{connection.version}!" end |
#idempotent? ⇒ Boolean
52 53 54 |
# File 'lib/async/websocket/request.rb', line 52 def idempotent? true end |
#protocol ⇒ Object
30 31 32 |
# File 'lib/async/websocket/request.rb', line 30 def protocol PROTOCOL end |
#to_s ⇒ Object
56 57 58 59 |
# File 'lib/async/websocket/request.rb', line 56 def to_s uri = "#{@scheme}://#{@authority}#{@path}" "\#<#{self.class} uri=#{uri.inspect}>" end |