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();
|
||||
wxString::const_iterator it = s.begin();
|
||||
wxString::const_iterator end = s.end();
|
||||
while ( it != end && wxIsspace(*it) ) ++it;
|
||||
while ( it != end && *it != ';' ) value += *it++;
|
||||
while ( it != end && wxIsspace(*it) )
|
||||
++it;
|
||||
while ( it != end && *it != ';' )
|
||||
value += *it++;
|
||||
value.Trim();
|
||||
if ( it != end ) ++it;
|
||||
if ( it != end )
|
||||
++it;
|
||||
SplitParameters(it, end, parameters);
|
||||
}
|
||||
|
||||
@@ -170,11 +173,15 @@ void wxWebRequest::SplitParameters(const wxString::const_iterator& begin,
|
||||
{
|
||||
pname.clear();
|
||||
pvalue.clear();
|
||||
while ( it != end && wxIsspace(*it) ) ++it;
|
||||
while ( it != end && *it != '=' && *it != ';' ) pname += *it++;
|
||||
while ( it != end && wxIsspace(*it) )
|
||||
++it;
|
||||
while ( it != end && *it != '=' && *it != ';' )
|
||||
pname += *it++;
|
||||
pname.Trim();
|
||||
if ( it != end && *it != ';' ) ++it;
|
||||
while ( it != end && wxIsspace(*it) ) ++it;
|
||||
if ( it != end && *it != ';' )
|
||||
++it;
|
||||
while ( it != end && wxIsspace(*it) )
|
||||
++it;
|
||||
while ( it != end && *it != ';' )
|
||||
{
|
||||
if ( *it == '"' )
|
||||
@@ -185,22 +192,29 @@ void wxWebRequest::SplitParameters(const wxString::const_iterator& begin,
|
||||
if ( *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 == '\\' )
|
||||
{
|
||||
++it;
|
||||
if ( it != end ) pvalue += *it++;
|
||||
if ( it != end )
|
||||
pvalue += *it++;
|
||||
}
|
||||
else pvalue += *it++;
|
||||
else
|
||||
pvalue += *it++;
|
||||
}
|
||||
pvalue.Trim();
|
||||
if ( !pname.empty() ) parameters[pname] = pvalue;
|
||||
if ( it != end ) ++it;
|
||||
if ( !pname.empty() )
|
||||
parameters[pname] = pvalue;
|
||||
if ( it != end )
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +371,9 @@ void wxWebResponse::ReportDataReceived(size_t sizeReceived)
|
||||
m_request.ReportDataReceived(sizeReceived);
|
||||
|
||||
if ( m_request.GetStorage() == wxWebRequest::Storage_File )
|
||||
{
|
||||
m_file.Write(m_readBuffer.GetData(), m_readBuffer.GetDataLen());
|
||||
}
|
||||
else if ( m_request.GetStorage() == wxWebRequest::Storage_None )
|
||||
{
|
||||
wxWebRequestEvent evt(wxEVT_WEBREQUEST_DATA, m_request.GetId(), wxWebRequest::State_Active);
|
||||
|
@@ -254,7 +254,7 @@ void wxWebRequestCURL::Cancel()
|
||||
|
||||
void wxWebRequestCURL::HandleCompletion()
|
||||
{
|
||||
int status = (m_response) ? m_response->GetStatus() : 0;
|
||||
int status = m_response ? m_response->GetStatus() : 0;
|
||||
|
||||
if ( status == 0)
|
||||
SetState(State_Failed, GetError());
|
||||
|
@@ -31,7 +31,7 @@
|
||||
// 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.
|
||||
#ifdef __VISUALC__
|
||||
#pragma comment(lib, "Winhttp")
|
||||
#pragma comment(lib, "winhttp")
|
||||
#endif
|
||||
|
||||
// Define constants potentially missing in old SDKs
|
||||
@@ -99,9 +99,12 @@ static wxString wxWinHTTPQueryHeaderString(HINTERNET hRequest, DWORD dwInfoLevel
|
||||
{
|
||||
wxWCharBuffer resBuf(bufferLen);
|
||||
if ( ::WinHttpQueryHeaders(hRequest, dwInfoLevel, pwszName,
|
||||
resBuf.data(), &bufferLen, WINHTTP_NO_HEADER_INDEX) )
|
||||
resBuf.data(), &bufferLen,
|
||||
WINHTTP_NO_HEADER_INDEX) )
|
||||
{
|
||||
result.assign(resBuf);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -257,7 +260,7 @@ void wxWebRequestWinHTTP::Start()
|
||||
|
||||
int port;
|
||||
if ( !uri.HasPort() )
|
||||
port = (isSecure) ? 443 : 80;
|
||||
port = isSecure ? 443 : 80;
|
||||
else
|
||||
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
|
||||
// Author: Tobias Taschner
|
||||
// Created: 2018-10-25
|
||||
@@ -109,7 +109,7 @@ void wxWebRequestURLSession::Start()
|
||||
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:
|
||||
[NSURL URLWithString:wxCFStringRef(m_url).AsNSString()]];
|
||||
if (m_method.empty())
|
||||
req.HTTPMethod = (m_dataSize) ? @"POST" : @"GET";
|
||||
req.HTTPMethod = m_dataSize ? @"POST" : @"GET";
|
||||
else
|
||||
req.HTTPMethod = wxCFStringRef(m_method).AsNSString();
|
||||
|
||||
@@ -126,7 +126,7 @@ void wxWebRequestURLSession::Start()
|
||||
wxMemoryBuffer memBuf;
|
||||
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];
|
||||
m_task = [[session.GetSession() uploadTaskWithRequest:req fromData:data] retain];
|
||||
}
|
||||
|
Reference in New Issue
Block a user