Bearer token authentication?

2018-03-02 Thread John Hascall
Has any thought been given to the possibility of something along these
lines:


curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER);
curl_easy_setopt(curl, CURLOPT_BEARER_TOKEN, token);

   *or*
curl_easy_setopt(curl, CURLOPT_PASSWORD, token);


because faffing around in the struct curl_slist of headers to
​ ​
replace the "Authorization Bearer *token*" header every time you have
​ ​
a new token
(especially with short-lived tokens like at api.box.com)
​ ​
is annoying
​ (and
smells of an abstraction violation).

Or am I missing some sane way to do it?


John​
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

IPv6 address treated as a DNS name when compiled w/o IPV6 support

2018-01-22 Thread John Hascall via curl-library
[From My Stackoverflow question

]

I am attempting to use curl's CURLOPT_CONNECT_TO option to connect to a
specific address (rather than the result of the DNS lookup of the host part
of the url):

CURL * r_curl = NULL;
struct curl_slist * r_connect = NULL;
char connectStr[128];

if (af == AF_INET) {
sprintf(connectStr, "::%s:", ipAddrString);
} else if (af == AF_INET6) {
/* in [] per https://curl.haxx.se/libcurl/c/CURLOPT_CONNECT_TO.html */
sprintf(connectStr, "::[%s]:", ipAddrString);
}
fprintf(stderr, "DEBUG: connect '%s', url %s\n", connectStr, url);

r_curl = curl_easy_init();
...
r_connect = curl_slist_append(r_connect, connectStr);
curl_easy_setopt(r_curl, CURLOPT_CONNECT_TO, r_connect);
curl_easy_setopt(r_curl, CURLOPT_URL, url);
curl_easy_perform(r_curl);


​Result:

DEBUG: connect '::[2610:130:101:104::2]:', url http://www.iastate.edu/
* Connecting to hostname: 2610:130:101:104::2
* Could not resolve host: 2610:130:101:104::2


​I would like to suggest that returning some sort of error like
CURLE_NO_IPV6_SUPPORT (or at least
CURLE_NOT_BUILT_IN
​) ​
would be more helpful.

However, it is not clear to me whether this should happen on the
curl_easy_setopt
​(​
CURLOPT_CONNECT_TO
​) call or on the ​
curl_easy_perform
​() call.

​
This was with version 7.56.1

John
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html