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
Returns a new instance of Request.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/async/websocket/request.rb', line 33 def initialize(scheme = nil, = nil, path = nil, headers = nil, **, &block) @scheme = scheme @authority = @path = path @headers = headers @options = @body = nil end |
Instance Attribute Details
#authority ⇒ Object
Returns the value of attribute authority.
45 46 47 |
# File 'lib/async/websocket/request.rb', line 45 def @authority end |
#body ⇒ Object
Returns the value of attribute body.
49 50 51 |
# File 'lib/async/websocket/request.rb', line 49 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
47 48 49 |
# File 'lib/async/websocket/request.rb', line 47 def headers @headers end |
#path ⇒ Object
Returns the value of attribute path.
46 47 48 |
# File 'lib/async/websocket/request.rb', line 46 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
44 45 46 |
# File 'lib/async/websocket/request.rb', line 44 def scheme @scheme end |
Class Method Details
.websocket?(request) ⇒ Boolean
29 30 31 |
# File 'lib/async/websocket/request.rb', line 29 def self.websocket?(request) Array(request.protocol).include?(PROTOCOL) end |
Instance Method Details
#call(connection) ⇒ Object
Send the request to the given connection.
52 53 54 55 56 57 58 59 60 |
# File 'lib/async/websocket/request.rb', line 52 def call(connection) if connection.http1? return UpgradeRequest.new(self, **@options).call(connection) elsif connection.http2? return ConnectRequest.new(self, **@options).call(connection) end raise HTTP::Error, "Unsupported HTTP version: #{connection.version}!" end |
#idempotent? ⇒ Boolean
62 63 64 |
# File 'lib/async/websocket/request.rb', line 62 def idempotent? true end |
#to_s ⇒ Object
66 67 68 |
# File 'lib/async/websocket/request.rb', line 66 def to_s "\#<#{self.class} #{@scheme}://#{@authority}: #{@path}>" end |