Class: HT2P::Client::Request
- Inherits:
-
Object
- Object
- HT2P::Client::Request
- Extended by:
- Forwardable
- Defined in:
- lib/ht2p/client/request.rb
Constant Summary collapse
- METHODS =
%w'get head post put delete options trace connect'
Instance Attribute Summary collapse
-
#header ⇒ Object
(also: #headers)
Returns the value of attribute header.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
-
#initialize(client, params) ⇒ Request
constructor
A new instance of Request.
- #send(body = nil, &block) ⇒ Object
Constructor Details
Instance Attribute Details
#header ⇒ Object Also known as: headers
Returns the value of attribute header.
6 7 8 |
# File 'lib/ht2p/client/request.rb', line 6 def header @header end |
#method ⇒ Object
Returns the value of attribute method.
6 7 8 |
# File 'lib/ht2p/client/request.rb', line 6 def method @method end |
Instance Method Details
#send(body = nil, &block) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ht2p/client/request.rb', line 16 def send(body=nil, &block) @header['content-length'] = body.to_s.size if body @client.write @header.format(@method, @client.uri) @client.write body if body block.call self if block_given? @client.flush HT2P::Client::Response.new @client end |