diff --git a/lib/url.c b/lib/url.c
index c075541..74259ff 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4131,11 +4131,19 @@ static CURLcode parse_proxy(struct SessionHandle *data,
 
   /* Skip the protocol part if present */
   endofprot = strstr(proxy, "://");
-  if(endofprot)
+  if(endofprot) {
     proxyptr = endofprot+3;
-  else
-    proxyptr = proxy;
-
+    struct SessionHandle *data = conn->data;
+    if ( strncmp(proxy,"socks5",6) == 0)
+	data->set.proxytype = CURLPROXY_SOCKS5;
+    if ( strncmp(proxy,"socks4",6) == 0)
+	data->set.proxytype = CURLPROXY_SOCKS4;
+    if ( strncmp(proxy,"socks4a",7) == 0)
+        data->set.proxytype = CURLPROXY_SOCKS4A;
+    /* Any other xxx:// : change to http proxy */
+  } else {
+    proxyptr = proxy; /* No xxx:// head: It's a HTTP proxy */
+  }
   /* Is there a username and password given in this proxy url? */
   atsign = strchr(proxyptr, '@');
   if(atsign) {


