cURL / Mailing Lists / curl-library / Single Mail

curl-library

Default to https with a command-line flag

From: Nathaniel Waisbrot <waisbrot_at_whoop.com>
Date: Fri, 17 Jul 2015 16:38:44 -0400

I'd like to be able to select HTTPS as curl's default protocol. I asked about this on Stack Overflow (http://stackoverflow.com/questions/31479263/can-curl-default-to-using-https) and was pointed to https://github.com/bagder/curl/blob/master/lib/url.c#L4051 where I can see that the default is to use HTTP.

The background to this question is that I have a Bash script where I take command-line arguments for curl, add some extra args for them and then invoke curl. I want to ensure that they're talking HTTPS, but I don't know an easy way to parse all the command-line args to discover and rewrite the URL before sending it to curl.

What about allowing HTTPS as the default? I've attached a tiny patch which would do this: if you pass `curl --ssl google.com` then curl will try https://google.com. It's a little odd, because the --ssl flags are for FTP, and under this patch `--ssl`, `--ftp-ssl-control`, and `--ssl-reqd` all produce the same behavior when you don't specify a scheme in the URL and the domain doesn't begin with any of the protocol-indicating names.

Alternatively, what about a command-line flag to specify the protocol (when the URL doesn't include it or when you want to override what's in the URL)? Maybe `curl --use-proto ftp google.com` could be the equivalent of `curl ftp://google.com`.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

  • application/octet-stream attachment: ssl.patch
Received on 2015-07-17