diff --git a/httprl.module b/httprl.module
index 36edd12..5f46fd3 100755
--- a/httprl.module
+++ b/httprl.module
@@ -646,7 +646,20 @@ function httprl_parse_data(&$result) {
     case 301: // Moved permanently
     case 302: // Moved temporarily
     case 307: // Moved temporarily
-      $location = $result->headers['location'];
+      $location = @parse_url($result->headers['location']);
+      // If location isn't fully qualified URL (as per W3 RFC2616), build one.
+      if (empty($location['scheme']) || empty($location['host'])) {
+        // Get the important parts from the original request.
+        $original_location = @parse_url($result->url);
+        // Assume request is to self if none of this was setup correctly.
+        $location['scheme'] = !empty($location['scheme']) ? $location['scheme'] : $original_location['scheme'];
+        $location['host'] = !empty($location['host']) ? $location['host'] : !empty($original_location['host']) ? $original_location['host'] : $_SERVER['HTTP_HOST'];
+        $location['port'] = !empty($location['port']) ? $location['port'] : !empty($original_location['port']) ? $original_location['port'] : '';
+        $location = httprl_glue_url($location)
+      }
+      else {
+        $location = $result->headers['location'];
+      }
       if ($result->options['max_redirects']) {
         // Redirect to the new location.
         // TODO: Parse cookies from header and send them in the redirect request.
@@ -730,3 +743,33 @@ function httprl_strlen($string) {
     return strlen($string);
   }
 }
+
+/**
+ * Alt to http_build_url().
+ *
+ * @see http://php.net/parse-url#85963
+ *
+ * @param $parsed
+ *   array from parse_url()
+ * @return string
+ *   URI is returned.
+ */
+function httprl_glue_url($parsed) {
+  if (!is_array($parsed)) {
+    return FALSE;
+  }
+
+  $uri = isset($parsed['scheme']) ? $parsed['scheme'] . ':' . ((strtolower($parsed['scheme']) == 'mailto') ? '' : '//') : '';
+  $uri .= isset($parsed['user']) ? $parsed['user'] . (isset($parsed['pass']) ? ':' . $parsed['pass'] : '') . '@' : '';
+  $uri .= isset($parsed['host']) ? $parsed['host'] : '';
+  $uri .= !empty($parsed['port']) ? ':' . $parsed['port'] : '';
+
+  if (isset($parsed['path'])) {
+    $uri .= (substr($parsed['path'], 0, 1) == '/') ? $parsed['path'] : ((!empty($uri) ? '/' : '' ) . $parsed['path']);
+  }
+
+  $uri .= isset($parsed['query']) ? '?' . $parsed['query'] : '';
+  $uri .= isset($parsed['fragment']) ? '#' . $parsed['fragment'] : '';
+
+  return $uri;
+}
