Minor code formatting changes
No real changes at all, just improve layout, consistency etc.
This commit is contained in:
@@ -151,10 +151,13 @@ void wxWebRequest::SplitParameters(const wxString& s, wxString& value,
|
|||||||
parameters.clear();
|
parameters.clear();
|
||||||
wxString::const_iterator it = s.begin();
|
wxString::const_iterator it = s.begin();
|
||||||
wxString::const_iterator end = s.end();
|
wxString::const_iterator end = s.end();
|
||||||
while ( it != end && wxIsspace(*it) ) ++it;
|
while ( it != end && wxIsspace(*it) )
|
||||||
while ( it != end && *it != ';' ) value += *it++;
|
++it;
|
||||||
|
while ( it != end && *it != ';' )
|
||||||
|
value += *it++;
|
||||||
value.Trim();
|
value.Trim();
|
||||||
if ( it != end ) ++it;
|
if ( it != end )
|
||||||
|
++it;
|
||||||
SplitParameters(it, end, parameters);
|
SplitParameters(it, end, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,11 +173,15 @@ void wxWebRequest::SplitParameters(const wxString::const_iterator& begin,
|
|||||||
{
|
{
|
||||||
pname.clear();
|
pname.clear();
|
||||||
pvalue.clear();
|
pvalue.clear();
|
||||||
while ( it != end && wxIsspace(*it) ) ++it;
|
while ( it != end && wxIsspace(*it) )
|
||||||
while ( it != end && *it != '=' && *it != ';' ) pname += *it++;
|
++it;
|
||||||
|
while ( it != end && *it != '=' && *it != ';' )
|
||||||
|
pname += *it++;
|
||||||
pname.Trim();
|
pname.Trim();
|
||||||
if ( it != end && *it != ';' ) ++it;
|
if ( it != end && *it != ';' )
|
||||||
while ( it != end && wxIsspace(*it) ) ++it;
|
++it;
|
||||||
|
while ( it != end && wxIsspace(*it) )
|
||||||
|
++it;
|
||||||
while ( it != end && *it != ';' )
|
while ( it != end && *it != ';' )
|
||||||
{
|
{
|
||||||
if ( *it == '"' )
|
if ( *it == '"' )
|
||||||
@@ -185,22 +192,29 @@ void wxWebRequest::SplitParameters(const wxString::const_iterator& begin,
|
|||||||
if ( *it == '\\' )
|
if ( *it == '\\' )
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
if ( it != end ) pvalue += *it++;
|
if ( it != end )
|
||||||
|
pvalue += *it++;
|
||||||
}
|
}
|
||||||
else pvalue += *it++;
|
else
|
||||||
|
pvalue += *it++;
|
||||||
}
|
}
|
||||||
if ( it != end ) ++it;
|
if ( it != end )
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
else if ( *it == '\\' )
|
else if ( *it == '\\' )
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
if ( it != end ) pvalue += *it++;
|
if ( it != end )
|
||||||
|
pvalue += *it++;
|
||||||
}
|
}
|
||||||
else pvalue += *it++;
|
else
|
||||||
|
pvalue += *it++;
|
||||||
}
|
}
|
||||||
pvalue.Trim();
|
pvalue.Trim();
|
||||||
if ( !pname.empty() ) parameters[pname] = pvalue;
|
if ( !pname.empty() )
|
||||||
if ( it != end ) ++it;
|
parameters[pname] = pvalue;
|
||||||
|
if ( it != end )
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +371,9 @@ void wxWebResponse::ReportDataReceived(size_t sizeReceived)
|
|||||||
m_request.ReportDataReceived(sizeReceived);
|
m_request.ReportDataReceived(sizeReceived);
|
||||||
|
|
||||||
if ( m_request.GetStorage() == wxWebRequest::Storage_File )
|
if ( m_request.GetStorage() == wxWebRequest::Storage_File )
|
||||||
|
{
|
||||||
m_file.Write(m_readBuffer.GetData(), m_readBuffer.GetDataLen());
|
m_file.Write(m_readBuffer.GetData(), m_readBuffer.GetDataLen());
|
||||||
|
}
|
||||||
else if ( m_request.GetStorage() == wxWebRequest::Storage_None )
|
else if ( m_request.GetStorage() == wxWebRequest::Storage_None )
|
||||||
{
|
{
|
||||||
wxWebRequestEvent evt(wxEVT_WEBREQUEST_DATA, m_request.GetId(), wxWebRequest::State_Active);
|
wxWebRequestEvent evt(wxEVT_WEBREQUEST_DATA, m_request.GetId(), wxWebRequest::State_Active);
|
||||||
|
@@ -254,7 +254,7 @@ void wxWebRequestCURL::Cancel()
|
|||||||
|
|
||||||
void wxWebRequestCURL::HandleCompletion()
|
void wxWebRequestCURL::HandleCompletion()
|
||||||
{
|
{
|
||||||
int status = (m_response) ? m_response->GetStatus() : 0;
|
int status = m_response ? m_response->GetStatus() : 0;
|
||||||
|
|
||||||
if ( status == 0)
|
if ( status == 0)
|
||||||
SetState(State_Failed, GetError());
|
SetState(State_Failed, GetError());
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
// For MSVC we can link in the required library explicitly, for the other
|
// For MSVC we can link in the required library explicitly, for the other
|
||||||
// compilers (e.g. MinGW) this needs to be done at makefiles level.
|
// compilers (e.g. MinGW) this needs to be done at makefiles level.
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
#pragma comment(lib, "Winhttp")
|
#pragma comment(lib, "winhttp")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define constants potentially missing in old SDKs
|
// Define constants potentially missing in old SDKs
|
||||||
@@ -99,9 +99,12 @@ static wxString wxWinHTTPQueryHeaderString(HINTERNET hRequest, DWORD dwInfoLevel
|
|||||||
{
|
{
|
||||||
wxWCharBuffer resBuf(bufferLen);
|
wxWCharBuffer resBuf(bufferLen);
|
||||||
if ( ::WinHttpQueryHeaders(hRequest, dwInfoLevel, pwszName,
|
if ( ::WinHttpQueryHeaders(hRequest, dwInfoLevel, pwszName,
|
||||||
resBuf.data(), &bufferLen, WINHTTP_NO_HEADER_INDEX) )
|
resBuf.data(), &bufferLen,
|
||||||
|
WINHTTP_NO_HEADER_INDEX) )
|
||||||
|
{
|
||||||
result.assign(resBuf);
|
result.assign(resBuf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -257,7 +260,7 @@ void wxWebRequestWinHTTP::Start()
|
|||||||
|
|
||||||
int port;
|
int port;
|
||||||
if ( !uri.HasPort() )
|
if ( !uri.HasPort() )
|
||||||
port = (isSecure) ? 443 : 80;
|
port = isSecure ? 443 : 80;
|
||||||
else
|
else
|
||||||
port = wxAtoi(uri.GetPort());
|
port = wxAtoi(uri.GetPort());
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: src/osx/webrequest_urlsession.h
|
// Name: src/osx/webrequest_urlsession.mm
|
||||||
// Purpose: wxWebRequest implementation using URLSession
|
// Purpose: wxWebRequest implementation using URLSession
|
||||||
// Author: Tobias Taschner
|
// Author: Tobias Taschner
|
||||||
// Created: 2018-10-25
|
// Created: 2018-10-25
|
||||||
@@ -109,7 +109,7 @@ void wxWebRequestURLSession::Start()
|
|||||||
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:
|
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:
|
||||||
[NSURL URLWithString:wxCFStringRef(m_url).AsNSString()]];
|
[NSURL URLWithString:wxCFStringRef(m_url).AsNSString()]];
|
||||||
if (m_method.empty())
|
if (m_method.empty())
|
||||||
req.HTTPMethod = (m_dataSize) ? @"POST" : @"GET";
|
req.HTTPMethod = m_dataSize ? @"POST" : @"GET";
|
||||||
else
|
else
|
||||||
req.HTTPMethod = wxCFStringRef(m_method).AsNSString();
|
req.HTTPMethod = wxCFStringRef(m_method).AsNSString();
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ void wxWebRequestURLSession::Start()
|
|||||||
wxMemoryBuffer memBuf;
|
wxMemoryBuffer memBuf;
|
||||||
m_dataStream->Read(memBuf.GetWriteBuf(m_dataSize), m_dataSize);
|
m_dataStream->Read(memBuf.GetWriteBuf(m_dataSize), m_dataSize);
|
||||||
|
|
||||||
// Create NSDAta from memory buffer
|
// Create NSData from memory buffer
|
||||||
NSData* data = [NSData dataWithBytes:memBuf.GetData() length:m_dataSize];
|
NSData* data = [NSData dataWithBytes:memBuf.GetData() length:m_dataSize];
|
||||||
m_task = [[session.GetSession() uploadTaskWithRequest:req fromData:data] retain];
|
m_task = [[session.GetSession() uploadTaskWithRequest:req fromData:data] retain];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user