gpt4 book ai didi

c - WinHttpSendRequest 和 ERROR_WINHTTP_RESEND_REQUEST

转载 作者:行者123 更新时间:2023-12-04 02:03:44 26 4
gpt4 key购买 nike

调用 WinHttpSendRequest 后 GetLastError() 是否可能返回 ERROR_WINHTTP_RESEND_REQUEST?

WinHttpSendRequest 的文档:

ERROR_WINHTTP_RESEND_REQUEST
The application must call WinHttpSendRequest again due to a redirect or authentication challenge. Windows Server 2003 with SP1, Windows XP with SP2 and Windows 2000:  This error is not supported.

但是来自 MSDN 的示例(WinHTTP 中的身份验证)会在 WinHttpReceiveResponse 之后检查此值。

最佳答案

But samples from MSDN (Authentication in WinHTTP) checks for this value after WinHttpReceiveResponse.

乍一看the sample可能看起来像那样。但是,如果您仔细观察,该示例实际上会检查 ERROR_WINHTTP_RESEND_REQUEST if either WinHttpSendRequest() WinHttpReceiveResponse () 失败:

// Send a request.
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0,
WINHTTP_NO_REQUEST_DATA,
0,
0,
0 );

// End the request.
if( bResults )
bResults = WinHttpReceiveResponse( hRequest, NULL );

// Resend the request in case of
// ERROR_WINHTTP_RESEND_REQUEST error.
if( !bResults && GetLastError( ) == ERROR_WINHTTP_RESEND_REQUEST)
continue;

如果 WinHttpSendRequest() 返回 FALSE,将跳过对 WinHttpReceiveResponse() 的调用并调用 GetLastError() 将检查 ERROR_WINHTTP_RESEND_REQUEST。此代码位于 while 循环内,因此 continue 语句将导致循环的剩余部分被跳过,因此 WinHttpSendRequest() 将是再次调用。

结论:样本与引用文档一致。

关于c - WinHttpSendRequest 和 ERROR_WINHTTP_RESEND_REQUEST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45330858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com