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 =
CURLAUTH_BASIC
- AuthDigest =
CURLAUTH_DIGEST
- AuthAny =
CURLAUTH_ANY
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#auth_type ⇒ Object
Returns the value of attribute auth_type.
-
#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.
-
#password ⇒ Object
Returns the value of attribute password.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#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.
35 36 37 38 39 40 41 |
# File 'lib/patron/request.rb', line 35 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.
44 45 46 |
# File 'lib/patron/request.rb', line 44 def action @action end |
#auth_type ⇒ Object
Returns the value of attribute auth_type.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def auth_type @auth_type end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
44 45 46 |
# File 'lib/patron/request.rb', line 44 def connect_timeout @connect_timeout end |
#file_name ⇒ Object
Returns the value of attribute file_name.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def file_name @file_name end |
#headers ⇒ Object
Returns the value of attribute headers.
44 45 46 |
# File 'lib/patron/request.rb', line 44 def headers @headers end |
#insecure ⇒ Object
Returns the value of attribute insecure.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def insecure @insecure end |
#max_redirects ⇒ Object
Returns the value of attribute max_redirects.
44 45 46 |
# File 'lib/patron/request.rb', line 44 def max_redirects @max_redirects end |
#password ⇒ Object
Returns the value of attribute password.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def password @password end |
#proxy ⇒ Object
Returns the value of attribute proxy.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def proxy @proxy end |
#timeout ⇒ Object
Returns the value of attribute timeout.
44 45 46 |
# File 'lib/patron/request.rb', line 44 def timeout @timeout end |
#url ⇒ Object
Returns the value of attribute url.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
43 44 45 |
# File 'lib/patron/request.rb', line 43 def username @username end |
Instance Method Details
#action_name ⇒ Object
122 123 124 |
# File 'lib/patron/request.rb', line 122 def action_name @action.to_s.upcase end |
#credentials ⇒ Object
126 127 128 129 |
# File 'lib/patron/request.rb', line 126 def credentials return nil if username.nil? || password.nil? "#{username}:#{password}" end |
#upload_data ⇒ Object
78 79 80 |
# File 'lib/patron/request.rb', line 78 def upload_data @upload_data end |
#upload_data=(data) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/patron/request.rb', line 69 def upload_data=(data) @upload_data = case data when Hash hash_to_string(data) else data end end |