class OpenID::Yadis::XRI::ProxyResolver
Constants
- DEFAULT_PROXY
Public Class Methods
new(proxy_url=nil)
click to toggle source
# File lib/openid/yadis/xrires.rb, line 18 def initialize(proxy_url=nil) if proxy_url @proxy_url = proxy_url else @proxy_url = DEFAULT_PROXY end @proxy_url += '/' unless @proxy_url.match('/$') end
Public Instance Methods
query(xri)
click to toggle source
# File lib/openid/yadis/xrires.rb, line 45 def query(xri) # these can be query args or http headers, needn't be both. # headers = {'Accept' => 'application/xrds+xml;sep=true'} canonicalID = nil url = self.query_url(xri) begin response = OpenID.fetch(url) rescue raise XRIHTTPError, "Could not fetch #{xri}, #{$!}" end raise XRIHTTPError, "Could not fetch #{xri}" if response.nil? xrds = Yadis::parseXRDS(response.body) canonicalID = Yadis::get_canonical_id(xri, xrds) return canonicalID, Yadis::services(xrds) # TODO: # * If we do get hits for multiple service_types, we're almost # certainly going to have duplicated service entries and # broken priority ordering. end
query_url(xri, service_type=nil)
click to toggle source
# File lib/openid/yadis/xrires.rb, line 28 def query_url(xri, service_type=nil) # URI normal form has a leading xri://, but we need to strip # that off again for the QXRI. This is under discussion for # XRI Resolution WD 11. qxri = XRI.to_uri_normal(xri)[6..-1] hxri = @proxy_url + qxri args = {'_xrd_r' => 'application/xrds+xml'} if service_type args['_xrd_t'] = service_type else # don't perform service endpoint selection args['_xrd_r'] += ';sep=false' end return XRI.append_args(hxri, args) end