Class: Protocol::HTTP::Request
- Inherits:
-
Object
- Object
- Protocol::HTTP::Request
- Includes:
- Body::Reader
- Defined in:
- lib/protocol/http/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.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(connection) ⇒ Object
Send the request to the given connection.
- #connect? ⇒ Boolean
- #head? ⇒ Boolean
- #idempotent? ⇒ Boolean
-
#initialize(scheme = nil, authority = nil, method = nil, path = nil, version = nil, headers = [], body = nil, protocol = nil) ⇒ Request
constructor
A new instance of Request.
- #to_s ⇒ Object
- #trailers ⇒ Object
Methods included from Body::Reader
#body?, #close, #each, #finish, #read, #save
Constructor Details
#initialize(scheme = nil, authority = nil, method = nil, path = nil, version = nil, headers = [], body = nil, protocol = nil) ⇒ Request
Returns a new instance of Request.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/protocol/http/request.rb', line 31 def initialize(scheme = nil, = nil, method = nil, path = nil, version = nil, headers = [], body = nil, protocol = nil) @scheme = scheme @authority = @method = method @path = path @version = version @headers = headers @body = body @protocol = protocol end |
Instance Attribute Details
#authority ⇒ Object
Returns the value of attribute authority.
43 44 45 |
# File 'lib/protocol/http/request.rb', line 43 def @authority end |
#body ⇒ Object
Returns the value of attribute body.
48 49 50 |
# File 'lib/protocol/http/request.rb', line 48 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
47 48 49 |
# File 'lib/protocol/http/request.rb', line 47 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
44 45 46 |
# File 'lib/protocol/http/request.rb', line 44 def method @method end |
#path ⇒ Object
Returns the value of attribute path.
45 46 47 |
# File 'lib/protocol/http/request.rb', line 45 def path @path end |
#protocol ⇒ Object
Returns the value of attribute protocol.
49 50 51 |
# File 'lib/protocol/http/request.rb', line 49 def protocol @protocol end |
#scheme ⇒ Object
Returns the value of attribute scheme.
42 43 44 |
# File 'lib/protocol/http/request.rb', line 42 def scheme @scheme end |
#version ⇒ Object
Returns the value of attribute version.
46 47 48 |
# File 'lib/protocol/http/request.rb', line 46 def version @version end |
Class Method Details
Instance Method Details
#call(connection) ⇒ Object
Send the request to the given connection.
58 59 60 |
# File 'lib/protocol/http/request.rb', line 58 def call(connection) connection.call(self) end |
#connect? ⇒ Boolean
66 67 68 |
# File 'lib/protocol/http/request.rb', line 66 def connect? @method == Methods::CONNECT end |
#head? ⇒ Boolean
62 63 64 |
# File 'lib/protocol/http/request.rb', line 62 def head? @method == Methods::HEAD end |
#idempotent? ⇒ Boolean
77 78 79 |
# File 'lib/protocol/http/request.rb', line 77 def idempotent? @method != Methods::POST && (@body.nil? || @body.empty?) end |
#to_s ⇒ Object
81 82 83 |
# File 'lib/protocol/http/request.rb', line 81 def to_s "#{@scheme}://#{@authority}: #{@method} #{@path} #{@version}" end |
#trailers ⇒ Object
51 52 53 54 55 |
# File 'lib/protocol/http/request.rb', line 51 def trailers if @headers.respond_to?(:trailers) @headers.trailers end end |