Object
Creates new BasicAuth filter.
# File lib/httpclient/auth.rb, line 214
214: def initialize
215: @cred = nil
216: @auth = {}
217: @challengeable = {}
218: @scheme = "Basic"
219: end
Challenge handler: remember URL for response.
# File lib/httpclient/auth.rb, line 254
254: def challenge(uri, param_str)
255: @challengeable[uri] = true
256: true
257: end
Response handler: returns credential. It sends cred only when a given uri is;
child page of challengeable(got *Authenticate before) uri and,
child page of defined credential
# File lib/httpclient/auth.rb, line 242
242: def get(req)
243: target_uri = req.header.request_uri
244: return nil unless @challengeable.find { |uri, ok|
245: Util.uri_part_of(target_uri, uri) and ok
246: }
247: return @cred if @cred
248: Util.hash_find_value(@auth) { |uri, cred|
249: Util.uri_part_of(target_uri, uri)
250: }
251: end
Resets challenge state. Do not send ’*Authorization’ header until the server sends ’*Authentication’ again.
# File lib/httpclient/auth.rb, line 223
223: def reset_challenge
224: @challengeable.clear
225: end
Set authentication credential. uri == nil for generic purpose (allow to use user/password for any URL).
# File lib/httpclient/auth.rb, line 229
229: def set(uri, user, passwd)
230: if uri.nil?
231: @cred = ["#{user}:#{passwd}"].pack('m').tr("\n", '')
232: else
233: uri = Util.uri_dirname(uri)
234: @auth[uri] = ["#{user}:#{passwd}"].pack('m').tr("\n", '')
235: end
236: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.