From 700d6ddea6c8106f3fa9a55d7296d8f80d967184 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 Dec 2020 00:27:09 +0100 Subject: [PATCH] Minor code formatting changes No real changes at all, just improve layout, consistency etc. --- include/wx/msw/webrequest_winhttp.h | 4 +-- include/wx/osx/webrequest_urlsession.h | 8 ++--- include/wx/webrequest_curl.h | 6 ++-- src/common/webrequest.cpp | 48 +++++++++++++++++--------- src/common/webrequest_curl.cpp | 2 +- src/msw/webrequest_winhttp.cpp | 9 +++-- src/osx/webrequest_urlsession.mm | 6 ++-- 7 files changed, 51 insertions(+), 32 deletions(-) diff --git a/include/wx/msw/webrequest_winhttp.h b/include/wx/msw/webrequest_winhttp.h index 11161be5b9..7dd322eb3f 100644 --- a/include/wx/msw/webrequest_winhttp.h +++ b/include/wx/msw/webrequest_winhttp.h @@ -106,7 +106,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebRequestWinHTTP); }; -class WXDLLIMPEXP_NET wxWebSessionWinHTTP: public wxWebSession +class WXDLLIMPEXP_NET wxWebSessionWinHTTP : public wxWebSession { public: wxWebSessionWinHTTP(); @@ -128,7 +128,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebSessionWinHTTP); }; -class WXDLLIMPEXP_NET wxWebSessionFactoryWinHTTP: public wxWebSessionFactory +class WXDLLIMPEXP_NET wxWebSessionFactoryWinHTTP : public wxWebSessionFactory { public: wxWebSession* Create() wxOVERRIDE diff --git a/include/wx/osx/webrequest_urlsession.h b/include/wx/osx/webrequest_urlsession.h index 3e4646907e..1e284885c1 100644 --- a/include/wx/osx/webrequest_urlsession.h +++ b/include/wx/osx/webrequest_urlsession.h @@ -19,7 +19,7 @@ DECLARE_WXCOCOA_OBJC_CLASS(wxWebSessionDelegte); class wxWebSessionURLSession; class wxWebResponseURLSession; -class WXDLLIMPEXP_NET wxWebResponseURLSession: public wxWebResponse +class WXDLLIMPEXP_NET wxWebResponseURLSession : public wxWebResponse { public: wxWebResponseURLSession(wxWebRequest& request, WX_NSURLSessionTask task); @@ -44,7 +44,7 @@ private: WX_NSURLSessionTask m_task; }; -class WXDLLIMPEXP_NET wxWebRequestURLSession: public wxWebRequest +class WXDLLIMPEXP_NET wxWebRequestURLSession : public wxWebRequest { public: wxWebRequestURLSession(wxWebSessionURLSession& session, const wxString& url, int id); @@ -78,7 +78,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebRequestURLSession); }; -class WXDLLIMPEXP_NET wxWebSessionURLSession: public wxWebSession +class WXDLLIMPEXP_NET wxWebSessionURLSession : public wxWebSession { public: wxWebSessionURLSession(); @@ -100,7 +100,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession); }; -class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession: public wxWebSessionFactory +class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession : public wxWebSessionFactory { public: wxWebSession* Create() wxOVERRIDE diff --git a/include/wx/webrequest_curl.h b/include/wx/webrequest_curl.h index 76cc0f56b8..2033b65d10 100644 --- a/include/wx/webrequest_curl.h +++ b/include/wx/webrequest_curl.h @@ -35,7 +35,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebAuthChallengeCURL); }; -class WXDLLIMPEXP_NET wxWebRequestCURL: public wxWebRequest +class WXDLLIMPEXP_NET wxWebRequestCURL : public wxWebRequest { public: wxWebRequestCURL(wxWebSession& session, int id, const wxString& url); @@ -107,7 +107,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebResponseCURL); }; -class WXDLLIMPEXP_NET wxWebSessionCURL: public wxWebSession, private wxThreadHelper +class WXDLLIMPEXP_NET wxWebSessionCURL : public wxWebSession, private wxThreadHelper { public: wxWebSessionCURL(); @@ -144,7 +144,7 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL); }; -class WXDLLIMPEXP_NET wxWebSessionFactoryCURL: public wxWebSessionFactory +class WXDLLIMPEXP_NET wxWebSessionFactoryCURL : public wxWebSessionFactory { public: wxWebSession* Create() wxOVERRIDE diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index 165c29cf39..943146671b 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -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,28 +192,35 @@ 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; } } void wxWebRequest::ProcessStateEvent(State state, const wxString& failMsg) { - if (!IsActiveState(state) && GetResponse()) + if ( !IsActiveState(state) && GetResponse() ) GetResponse()->Finalize(); wxString responseFileName; @@ -248,7 +262,7 @@ wxWebResponse::~wxWebResponse() bool wxWebResponse::Init() { - if (m_request.GetStorage() == wxWebRequest::Storage_File) + if ( m_request.GetStorage() == wxWebRequest::Storage_File ) { wxFileName tmpPrefix; tmpPrefix.AssignDir(m_request.GetSession().GetTempDir()); @@ -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); diff --git a/src/common/webrequest_curl.cpp b/src/common/webrequest_curl.cpp index 746e7455a5..b7280ffb20 100644 --- a/src/common/webrequest_curl.cpp +++ b/src/common/webrequest_curl.cpp @@ -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()); diff --git a/src/msw/webrequest_winhttp.cpp b/src/msw/webrequest_winhttp.cpp index aad68998bc..ce45266be0 100644 --- a/src/msw/webrequest_winhttp.cpp +++ b/src/msw/webrequest_winhttp.cpp @@ -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,8 +99,11 @@ 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()); diff --git a/src/osx/webrequest_urlsession.mm b/src/osx/webrequest_urlsession.mm index c80eac7568..38ec334e02 100644 --- a/src/osx/webrequest_urlsession.mm +++ b/src/osx/webrequest_urlsession.mm @@ -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]; }