Index: openid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openid/openid.inc,v
retrieving revision 1.2.2.4
diff -u -u -r1.2.2.4 openid.inc
--- openid.inc	30 Jan 2008 20:43:20 -0000	1.2.2.4
+++ openid.inc	8 Jun 2008 14:50:18 -0000
@@ -436,4 +436,4 @@
     }
     return $result;
   }
-}
\ No newline at end of file
+}
Index: openid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openid/openid.module,v
retrieving revision 1.2.2.7
diff -u -u -r1.2.2.7 openid.module
--- openid.module	30 Jan 2008 20:43:20 -0000	1.2.2.7
+++ openid.module	8 Jun 2008 14:50:18 -0000
@@ -221,7 +221,6 @@
   include_once drupal_get_path('module', 'openid') .'/openid.inc';
   
   $claimed_id = _openid_normalize($claimed_id); 
-
   $services = openid_discovery($claimed_id);
   if (count($services) == 0) {
     form_set_error('openid_identifier', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.'));
@@ -338,49 +337,49 @@
     // For regular URLs, try Yadis resolution first, then HTML-based discovery
     $headers = array('Accept' => 'application/xrds+xml');
     $result = drupal_http_request($xrds_url, $headers);
+    // We recieved and xrds response, return services found in contents.
+    if (isset($result->headers['Content-Type']) && preg_match("/application\/xrds\+xml/", $result->headers['Content-Type'])) {
+      // Parse XML document to find URL
+      $services = xrds_parse($result->data);
+    }
 
-    if (!isset($result->error)) {
-      if (isset($result->headers['Content-Type']) && preg_match("/application\/xrds\+xml/", $result->headers['Content-Type'])) {
-        // Parse XML document to find URL
-        $services = xrds_parse($result->data);
+    if (empty($services)) {
+      // Fall through, check for an XRDS redirect.
+      $xrds_url = NULL;
+      if (isset($result->headers['X-XRDS-Location'])) {
+        $xrds_url = $result->headers['X-XRDS-Location'];
       }
       else {
-        $xrds_url = NULL;
-        if (isset($result->headers['X-XRDS-Location'])) {
-          $xrds_url = $result->headers['X-XRDS-Location'];
-        }
-        else {
-          // Look for meta http-equiv link in HTML head
-          $xrds_url = _openid_meta_httpequiv('X-XRDS-Location', $result->data);
-        }
-        if (!empty($xrds_url)) {
-          $headers = array('Accept' => 'application/xrds+xml');
-          $xrds_result = drupal_http_request($xrds_url, $headers);
-          if (!isset($xrds_result->error)) {
-            $services = xrds_parse($xrds_result->data);
-          }
-        }
+        // Look for meta http-equiv link in HTML head
+        $xrds_url = _openid_meta_httpequiv('X-XRDS-Location', $result->data);
       }
-
-      // Check for HTML delegation
-      if (count($services) == 0) {
-        // Look for 2.0 links
-        $uri = _openid_link_href('openid2.provider', $result->data);
-        $delegate = _openid_link_href('openid2.local_id', $result->data);
-        $version = 2;
-        
-        // 1.0 links
-        if (empty($uri)) {
-          $uri = _openid_link_href('openid.server', $result->data);
-          $delegate = _openid_link_href('openid.delegate', $result->data);
-          $version = 1;
-        }
-        if (!empty($uri)) {
-          $services[] = array('uri' => $uri, 'delegate' => $delegate, 'version' => $version);
+      drupal_set_message('Location: '. $xrds_url);
+      if (!empty($xrds_url)) {
+        $headers = array('Accept' => 'application/xrds+xml');
+        $xrds_result = drupal_http_request($xrds_url, $headers);
+        if (!isset($xrds_result->error)) {
+          $services =  xrds_parse($xrds_result->data);
         }
       }
     }
+
+    // Fall through, look for delegation links.
+    // Look for 2.0 links
+    $uri = _openid_link_href('openid2.provider', $result->data);
+    $delegate = _openid_link_href('openid2.local_id', $result->data);
+    $version = 2;
+      
+    // 1.0 links
+    if (empty($uri)) {
+      $uri = _openid_link_href('openid.server', $result->data);
+      $delegate = _openid_link_href('openid.delegate', $result->data);
+      $version = 1;
+    }
+    if (!empty($uri)) {
+      $services[] =  array('uri' => $uri, 'delegate' => $delegate, 'version' => $version);
+    }
   }
+  // If we got to here return an empty array to indication that all discovery attempts failed.
   return $services;
 }
 
