diff --git a/httprl.module b/httprl.module
index 61e298b..2a9aa88 100644
--- a/httprl.module
+++ b/httprl.module
@@ -537,6 +537,7 @@ function httprl_set_default_options(array &$options) {
     'chunk_size_write' => 1024,
     'async_connect' => TRUE,
     'ping_db' => 20,
+    'url_encoding' => array(),
   );
 
   // Adjust Time To First Byte Timeout if timeout is large and ttfb is default.
@@ -556,6 +557,16 @@ function httprl_set_default_options(array &$options) {
     'Connection' => 'close',
   );
 
+  // Defaults for url encoding the url.
+  // Use %20 for spaces in the path and in the query string.
+  $options['url_encoding'] += array(
+    'space' => array(),
+  );
+  $options['url_encoding']['space'] += array(
+    'path' => '%20',
+    'query' => '%20',
+  );
+
   // Set referrer to current page.
   if (!isset($options['headers']['Referer']) && !empty($options['referrer'])) {
     if (function_exists('request_uri')) {
@@ -891,9 +902,11 @@ function httprl_basic_auth($uri, &$options) {
  */
 function httprl_build_request_string($uri, $options) {
   // Construct the path to act on.
-  $path = isset($uri['path']) ? $uri['path'] : '/';
+  // Enocde any spaces to be %20.
+  $path = isset($uri['path']) ? str_replace(' ', $options['url_encoding']['space']['path'], $uri['path']) : '/';
   if (isset($uri['query'])) {
-    $path .= '?' . $uri['query'];
+    // Enocde any spaces in the query string to be %20.
+    $path .= '?' . str_replace(' ', $options['url_encoding']['space']['query'], $uri['query']);
   }
 
   // Assemble the request together. HTTP version requires to be a float.
