Class: Patron::Request
- Inherits:
-
Object
- Object
- Patron::Request
- Defined in:
- lib/patron/request.rb,
ext/patron/session_ext.c
Overview
Represents the information necessary for an HTTP request. This is basically a data object with validation. Not all fields will be used in every request.
Constant Summary collapse
- VALID_ACTIONS =
[:get, :put, :post, :delete, :head, :copy]
- AuthBasic =
INT2FIX(CURLAUTH_BASIC)
- AuthDigest =
INT2FIX(CURLAUTH_DIGEST)
- AuthAny =
INT2FIX(CURLAUTH_ANY)
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#auth_type ⇒ Object
Returns the value of attribute auth_type.
-
#buffer_size ⇒ Object
Returns the value of attribute buffer_size.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#insecure ⇒ Object
Returns the value of attribute insecure.
-
#max_redirects ⇒ Object
Returns the value of attribute max_redirects.
-
#multipart ⇒ Object
Returns the value of attribute multipart.
-
#password ⇒ Object
Returns the value of attribute password.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#proxy_type ⇒ Object
Returns the value of attribute proxy_type.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #action_name ⇒ Object
- #credentials ⇒ Object
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #upload_data ⇒ Object
- #upload_data=(data) ⇒ Object
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
37 38 39 40 41 42 43 |
# File 'lib/patron/request.rb', line 37 def initialize @action = :get @headers = {} @timeout = 0 @connect_timeout = 0 @max_redirects = -1 end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def action @action end |
#auth_type ⇒ Object
Returns the value of attribute auth_type.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def auth_type @auth_type end |
#buffer_size ⇒ Object
Returns the value of attribute buffer_size.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def buffer_size @buffer_size end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def connect_timeout @connect_timeout end |
#file_name ⇒ Object
Returns the value of attribute file_name.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def file_name @file_name end |
#headers ⇒ Object
Returns the value of attribute headers.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def headers @headers end |
#insecure ⇒ Object
Returns the value of attribute insecure.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def insecure @insecure end |
#max_redirects ⇒ Object
Returns the value of attribute max_redirects.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def max_redirects @max_redirects end |
#multipart ⇒ Object
Returns the value of attribute multipart.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def multipart @multipart end |
#password ⇒ Object
Returns the value of attribute password.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def password @password end |
#proxy ⇒ Object
Returns the value of attribute proxy.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def proxy @proxy end |
#proxy_type ⇒ Object
Returns the value of attribute proxy_type.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def proxy_type @proxy_type end |
#timeout ⇒ Object
Returns the value of attribute timeout.
46 47 48 |
# File 'lib/patron/request.rb', line 46 def timeout @timeout end |
#url ⇒ Object
Returns the value of attribute url.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
45 46 47 |
# File 'lib/patron/request.rb', line 45 def username @username end |
Instance Method Details
#action_name ⇒ Object
132 133 134 |
# File 'lib/patron/request.rb', line 132 def action_name @action.to_s.upcase end |
#credentials ⇒ Object
136 137 138 139 |
# File 'lib/patron/request.rb', line 136 def credentials return nil if username.nil? || password.nil? "#{username}:#{password}" end |
#upload_data ⇒ Object
80 81 82 |
# File 'lib/patron/request.rb', line 80 def upload_data @upload_data end |
#upload_data=(data) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/patron/request.rb', line 71 def upload_data=(data) @upload_data = case data when Hash self.multipart ? data : Util.build_query_string_from_hash(data, @action == :post) else data end end |