Add an optional  parameter to URL helpers base_url() and site_url() (supersedes #2535)
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index d0fab3f..3621963 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -46,13 +46,20 @@
 	 * Create a local URL based on your basepath. Segments can be passed via the
 	 * first parameter either as a string or an array.
 	 *
-	 * @param	string
+	 * @param	string	$uri
+	 * @param	string	$protocol
 	 * @return	string
 	 */
 	function site_url($uri = '')
 	{
-		$CI =& get_instance();
-		return $CI->config->site_url($uri);
+		$site_url = get_instance()->config->site_url($uri);
+
+		if (isset($protocol))
+		{
+			$site_url = $protocol.substr($site_url, strpos($site_url, '://'));
+		}
+
+		return $site_url;
 	}
 }
 
@@ -67,13 +74,20 @@
 	 * Segments can be passed in as a string or an array, same as site_url
 	 * or a URL to a file can be passed in, e.g. to an image file.
 	 *
-	 * @param	string
+	 * @param	string	$uri
+	 * @param	string	$protocol
 	 * @return	string
 	 */
-	function base_url($uri = '')
+	function base_url($uri = '', $protocol = NULL)
 	{
-		$CI =& get_instance();
-		return $CI->config->base_url($uri);
+		$base_url = get_instance()->config->base_url($uri);
+
+		if (isset($protocol))
+		{
+			$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
+		}
+
+		return $base_url;
 	}
 }