Хорошо, это хорошо, потому что статус 407 означает, что прокси требует аутентификации.
Таким образом, вы можете использовать это:
case 407:
// The proxy requires authentication.
printf("The proxy requires authentication. Sending credentials...\n");
// Obtain the supported and preferred schemes.
bResults = WinHttpQueryAuthSchemes(hRequest,
&dwSupportedSchemes,
&dwFirstScheme,
&dwTarget);
// Set the credentials before resending the request.
if(bResults)
dwProxyAuthScheme = ChooseAuthScheme(dwSupportedSchemes);
// If the same credentials are requested twice, abort the
// request. For simplicity, this sample does not check
// for a repeated sequence of status codes.
if(dwLastStatus == 407)
bDone = TRUE;
break;
Функция
DWORD ChooseAuthScheme(DWORD dwSupportedSchemes)
{
// It is the server's responsibility only to accept
// authentication schemes that provide a sufficient
// level of security to protect the servers resources.
//
// The client is also obligated only to use an authentication
// scheme that adequately protects its username and password.
//
// Thus, this sample code does not use Basic authentication
// becaus Basic authentication exposes the client's username
// and password to anyone monitoring the connection.
if(dwSupportedSchemes & WINHTTP_AUTH_SCHEME_NEGOTIATE)
return WINHTTP_AUTH_SCHEME_NEGOTIATE;
else if(dwSupportedSchemes & WINHTTP_AUTH_SCHEME_NTLM)
return WINHTTP_AUTH_SCHEME_NTLM;
else if(dwSupportedSchemes & WINHTTP_AUTH_SCHEME_PASSPORT)
return WINHTTP_AUTH_SCHEME_PASSPORT;
else if(dwSupportedSchemes & WINHTTP_AUTH_SCHEME_DIGEST)
return WINHTTP_AUTH_SCHEME_DIGEST;
else
return 0;
}
Это определяет схему аутентификации ..... и после того, как использовать
bResults = WinHttpSetCredentials(hRequest,
WINHTTP_AUTH_TARGET_SERVER,
dwProxyAuthScheme,
username,
password,
NULL);
Я надеюсь, это помогает ... Я также работаю с ними, чтобы подключиться к микрософт-переводчику с лазурного рынка, так как он переместился туда, и f rom, все старые переводчики bing не собираются получать запросы. И для меня он должен отправить ключ аутентификации через заголовок. Но я думаю, у вас есть имя пользователя и пароль.
Большое спасибо за эту замечательную помощь! –