Class: HTTPalooza::Request
- Inherits:
-
Object
- Object
- HTTPalooza::Request
- Defined in:
- lib/httpalooza/request.rb
Overview
Request presents a standard interface for describing an HTTP request that Players can translate into the underlying library’s representation.
Constant Summary collapse
- STANDARD_METHODS =
[:get, :post, :put, :patch, :delete, :options, :head]
Instance Attribute Summary collapse
-
#headers ⇒ Hash
readonly
The request headers.
-
#method ⇒ Symbol
readonly
The HTTP method.
-
#params ⇒ Hash
readonly
The URL parameters.
-
#payload ⇒ String
readonly
The request body.
-
#url ⇒ String
readonly
The URL to request.
Instance Method Summary collapse
-
#initialize(url, method, options = {}) ⇒ Request
constructor
Instantiate a Request.
-
#ssl? ⇒ Boolean
Whether or not the URL is SSL.
Constructor Details
#initialize(url, method, options = {}) ⇒ Request
Instantiate a Request.
26 27 28 29 30 31 32 33 34 |
# File 'lib/httpalooza/request.rb', line 26 def initialize(url, method, = {}) @url = url @method = method @params = [:params] || {} @payload = [:payload] @headers = Rack::Utils::HeaderHash.new([:headers] || {}) normalize_url! end |
Instance Attribute Details
#headers ⇒ Hash (readonly)
Returns the request headers.
7 8 9 |
# File 'lib/httpalooza/request.rb', line 7 def headers @headers end |
#method ⇒ Symbol (readonly)
Returns the HTTP method.
7 8 9 |
# File 'lib/httpalooza/request.rb', line 7 def method @method end |
#params ⇒ Hash (readonly)
Returns the URL parameters.
7 8 9 |
# File 'lib/httpalooza/request.rb', line 7 def params @params end |
#payload ⇒ String (readonly)
Returns the request body.
7 8 9 |
# File 'lib/httpalooza/request.rb', line 7 def payload @payload end |
#url ⇒ String (readonly)
Returns the URL to request.
7 8 9 |
# File 'lib/httpalooza/request.rb', line 7 def url @url end |
Instance Method Details
#ssl? ⇒ Boolean
Returns whether or not the URL is SSL.
37 38 39 |
# File 'lib/httpalooza/request.rb', line 37 def ssl? !!(url.to_s =~ /^https/) end |