diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc
index ad248ee..02f956d 100644
--- a/plugins/FeedsParser.inc
+++ b/plugins/FeedsParser.inc
@@ -423,7 +423,7 @@ class FeedsEnclosure extends FeedsElement {
     if ($result->code != 200) {
       throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->getUrlEncodedValue(), '!code' => $result->code)));
     }
-    return $result->data;
+    return $result;
   }
 
   /**
@@ -473,14 +473,44 @@ class FeedsEnclosure extends FeedsElement {
           $destination = trim($destination, '/') . '/';
         }
         try {
-          $filename = $this->getLocalValue();
+          // Grab the filename from the sent headers if possible - note: this uses
+          // http_request_get, which returns header indexes in lowercase.
+          $file_download = $this->getContent();
+          if (isset($file_download->headers['content-disposition']) && strpos($file_download->headers['content-disposition'], 'filename')) {
+            // Regexes based off filefield_sources/sources/remote.inc
+            if (preg_match('/.*?filename="(.+?)"/', $file_download->headers['content-disposition'], $matches)) {
+              // Content-Disposition: attachment; filename="FILE NAME HERE"
+              $filename = $matches[1];
+            }
+            elseif (preg_match('/.*?filename=([^; ]+)/', $file_download->headers['content-disposition'], $matches)) {
+              // Content-Disposition: attachment; filename=file.ext
+              $filename = trim($matches[1]);
+            }
+          }
+          else {
+            $filename = basename($this->getLocalValue());
+            $filemime = file_get_mimetype($filename);
+            if ($filemime != $this->mime_type) {
+              include_once DRUPAL_ROOT . "/includes/file.mimetypes.inc";
+              $mapping = file_mimetype_mapping();
+              if ($ext_id = array_search($this->mime_type, $mapping["mimetypes"])) {
+                $extensions = array_keys($mapping["extensions"], $ext_id);
+                foreach ($extensions as $extension) {
+                  if (array_search($extension, $this->allowedExtensions)) {
+                    $filename .= ".$extension";
+                    break;
+                  }
+                }
+              }
+            }
+          }
 
           if (module_exists('transliteration')) {
             require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
             $filename = transliteration_clean_filename($filename);
           }
 
-          $file = file_save_data($this->getContent(), $destination . $filename);
+          $file = file_save_data($file_download->data, $destination . $filename);
         }
         catch (Exception $e) {
           watchdog_exception('Feeds', $e, nl2br(check_plain($e)));
