cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: prompting for password when username is specified in URL

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 18 Jan 2014 22:35:43 +0100 (CET)

On Tue, 14 Jan 2014, Jeremy Lin wrote:

>> The command line tool curl never really parses the URL so it would take
>> quite a lot of work to introduce such a change.
>
> 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?

No, I don't think I would object to 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?

We have done both in the past and it really depends on the details. If you can
re-use code from libcurl without libcurl getting punished for it too much,
then sure that's a feasable option. We have lots of curlx* functions like that
already.

If you can't do it without having to massacre libcurl code, then copying code
is the way. But then it also becomes a matter of code amount. It would feel a
bit unnecessary if there would be vast amounts of code copied over for this
kind of a rather special-case feature.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
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-18