From bafbcfa90fd5c6ee18df8d0599305b119803b4fb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 15 Jan 2021 02:56:45 +0100 Subject: [PATCH] Add tracing statements to WinHTTP code too This again can be very useful for debugging. --- src/msw/webrequest_winhttp.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/msw/webrequest_winhttp.cpp b/src/msw/webrequest_winhttp.cpp index 6643bd2099..9aa07a0f3d 100644 --- a/src/msw/webrequest_winhttp.cpp +++ b/src/msw/webrequest_winhttp.cpp @@ -149,6 +149,9 @@ wxWebRequestWinHTTP::HandleCallback(DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) { + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: callback %08x, len=%zu", + this, dwInternetStatus, dwStatusInformationLength); + switch ( dwInternetStatus ) { case WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE: @@ -194,6 +197,8 @@ wxWebRequestWinHTTP::HandleCallback(DWORD dwInternetStatus, void wxWebRequestWinHTTP::WriteData() { + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: writing data", this); + int dataWriteSize = wxWEBREQUEST_BUFFER_SIZE; if ( m_dataWritten + dataWriteSize > m_dataSize ) dataWriteSize = m_dataSize - m_dataWritten; @@ -224,6 +229,8 @@ void wxWebRequestWinHTTP::WriteData() void wxWebRequestWinHTTP::CreateResponse() { + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: creating response", this); + if ( !::WinHttpReceiveResponse(m_request, NULL) ) { SetFailedWithLastError(); @@ -269,6 +276,17 @@ void wxWebRequestWinHTTP::SetFailed(DWORD errorCode) void wxWebRequestWinHTTP::Start() { + wxString method; + if ( !m_method.empty() ) + method = m_method; + else if ( m_dataSize ) + method = "POST"; + else + method = "GET"; + + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: start \"%s %s\"", + this, method, m_url); + // Parse the URL URL_COMPONENTS urlComps; wxZeroMemory(urlComps); @@ -298,14 +316,6 @@ void wxWebRequestWinHTTP::Start() return; } - wxString method; - if ( !m_method.empty() ) - method = m_method; - else if ( m_dataSize ) - method = "POST"; - else - method = "GET"; - wxString objectName(urlComps.lpszUrlPath, urlComps.dwUrlPathLength); if ( urlComps.dwExtraInfoLength ) objectName += "?" + wxString(urlComps.lpszExtraInfo, urlComps.dwExtraInfoLength); @@ -381,6 +391,8 @@ void wxWebRequestWinHTTP::SendRequest() void wxWebRequestWinHTTP::Cancel() { + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: cancelling", this); + SetState(wxWebRequest::State_Cancelled); if ( m_request != NULL ) { @@ -403,6 +415,9 @@ wxWebResponseWinHTTP::wxWebResponseWinHTTP(wxWebRequestWinHTTP& request): !contentLengthStr.ToLongLong(&m_contentLength) ) m_contentLength = -1; + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: receiving %llu bytes", + &request, m_contentLength); + Init(); } @@ -444,6 +459,8 @@ wxString wxWebResponseWinHTTP::GetStatusText() const bool wxWebResponseWinHTTP::ReadData() { + wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: reading data", &m_request); + return ::WinHttpReadData ( m_requestHandle,