Prepare additional wxWebRequest backends
This commit is contained in:
@@ -654,11 +654,52 @@
|
||||
// wxMimeTypesManager class
|
||||
#define wxUSE_MIMETYPE 1
|
||||
|
||||
// wxWebRequest backend based on WinHTTP
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 on Windows
|
||||
|
||||
// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION()
|
||||
// here as this file is included from wx/platform.h before they're defined.
|
||||
#if defined(_MSC_VER) || \
|
||||
(defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8))
|
||||
#define wxUSE_WEBREQUEST_WINHTTP 1
|
||||
#else
|
||||
#define wxUSE_WEBREQUEST_WINHTTP 0
|
||||
#endif
|
||||
|
||||
// wxWebRequest backend based on NSURLSession
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1 on macOS 10.9+
|
||||
#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_9) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
|
||||
#define wxUSE_WEBREQUEST_URLSESSION 1
|
||||
#else
|
||||
#define wxUSE_WEBREQUEST_URLSESSION 0
|
||||
#endif
|
||||
|
||||
// wxWebRequest backend based on NSURLSession
|
||||
//
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 0 on Windows and macOS otherwise 1
|
||||
#if defined(__WINDOWS__) || defined(__APPLE__)
|
||||
#define wxUSE_WEBREQUEST_CURL 0
|
||||
#else
|
||||
#define wxUSE_WEBREQUEST_CURL 1
|
||||
#endif
|
||||
|
||||
// wxWebRequest and related classes: This will allow usage of system libraries
|
||||
// for HTTP(S) requests
|
||||
//
|
||||
// Default is 1
|
||||
#if wxUSE_WEBREQUEST_WINHTTP || wxUSE_WEBREQUEST_URLSESSION || wxUSE_WEBREQUEST_CURL
|
||||
#define wxUSE_WEBREQUEST 1
|
||||
#else
|
||||
#define wxUSE_WEBREQUEST 0
|
||||
#endif
|
||||
|
||||
// wxProtocol and related classes: if you want to use either of wxFTP, wxHTTP
|
||||
// or wxURL you need to set this to 1.
|
||||
|
42
include/wx/osx/webrequest_urlsession.h
Normal file
42
include/wx/osx/webrequest_urlsession.h
Normal file
@@ -0,0 +1,42 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/osx/webrequest_urlsession.h
|
||||
// Purpose: wxWebRequest implementation using URLSession
|
||||
// Author: Tobias Taschner
|
||||
// Created: 2018-10-25
|
||||
// Copyright: (c) 2018 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_WEBREQUEST_URLSESSION_H
|
||||
#define _WX_OSX_WEBREQUEST_URLSESSION_H
|
||||
|
||||
#if wxUSE_WEBREQUEST_URLSESSION
|
||||
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSURLSession);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSURLTask);
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebSessionURLSession: public wxWebSession
|
||||
{
|
||||
public:
|
||||
wxWebSessionURLSession();
|
||||
|
||||
~wxWebSessionURLSession();
|
||||
|
||||
wxWebRequest* CreateRequest(const wxString& url, int id = wxID_ANY) wxOVERRIDE;
|
||||
|
||||
private:
|
||||
WX_NSURLSession m_session;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_NET wxWebSessionFactoryURLSession: public wxWebSessionFactory
|
||||
{
|
||||
public:
|
||||
wxWebSession* Create() wxOVERRIDE
|
||||
{ return new wxWebSessionURLSession(); }
|
||||
};
|
||||
|
||||
#endif // wxUSE_WEBREQUEST_URLSESSION
|
||||
|
||||
#endif // _WX_OSX_WEBREQUEST_URLSESSION_H
|
Reference in New Issue
Block a user