Minor code formatting changes

No real changes at all, just improve layout, consistency etc.
This commit is contained in:
Vadim Zeitlin
2020-12-13 00:27:09 +01:00
parent f02f8cc8a1
commit 700d6ddea6
7 changed files with 51 additions and 32 deletions

View File

@@ -106,7 +106,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebRequestWinHTTP); wxDECLARE_NO_COPY_CLASS(wxWebRequestWinHTTP);
}; };
class WXDLLIMPEXP_NET wxWebSessionWinHTTP: public wxWebSession class WXDLLIMPEXP_NET wxWebSessionWinHTTP : public wxWebSession
{ {
public: public:
wxWebSessionWinHTTP(); wxWebSessionWinHTTP();
@@ -128,7 +128,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebSessionWinHTTP); wxDECLARE_NO_COPY_CLASS(wxWebSessionWinHTTP);
}; };
class WXDLLIMPEXP_NET wxWebSessionFactoryWinHTTP: public wxWebSessionFactory class WXDLLIMPEXP_NET wxWebSessionFactoryWinHTTP : public wxWebSessionFactory
{ {
public: public:
wxWebSession* Create() wxOVERRIDE wxWebSession* Create() wxOVERRIDE

View File

@@ -19,7 +19,7 @@ DECLARE_WXCOCOA_OBJC_CLASS(wxWebSessionDelegte);
class wxWebSessionURLSession; class wxWebSessionURLSession;
class wxWebResponseURLSession; class wxWebResponseURLSession;
class WXDLLIMPEXP_NET wxWebResponseURLSession: public wxWebResponse class WXDLLIMPEXP_NET wxWebResponseURLSession : public wxWebResponse
{ {
public: public:
wxWebResponseURLSession(wxWebRequest& request, WX_NSURLSessionTask task); wxWebResponseURLSession(wxWebRequest& request, WX_NSURLSessionTask task);
@@ -44,7 +44,7 @@ private:
WX_NSURLSessionTask m_task; WX_NSURLSessionTask m_task;
}; };
class WXDLLIMPEXP_NET wxWebRequestURLSession: public wxWebRequest class WXDLLIMPEXP_NET wxWebRequestURLSession : public wxWebRequest
{ {
public: public:
wxWebRequestURLSession(wxWebSessionURLSession& session, const wxString& url, int id); wxWebRequestURLSession(wxWebSessionURLSession& session, const wxString& url, int id);
@@ -78,7 +78,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebRequestURLSession); wxDECLARE_NO_COPY_CLASS(wxWebRequestURLSession);
}; };
class WXDLLIMPEXP_NET wxWebSessionURLSession: public wxWebSession class WXDLLIMPEXP_NET wxWebSessionURLSession : public wxWebSession
{ {
public: public:
wxWebSessionURLSession(); wxWebSessionURLSession();
@@ -100,7 +100,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession); wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession);
}; };
class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession: public wxWebSessionFactory class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession : public wxWebSessionFactory
{ {
public: public:
wxWebSession* Create() wxOVERRIDE wxWebSession* Create() wxOVERRIDE

View File

@@ -35,7 +35,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebAuthChallengeCURL); wxDECLARE_NO_COPY_CLASS(wxWebAuthChallengeCURL);
}; };
class WXDLLIMPEXP_NET wxWebRequestCURL: public wxWebRequest class WXDLLIMPEXP_NET wxWebRequestCURL : public wxWebRequest
{ {
public: public:
wxWebRequestCURL(wxWebSession& session, int id, const wxString& url); wxWebRequestCURL(wxWebSession& session, int id, const wxString& url);
@@ -107,7 +107,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebResponseCURL); wxDECLARE_NO_COPY_CLASS(wxWebResponseCURL);
}; };
class WXDLLIMPEXP_NET wxWebSessionCURL: public wxWebSession, private wxThreadHelper class WXDLLIMPEXP_NET wxWebSessionCURL : public wxWebSession, private wxThreadHelper
{ {
public: public:
wxWebSessionCURL(); wxWebSessionCURL();
@@ -144,7 +144,7 @@ private:
wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL); wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL);
}; };
class WXDLLIMPEXP_NET wxWebSessionFactoryCURL: public wxWebSessionFactory class WXDLLIMPEXP_NET wxWebSessionFactoryCURL : public wxWebSessionFactory
{ {
public: public:
wxWebSession* Create() wxOVERRIDE wxWebSession* Create() wxOVERRIDE

View File

@@ -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,28 +192,35 @@ 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;
} }
} }
void wxWebRequest::ProcessStateEvent(State state, const wxString& failMsg) void wxWebRequest::ProcessStateEvent(State state, const wxString& failMsg)
{ {
if (!IsActiveState(state) && GetResponse()) if ( !IsActiveState(state) && GetResponse() )
GetResponse()->Finalize(); GetResponse()->Finalize();
wxString responseFileName; wxString responseFileName;
@@ -248,7 +262,7 @@ wxWebResponse::~wxWebResponse()
bool wxWebResponse::Init() bool wxWebResponse::Init()
{ {
if (m_request.GetStorage() == wxWebRequest::Storage_File) if ( m_request.GetStorage() == wxWebRequest::Storage_File )
{ {
wxFileName tmpPrefix; wxFileName tmpPrefix;
tmpPrefix.AssignDir(m_request.GetSession().GetTempDir()); tmpPrefix.AssignDir(m_request.GetSession().GetTempDir());
@@ -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);

View File

@@ -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());

View File

@@ -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());

View File

@@ -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];
} }