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.
- #to_s ⇒ Object
Constructor Details
#initialize(scheme = nil, authority = nil, path = nil, headers = nil, **options, &block) ⇒ Request
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/async/websocket/request.rb', line 18 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.
30 31 32 |
# File 'lib/async/websocket/request.rb', line 30 def end |
#body ⇒ Object
Returns the value of attribute body.
34 35 36 |
# File 'lib/async/websocket/request.rb', line 34 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
32 33 34 |
# File 'lib/async/websocket/request.rb', line 32 def headers @headers end |
#path ⇒ Object
Returns the value of attribute path.
31 32 33 |
# File 'lib/async/websocket/request.rb', line 31 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
29 30 31 |
# File 'lib/async/websocket/request.rb', line 29 def scheme @scheme end |
Class Method Details
.websocket?(request) ⇒ Boolean
14 15 16 |
# File 'lib/async/websocket/request.rb', line 14 def self.websocket?(request) Array(request.protocol).include?(PROTOCOL) end |
Instance Method Details
#call(connection) ⇒ Object
Send the request to the given connection.
37 38 39 40 41 42 43 44 45 |
# File 'lib/async/websocket/request.rb', line 37 def call(connection) if connection.http1? return UpgradeRequest.new(self, **).call(connection) elsif connection.http2? return ConnectRequest.new(self, **).call(connection) end raise HTTP::Error, "Unsupported HTTP version: #{connection.version}!" end |
#idempotent? ⇒ Boolean
47 48 49 |
# File 'lib/async/websocket/request.rb', line 47 def idempotent? true end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/async/websocket/request.rb', line 51 def to_s "\#<#{self.class} #{@scheme}://#{@authority}: #{@path}>" end |