cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: prompting for password when username is specified in URL

From: Jeremy Lin <jeremy.lin_at_gmail.com>
Date: Tue, 14 Jan 2014 17:36:47 -0800

On Mon, Jan 13, 2014 at 3:07 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Thu, 9 Jan 2014, Jeremy Lin wrote:
>
> Currently it seems that you need to pass -u to get curl to prompt for a
>> password, so something like 'curl -O sftp://user@example.com/foo.txt'
>> wouldn't prompt for a password, but would end up passing an empty password
>> instead.
>>
>> Is there a good reason for this behavior, or is it just that no one's
>> implemented it yet?
>>
>
> The command line tool curl never really parses the URL so it would take
> quite a lot of work to introduce such a change. But also, I've not really
> seen the need since you can easily provide the name with -u if you want to
> get prompted. Or write a wrapper script that prompts and create the proper
> URL before you pass it to curl!

Yep, I know it doesn't. I'm sure a lot of people wouldn't really care, but
it can be pretty useful when integrating with other programs. For example,
if a program called out to curl to download some file, and the user could
pass an http URL with or without a username/password, it would be nice to
have curl automatically prompt for a password if needed, rather than
forcing every such program to implement its own check and pass -u if
needed. So, would there be any objections if I added such a feature?

libcurl actually already has code that extracts the username and password
from a URL, but it's in a static function. Simply duplicating it in the
tool code would minimize the chances of breaking anything, but of course it
would be nicer to share it between the two if possible. What would be your
preference?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-15