Add some wxLogTrace() calls to wxWebRequestURLSession code
This is helpful when trying to understand what is going on, especially because CFNETWORK_DIAGNOSTICS, which is supposed to do the same thing at native level, doesn't seem to work (at least under 10.14).
This commit is contained in:
@@ -21,6 +21,9 @@ WX_DECLARE_STRING_HASH_MAP(wxString, wxWebRequestHeaderMap);
|
|||||||
// Default buffer size when a fixed-size buffer must be used.
|
// Default buffer size when a fixed-size buffer must be used.
|
||||||
const int wxWEBREQUEST_BUFFER_SIZE = 64 * 1024;
|
const int wxWEBREQUEST_BUFFER_SIZE = 64 * 1024;
|
||||||
|
|
||||||
|
// Trace mask used for the messages in wxWebRequest code.
|
||||||
|
#define wxTRACE_WEBREQUEST "webrequest"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWebAuthChallengeImpl
|
// wxWebAuthChallengeImpl
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -182,6 +182,8 @@ struct StateEventProcessor
|
|||||||
|
|
||||||
void wxWebRequestImpl::SetState(wxWebRequest::State state, const wxString & failMsg)
|
void wxWebRequestImpl::SetState(wxWebRequest::State state, const wxString & failMsg)
|
||||||
{
|
{
|
||||||
|
wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: state => %d", this, state);
|
||||||
|
|
||||||
m_state = state;
|
m_state = state;
|
||||||
|
|
||||||
// Trigger the event in the main thread
|
// Trigger the event in the main thread
|
||||||
|
@@ -67,6 +67,9 @@
|
|||||||
wxUnusedVar(session);
|
wxUnusedVar(session);
|
||||||
|
|
||||||
wxWebRequestURLSession* request = [self requestForTask:dataTask];
|
wxWebRequestURLSession* request = [self requestForTask:dataTask];
|
||||||
|
|
||||||
|
wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: didReceiveData", request);
|
||||||
|
|
||||||
if (request)
|
if (request)
|
||||||
request->GetResponseImplPtr()->HandleData(data);
|
request->GetResponseImplPtr()->HandleData(data);
|
||||||
}
|
}
|
||||||
@@ -77,9 +80,18 @@
|
|||||||
|
|
||||||
wxWebRequestURLSession* request = [self requestForTask:task];
|
wxWebRequestURLSession* request = [self requestForTask:task];
|
||||||
if (error)
|
if (error)
|
||||||
|
{
|
||||||
|
wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: didCompleteWithError, error=%s",
|
||||||
|
request, wxCFStringRefFromGet([error description]).AsString());
|
||||||
|
|
||||||
request->SetState(wxWebRequest::State_Failed, wxCFStringRefFromGet(error.localizedDescription).AsString());
|
request->SetState(wxWebRequest::State_Failed, wxCFStringRefFromGet(error.localizedDescription).AsString());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: completed successfully", request);
|
||||||
|
|
||||||
request->HandleCompletion();
|
request->HandleCompletion();
|
||||||
|
}
|
||||||
|
|
||||||
// After the task is completed it no longer needs to be mapped
|
// After the task is completed it no longer needs to be mapped
|
||||||
[m_requests removeObjectForKey:task];
|
[m_requests removeObjectForKey:task];
|
||||||
@@ -108,12 +120,13 @@ wxWebRequestURLSession::~wxWebRequestURLSession()
|
|||||||
|
|
||||||
void wxWebRequestURLSession::Start()
|
void wxWebRequestURLSession::Start()
|
||||||
{
|
{
|
||||||
|
wxString method = m_method;
|
||||||
|
if ( method.empty() )
|
||||||
|
method = m_dataSize ? wxASCII_STR("POST") : wxASCII_STR("GET");
|
||||||
|
|
||||||
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:
|
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:
|
||||||
[NSURL URLWithString:wxCFStringRef(m_url).AsNSString()]];
|
[NSURL URLWithString:wxCFStringRef(m_url).AsNSString()]];
|
||||||
if (m_method.empty())
|
req.HTTPMethod = wxCFStringRef(method).AsNSString();
|
||||||
req.HTTPMethod = m_dataSize ? @"POST" : @"GET";
|
|
||||||
else
|
|
||||||
req.HTTPMethod = wxCFStringRef(m_method).AsNSString();
|
|
||||||
|
|
||||||
// Set request headers
|
// Set request headers
|
||||||
for (wxWebRequestHeaderMap::const_iterator it = m_headers.begin(); it != m_headers.end(); ++it)
|
for (wxWebRequestHeaderMap::const_iterator it = m_headers.begin(); it != m_headers.end(); ++it)
|
||||||
@@ -138,6 +151,9 @@ void wxWebRequestURLSession::Start()
|
|||||||
m_task = [[m_sessionImpl.GetSession() dataTaskWithRequest:req] retain];
|
m_task = [[m_sessionImpl.GetSession() dataTaskWithRequest:req] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogTrace(wxTRACE_WEBREQUEST, "Request %p: start \"%s %s\"",
|
||||||
|
this, method, m_url);
|
||||||
|
|
||||||
// The session delegate needs to know which task is wrapped in which request
|
// The session delegate needs to know which task is wrapped in which request
|
||||||
[m_sessionImpl.GetDelegate() registerRequest:this task:m_task];
|
[m_sessionImpl.GetDelegate() registerRequest:this task:m_task];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user