Parent

Files

Patron::Request

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.

Constants

VALID_ACTIONS
AuthBasic
AuthDigest
AuthAny

Attributes

url[RW]
username[RW]
password[RW]
file_name[RW]
proxy[RW]
proxy_type[RW]
auth_type[RW]
insecure[RW]
ignore_content_length[RW]
multipart[RW]
action[R]
timeout[R]
connect_timeout[R]
max_redirects[R]
headers[R]
buffer_size[R]
auth_type[R]

Public Class Methods

new() click to toggle source
    # File lib/patron/request.rb, line 37
37:     def initialize
38:       @action = :get
39:       @headers = {}
40:       @timeout = 0
41:       @connect_timeout = 0
42:       @max_redirects = 1
43:     end

Public Instance Methods

action=(new_action) click to toggle source
    # File lib/patron/request.rb, line 84
84:     def action=(new_action)
85:       if !VALID_ACTIONS.include?(new_action)
86:         raise ArgumentError, "Action must be one of #{VALID_ACTIONS.join(', ')}"
87:       end
88: 
89:       @action = new_action
90:     end
action_name() click to toggle source
     # File lib/patron/request.rb, line 132
132:     def action_name
133:       @action.to_s.upcase
134:     end
auth_type=(type=:basic) click to toggle source

Set the type of authentication to use for this request.

@param [String, Symbol] type - The type of authentication to use for this request, can be one of

  :basic, :digest, or :any

@example

  sess.username = "foo"
  sess.password = "sekrit"
  sess.auth_type = :digest
    # File lib/patron/request.rb, line 58
58:     def auth_type=(type=:basic)
59:       @auth_type = case type
60:       when :basic, "basic"
61:         Request::AuthBasic
62:       when :digest, "digest"
63:         Request::AuthDigest
64:       when :any, "any"
65:         Request::AuthAny
66:       else
67:         raise "#{type.inspect} is an unknown authentication type"
68:       end
69:     end
buffer_size=(buffer_size) click to toggle source
     # File lib/patron/request.rb, line 124
124:     def buffer_size=(buffer_size)
125:       if buffer_size != nil && buffer_size.to_i < 1
126:         raise ArgumentError, "Buffer size must be a positive integer greater than 0 or nil"
127:       end
128: 
129:       @buffer_size = buffer_size != nil ? buffer_size.to_i : nil
130:     end
connect_timeout=(new_timeout) click to toggle source
     # File lib/patron/request.rb, line 100
100:     def connect_timeout=(new_timeout)
101:       if new_timeout && new_timeout.to_i < 1
102:         raise ArgumentError, "Timeout must be a positive integer greater than 0"
103:       end
104: 
105:       @connect_timeout = new_timeout.to_i
106:     end
credentials() click to toggle source
     # File lib/patron/request.rb, line 136
136:     def credentials
137:       return nil if username.nil? || password.nil?
138:       "#{username}:#{password}"
139:     end
headers=(new_headers) click to toggle source
     # File lib/patron/request.rb, line 116
116:     def headers=(new_headers)
117:       if !new_headers.kind_of?(Hash)
118:         raise ArgumentError, "Headers must be a hash"
119:       end
120: 
121:       @headers = new_headers
122:     end
max_redirects=(new_max_redirects) click to toggle source
     # File lib/patron/request.rb, line 108
108:     def max_redirects=(new_max_redirects)
109:       if new_max_redirects.to_i < 1
110:         raise ArgumentError, "Max redirects must be a positive integer, 0 or -1"
111:       end
112: 
113:       @max_redirects = new_max_redirects.to_i
114:     end
timeout=(new_timeout) click to toggle source
    # File lib/patron/request.rb, line 92
92:     def timeout=(new_timeout)
93:       if new_timeout && new_timeout.to_i < 1
94:         raise ArgumentError, "Timeout must be a positive integer greater than 0"
95:       end
96: 
97:       @timeout = new_timeout.to_i
98:     end
upload_data() click to toggle source
    # File lib/patron/request.rb, line 80
80:     def upload_data
81:       @upload_data
82:     end
upload_data=(data) click to toggle source
    # File lib/patron/request.rb, line 71
71:     def upload_data=(data)
72:       @upload_data = case data
73:       when Hash
74:         self.multipart ? data : Util.build_query_string_from_hash(data, @action == :post)
75:       else
76:         data
77:       end
78:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.