mirror of
https://github.com/curl/curl.git
synced 2026-08-24 15:53:32 +03:00
getinfo: provide info which auth was used for HTTP and proxy
CURLINFO_HTTPAUTH_USED and CURLINFO_PROXYAUTH_USED Tested in 590 and 694 Ref: #12668 Idea-by: Ganesh Viswanathan Closes #15450
This commit is contained in:
parent
f3efab1bb4
commit
9d5ecc9613
15 changed files with 409 additions and 9 deletions
|
|
@ -69,6 +69,8 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
|
|||
info->request_size = 0;
|
||||
info->proxyauthavail = 0;
|
||||
info->httpauthavail = 0;
|
||||
info->proxyauthpicked = 0;
|
||||
info->httpauthpicked = 0;
|
||||
info->numconnects = 0;
|
||||
|
||||
free(info->contenttype);
|
||||
|
|
@ -272,6 +274,14 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
|
|||
lptr.to_long = param_longp;
|
||||
*lptr.to_ulong = data->info.proxyauthavail;
|
||||
break;
|
||||
case CURLINFO_HTTPAUTH_USED:
|
||||
lptr.to_long = param_longp;
|
||||
*lptr.to_ulong = data->info.httpauthpicked;
|
||||
break;
|
||||
case CURLINFO_PROXYAUTH_USED:
|
||||
lptr.to_long = param_longp;
|
||||
*lptr.to_ulong = data->info.proxyauthpicked;
|
||||
break;
|
||||
case CURLINFO_OS_ERRNO:
|
||||
*param_longp = data->state.os_errno;
|
||||
break;
|
||||
|
|
|
|||
17
lib/http.c
17
lib/http.c
|
|
@ -530,6 +530,8 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
|
|||
pickhost = pickoneauth(&data->state.authhost, authmask);
|
||||
if(!pickhost)
|
||||
data->state.authproblem = TRUE;
|
||||
else
|
||||
data->info.httpauthpicked = data->state.authhost.picked;
|
||||
if(data->state.authhost.picked == CURLAUTH_NTLM &&
|
||||
conn->httpversion > 11) {
|
||||
infof(data, "Forcing HTTP/1.1 for NTLM");
|
||||
|
|
@ -545,6 +547,9 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
|
|||
authmask & ~CURLAUTH_BEARER);
|
||||
if(!pickproxy)
|
||||
data->state.authproblem = TRUE;
|
||||
else
|
||||
data->info.proxyauthpicked = data->state.authproxy.picked;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -851,12 +856,12 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
|
|||
struct connectdata *conn = data->conn;
|
||||
#ifdef USE_SPNEGO
|
||||
curlnegotiate *negstate = proxy ? &conn->proxy_negotiate_state :
|
||||
&conn->http_negotiate_state;
|
||||
&conn->http_negotiate_state;
|
||||
#endif
|
||||
#if defined(USE_SPNEGO) || \
|
||||
defined(USE_NTLM) || \
|
||||
!defined(CURL_DISABLE_DIGEST_AUTH) || \
|
||||
!defined(CURL_DISABLE_BASIC_AUTH) || \
|
||||
#if defined(USE_SPNEGO) || \
|
||||
defined(USE_NTLM) || \
|
||||
!defined(CURL_DISABLE_DIGEST_AUTH) || \
|
||||
!defined(CURL_DISABLE_BASIC_AUTH) || \
|
||||
!defined(CURL_DISABLE_BEARER_AUTH)
|
||||
|
||||
unsigned long *availp;
|
||||
|
|
@ -987,7 +992,7 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
|
|||
authp->avail |= CURLAUTH_BEARER;
|
||||
if(authp->picked == CURLAUTH_BEARER) {
|
||||
/* We asked for Bearer authentication but got a 40X back
|
||||
anyway, which basically means our token is not valid. */
|
||||
anyway, which basically means our token is not valid. */
|
||||
authp->avail = CURLAUTH_NONE;
|
||||
infof(data, "Authentication problem. Ignoring this.");
|
||||
data->state.authproblem = TRUE;
|
||||
|
|
|
|||
|
|
@ -252,6 +252,12 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
|
|||
break;
|
||||
|
||||
case NTLMSTATE_LAST:
|
||||
/* since this is a little artificial in that this is used without any
|
||||
outgoing auth headers being set, we need to set the bit by force */
|
||||
if(proxy)
|
||||
data->info.proxyauthpicked = CURLAUTH_NTLM;
|
||||
else
|
||||
data->info.httpauthpicked = CURLAUTH_NTLM;
|
||||
Curl_safefree(*allocuserpwd);
|
||||
authp->done = TRUE;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -983,6 +983,8 @@ struct PureInfo {
|
|||
curl_off_t request_size; /* the amount of bytes sent in the request(s) */
|
||||
unsigned long proxyauthavail; /* what proxy auth types were announced */
|
||||
unsigned long httpauthavail; /* what host auth types were announced */
|
||||
unsigned long proxyauthpicked; /* selected proxy auth type */
|
||||
unsigned long httpauthpicked; /* selected host auth type */
|
||||
long numconnects; /* how many new connection did libcurl created */
|
||||
char *contenttype; /* the content type of the object */
|
||||
char *wouldredirect; /* URL this would have been redirected to if asked to */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue