Class: S3restful::S3::Request
- Inherits:
-
Object
- Object
- S3restful::S3::Request
- Includes:
- Utils
- Defined in:
- lib/s3restful/s3/request.rb
Constant Summary collapse
- VALID_HTTP_METHODS =
[:head, :get, :aget, :put, :delete]
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#options ⇒ Object
Returns the value of attribute options.
-
#response ⇒ Object
Returns the value of attribute response.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #execute ⇒ Object
- #http_class ⇒ Object
-
#initialize(http_method, url, options = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(http_method, url, options = {}) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/s3restful/s3/request.rb', line 10 def initialize(http_method, url, = {}) @options = { :timeout => 10, :retry_count => 4, :headers => {}, :on_error => nil, :on_success => nil, :data => nil, :ssl => { :cert_chain_file => nil, :verify_peer => false } }.update() assert_valid_keys(, :timeout, :on_success, :on_error, :retry_count, :headers, :data, :ssl, :file) @http_method = http_method @url = url validate end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
8 9 10 |
# File 'lib/s3restful/s3/request.rb', line 8 def http_method @http_method end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/s3restful/s3/request.rb', line 8 def @options end |
#response ⇒ Object
Returns the value of attribute response.
8 9 10 |
# File 'lib/s3restful/s3/request.rb', line 8 def response @response end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/s3restful/s3/request.rb', line 8 def url @url end |
Instance Method Details
#execute ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/s3restful/s3/request.rb', line 30 def execute S3restful::Log.debug "Request: #{http_method.to_s.upcase} #{url}" @response = http_class.new(url).send(http_method, :timeout => [:timeout], :head => [:headers], :body => [:data], :ssl => [:ssl], :file => [:file]) @response.errback { error_callback } @response.callback { success_callback } @response end |
#http_class ⇒ Object
39 40 41 |
# File 'lib/s3restful/s3/request.rb', line 39 def http_class EventMachine::HttpRequest end |