Class: HttpVanilli::NetHttp::Request
- Defined in:
- lib/http_vanilli/net_http/request.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#original_request ⇒ Object
readonly
Returns the value of attribute original_request.
-
#uri ⇒ Object
(also: #url)
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #body ⇒ Object
- #host ⇒ Object
-
#initialize(http, request, &block) ⇒ Request
constructor
A new instance of Request.
- #to_s ⇒ Object
Methods inherited from Request
Constructor Details
#initialize(http, request, &block) ⇒ Request
Returns a new instance of Request.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/http_vanilli/net_http/request.rb', line 8 def initialize(http,request,&block) @http = http @original_request = request @block = block protocol = http.use_ssl? ? "https" : "http" path = request.path path = Addressable::URI.parse(request.path).request_uri if request.path =~ /^https?:/ @uri = Addressable::URI.parse( "#{protocol}://#{http.address}:#{http.port}#{path}" ) @method = request.method.downcase.to_sym end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/http_vanilli/net_http/request.rb', line 6 def block @block end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/http_vanilli/net_http/request.rb', line 6 def method @method end |
#original_request ⇒ Object (readonly)
Returns the value of attribute original_request.
6 7 8 |
# File 'lib/http_vanilli/net_http/request.rb', line 6 def original_request @original_request end |
#uri ⇒ Object (readonly) Also known as: url
Returns the value of attribute uri.
6 7 8 |
# File 'lib/http_vanilli/net_http/request.rb', line 6 def uri @uri end |
Instance Method Details
#body ⇒ Object
30 31 32 |
# File 'lib/http_vanilli/net_http/request.rb', line 30 def body @original_request.body end |
#host ⇒ Object
24 |
# File 'lib/http_vanilli/net_http/request.rb', line 24 def host; @uri.host end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/http_vanilli/net_http/request.rb', line 26 def to_s "#{@method} #{@uri.to_s}" end |