Class: PollEverywhere::HTTP::Request
- Inherits:
-
Struct
- Object
- Struct
- PollEverywhere::HTTP::Request
- Defined in:
- lib/polleverywhere/http.rb
Overview
Simple HTTP request/response objects for our adapter and DSL
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
12 13 14 |
# File 'lib/polleverywhere/http.rb', line 12 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
12 13 14 |
# File 'lib/polleverywhere/http.rb', line 12 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method
12 13 14 |
# File 'lib/polleverywhere/http.rb', line 12 def method @method end |
#url ⇒ Object
Returns the value of attribute url
12 13 14 |
# File 'lib/polleverywhere/http.rb', line 12 def url @url end |
Instance Method Details
#to_curl ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/polleverywhere/http.rb', line 13 def to_curl case method.to_s when /^put|post$/i %(curl -X #{method.to_s.upcase} #{headers.map{|h,v| %(-H "#{h}: #{v}")}.join(" ")} -d "#{body.gsub(/[!"`'\n]/){|m| "\\#{m}" }}" "#{url}") when /^get$/i %(curl #{headers.map{|h,v| %(-H "#{h}: #{v}")}.join(" ")} "#{url}") else %(curl -X #{method.to_s.upcase} #{headers.map{|h,v| %(-H "#{h}: #{v}")}.join(" ")} "#{url}") end end |