]> granicus.if.org Git - curl/commitdiff
lib: Prefix URLs with lower-case protocol names/schemes
authorMohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
Fri, 8 Jan 2016 22:50:38 +0000 (00:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 11 Jan 2016 22:38:42 +0000 (23:38 +0100)
Before this patch, if a URL does not start with the protocol
name/scheme, effective URLs would be prefixed with upper-case protocol
names/schemes. This behavior might not be expected by library users or
end users.

For example, if `CURLOPT_DEFAULT_PROTOCOL` is set to "https". And the
URL is "hostname/path". The effective URL would be
"HTTPS://hostname/path" instead of "https://hostname/path".

After this patch, effective URLs would be prefixed with a lower-case
protocol name/scheme.

Closes #597

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
lib/url.c
tests/data/test1213

index eaa282a04c73448061b4e7f38e3315ca5ae6e06c..2fd0a12837308d9e0ff34162b2d14ff9c9221b7c 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -5511,6 +5511,7 @@ static CURLcode create_conn(struct SessionHandle *data,
        we're gonna follow a Location: later or... then we need the protocol
        part added so that we have a valid URL. */
     char *reurl;
+    char *ch_lower;
 
     reurl = aprintf("%s://%s", conn->handler->scheme, data->change.url);
 
@@ -5519,6 +5520,10 @@ static CURLcode create_conn(struct SessionHandle *data,
       goto out;
     }
 
+    /* Change protocol prefix to lower-case */
+    for(ch_lower = reurl; *ch_lower != ':'; ch_lower++)
+      *ch_lower = (char)TOLOWER(*ch_lower);
+
     if(data->change.url_alloc) {
       Curl_safefree(data->change.url);
       data->change.url_alloc = FALSE;
index 729a7034dae06537bdb20ecfd667383901bb5f03..4f22f0d92dc539761574c1ef6159d436a47c948b 100644 (file)
@@ -43,7 +43,7 @@ HTTP with proxy and host-only URL
 ^User-Agent:.*
 </strip>
 <protocol>
-GET HTTP://we.want.that.site.com.1213/ HTTP/1.1\r
+GET http://we.want.that.site.com.1213/ HTTP/1.1\r
 Host: we.want.that.site.com.1213\r
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r