Minor code formatting changes
No real changes at all, just improve layout, consistency etc.
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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,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());
|
||||
|
||||
|
@@ -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