in src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp [286:399]
static void CALLBACK WinHttpSyncLogCallback(HINTERNET hInternet,
DWORD_PTR context,
DWORD dwInternetStatus,
LPVOID statusInformation,
DWORD dwStatusInformationLength)
{
AWS_UNREFERENCED_PARAM(context);
AWS_UNREFERENCED_PARAM(hInternet);
typedef enum
{
MORE_DATA_NULL,
MORE_DATA_STRING,
MORE_DATA_DWORD,
MORE_DATA_HINTERNET,
MORE_DATA_BUFFER,//shall use dwStatusInformationLength
MORE_DATA_ERROR,
MORE_DATA_ERROR_TLS,
}DATA_FLAGS;
struct STATUS_DATA
{
DWORD status;
const char* statusString;
DATA_FLAGS moreDataFlag;
const char* moreDataFormat;
} KNOWN_STATUSES[] = {
{ WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, "Closing the connection to the server.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, "Successfully connected to the server.", MORE_DATA_STRING, "IP address is %S" },
{ WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, "Connecting to the server.", MORE_DATA_STRING, "IP address is %S" },
{ WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, "Successfully closed the connection to the server", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, "Data is available to be retrieved with WinHttpReadData.", MORE_DATA_DWORD, "Data size is %d" },
{ WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, "An HINTERNET handle has been created.", MORE_DATA_HINTERNET, "" },
{ WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, "An HINTERNET handle has been terminated.", MORE_DATA_HINTERNET, "" },
{ WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, "The response header has been received and is available with WinHttpQueryHeaders.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE, "Received an intermediate (100 level) status code message from the server.", MORE_DATA_DWORD, "http status is %d" },
{ WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, "Successfully found the IP address of the server.", MORE_DATA_STRING, "Name resolved is %S" },
{ WINHTTP_CALLBACK_STATUS_READ_COMPLETE, "Data was successfully read from the server.", MORE_DATA_BUFFER, "Buffer size read is %d" },
{ WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, "Waiting for the server to respond to a request.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_REDIRECT, "An HTTP request is about to automatically redirect the request.", MORE_DATA_STRING, "Redirect target is %S" },
{ WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, "An error occurred while sending an HTTP request.", MORE_DATA_ERROR, "An error occurred ... to be formatted ..." },
{ WINHTTP_CALLBACK_STATUS_REQUEST_SENT, "Successfully sent the information request to the server.", MORE_DATA_DWORD, "Sent %d bytes" },
{ WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, "Looking up the IP address of a server name.", MORE_DATA_STRING, "Trying to resolve '%S'" },
{ WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, "Successfully received a response from the server.", MORE_DATA_DWORD, "Received %d bytes" },
{ WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, "One or more errors were encountered while retrieving a Secure Sockets Layer (SSL) certificate from the server.", MORE_DATA_ERROR_TLS, "TO BE CHECKED" },
{ WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, "Sending the information request to the server.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, "The request completed successfully.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, "Data was successfully written to the server.", MORE_DATA_DWORD, "Written %d bytes" },
{ WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, "The connection was successfully closed via a call to WinHttpWebSocketClose.", MORE_DATA_NULL, "" },
{ WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE, "The connection was successfully shut down via a call to WinHttpWebSocketShutdown.", MORE_DATA_NULL, "" }
};
bool found = false;
int i;
for (i = 0; i < sizeof(KNOWN_STATUSES) / sizeof(KNOWN_STATUSES[0]) && !found; i++)
{
if (dwInternetStatus == KNOWN_STATUSES[i].status)
{
struct STATUS_DATA* data = &(KNOWN_STATUSES[i]);
DWORD_PTR dwResult = 0;
DWORD dwError = 0;
DWORD tlsErrorFlags = 0;
static const size_t MORE_DATA_BUFFER_SZ = 1024;
char moreDataBuffer[MORE_DATA_BUFFER_SZ] = "";
switch (data->moreDataFlag)
{
case MORE_DATA_NULL:
break;
case MORE_DATA_STRING:
_snprintf_s(moreDataBuffer, _TRUNCATE, data->moreDataFormat, (wchar_t*)statusInformation);
break;
case MORE_DATA_DWORD:
_snprintf_s(moreDataBuffer, _TRUNCATE, data->moreDataFormat, *((DWORD*)statusInformation));
break;
case MORE_DATA_HINTERNET:
break;
case MORE_DATA_BUFFER:
_snprintf_s(moreDataBuffer, _TRUNCATE, data->moreDataFormat, dwStatusInformationLength);
break;
case MORE_DATA_ERROR:
dwResult = ((WINHTTP_ASYNC_RESULT*)statusInformation)->dwResult;
dwError = ((WINHTTP_ASYNC_RESULT*)statusInformation)->dwError;
GetDataErrorBuffer(moreDataBuffer,
MORE_DATA_BUFFER_SZ,
dwResult,
dwError);
break;
case MORE_DATA_ERROR_TLS:
tlsErrorFlags = *(DWORD*)statusInformation;
GetDataErrorForTlsError(tlsErrorFlags, moreDataBuffer, MORE_DATA_BUFFER_SZ);
break;
default:
_snprintf_s(moreDataBuffer,
_TRUNCATE,
"unknown more data flag %d",
data->moreDataFlag);
break;
}//switch more data
if (moreDataBuffer[0])
{
AWS_LOGSTREAM_TRACE("WinHttp", data->statusString << " " << moreDataBuffer);
}
else
{
AWS_LOGSTREAM_TRACE("WinHttp", data->statusString);
}
found = true;
}//found handler
}
if (!found)
{
AWS_LOGSTREAM_DEBUG("WinHttp", "got unrecognized internet status " << dwInternetStatus);
}
}