diff --git a/libraries/http_request.inc b/libraries/http_request.inc
index 330fc4d..6ac4022 100644
--- a/libraries/http_request.inc
+++ b/libraries/http_request.inc
@@ -241,7 +241,7 @@ function feeds_http_request($url, array $options = array()) {
       $download = curl_init($url);
       curl_setopt($download, CURLOPT_FOLLOWLOCATION, TRUE);
       if (!empty($options['username'])) {
-        curl_setopt($download, CURLOPT_USERPWD, '{' . $options['username'] . '}:{' . $options['password'] . '}');
+        curl_setopt($download, CURLOPT_USERPWD, $options['username'] . ':' . $options['password']);
         curl_setopt($download, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
       }
       curl_setopt($download, CURLOPT_HTTPHEADER, $headers);
diff --git a/tests/http_request.test b/tests/http_request.test
index 8bfab6a..c6b9ec5 100644
--- a/tests/http_request.test
+++ b/tests/http_request.test
@@ -52,6 +52,45 @@ EOF;
   }
 
   /**
+   * Tests fetching data from a protected directory.
+   */
+  public function testProtectedPages() {
+    // Create a directory and put a file in it.
+    $dir = 'public://feeds-protected';
+    file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
+    file_put_contents($dir . '/content.txt', 'A protected document');
+
+    // Create .htpasswd and .htaccess files.
+    file_put_contents($dir . '/.htpasswd', 'Morticia:$apr1$s3SZUBCe$loi5XqSMHJ9CRfsY9GzLW/');
+    $htaccess = "AuthType Basic\nAuthName \"Restricted area\"\nAuthUserFile !path\nrequire valid-user";
+    $htaccess = strtr($htaccess, array(
+      '!path' => drupal_realpath($dir . '/.htpasswd'),
+    ));
+    file_put_contents($dir . '/.htaccess', $htaccess);
+
+    // Create url to file.
+    $url = file_create_url($dir . '/content.txt');
+
+    // Try to access the file without username/password.
+    $result = feeds_http_request($url, array(
+      'cache_http_result' => FALSE,
+    ));
+    // Assert that it was forbidden.
+    $this->assertEqual(401, $result->code);
+    $this->assertNotEqual('A protected document', $result->data);
+
+    // Now access the same with username/password.
+    $result = feeds_http_request($url, array(
+      'username' => 'Morticia',
+      'password' => 'mort',
+      'cache_http_result' => FALSE,
+    ));
+    // And assert that this time the request was successful.
+    $this->assertEqual(200, $result->code);
+    $this->assertEqual('A protected document', $result->data);
+  }
+
+  /**
    * Tests http_request_create_absolute_url().
    */
   public function testHTTPRequestCreateAbsoluteUrl() {
