diff --git a/Makefile.in b/Makefile.in index b1d92f55df..a309da4ded 100644 --- a/Makefile.in +++ b/Makefile.in @@ -546,6 +546,7 @@ ALL_BASE_HEADERS = \ wx/socket.h \ wx/url.h \ wx/webrequest.h \ + wx/webrequest_curl.h \ wx/xml/xml.h \ wx/xtixml.h ALL_HEADERS = \ @@ -766,6 +767,7 @@ ALL_PORTS_BASE_HEADERS = \ wx/socket.h \ wx/url.h \ wx/webrequest.h \ + wx/webrequest_curl.h \ wx/xml/xml.h \ wx/xtixml.h ALL_BASE_SOURCES = \ @@ -916,9 +918,11 @@ ALL_BASE_SOURCES = \ src/common/socket.cpp \ src/common/url.cpp \ src/common/webrequest.cpp \ + src/common/webrequest_curl.cpp \ src/common/socketiohandler.cpp \ src/unix/sockunix.cpp \ src/osx/core/sockosx.cpp \ + src/osx/webrequest_urlsession.mm \ src/msw/sockmsw.cpp \ src/msw/urlmsw.cpp \ src/msw/webrequest_winhttp.cpp \ @@ -1060,6 +1064,7 @@ MONODLL_OBJECTS = \ monodll_socket.o \ monodll_url.o \ monodll_webrequest.o \ + monodll_webrequest_curl.o \ $(__NET_PLATFORM_SRC_OBJECTS) \ $(__MONOLIB_GUI_SRC_OBJECTS) \ monodll_xml.o \ @@ -1203,6 +1208,7 @@ MONOLIB_OBJECTS = \ monolib_socket.o \ monolib_url.o \ monolib_webrequest.o \ + monolib_webrequest_curl.o \ $(__NET_PLATFORM_SRC_OBJECTS_1) \ $(__MONOLIB_GUI_SRC_OBJECTS_1) \ monolib_xml.o \ @@ -1445,6 +1451,12 @@ NETDLL_CXXFLAGS = $(__netdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) $(__INC_REGEX_p) \ $(__INC_EXPAT_p) -DwxUSE_GUI=0 -DWXUSINGDLL -DWXMAKINGDLL_NET $(PIC_FLAG) \ $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS) +NETDLL_OBJCXXFLAGS = $(__netdll_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \ + $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -DWXBUILDING $(__INC_TIFF_BUILD_p) \ + $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \ + $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 -DWXUSINGDLL \ + -DWXMAKINGDLL_NET $(PIC_FLAG) $(CPPFLAGS) $(OBJCXXFLAGS) NETDLL_OBJECTS = \ $(__netdll___win32rc) \ netdll_fs_inet.o \ @@ -1458,6 +1470,7 @@ NETDLL_OBJECTS = \ netdll_socket.o \ netdll_url.o \ netdll_webrequest.o \ + netdll_webrequest_curl.o \ $(__NET_PLATFORM_SRC_OBJECTS_2) NETDLL_ODEP = $(_____pch_wxprec_netdll_wx_wxprec_h_gch___depname) NETLIB_CXXFLAGS = $(__netlib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ @@ -1465,6 +1478,11 @@ NETLIB_CXXFLAGS = $(__netlib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__THREAD_DEFINE_p) -DWXBUILDING $(__INC_TIFF_BUILD_p) $(__INC_TIFF_p) \ $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) $(__INC_REGEX_p) \ $(__INC_EXPAT_p) -DwxUSE_GUI=0 $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS) +NETLIB_OBJCXXFLAGS = $(__netlib_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \ + $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -DWXBUILDING $(__INC_TIFF_BUILD_p) \ + $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \ + $(__INC_REGEX_p) $(__INC_EXPAT_p) -DwxUSE_GUI=0 $(CPPFLAGS) $(OBJCXXFLAGS) NETLIB_OBJECTS = \ netlib_fs_inet.o \ netlib_ftp.o \ @@ -1477,6 +1495,7 @@ NETLIB_OBJECTS = \ netlib_socket.o \ netlib_url.o \ netlib_webrequest.o \ + netlib_webrequest_curl.o \ $(__NET_PLATFORM_SRC_OBJECTS_3) NETLIB_ODEP = $(_____pch_wxprec_netlib_wx_wxprec_h_gch___depname) COREDLL_CFLAGS = $(__coredll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ @@ -4233,9 +4252,12 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS = \ @COND_PLATFORM_WIN32_1@ = monodll_msw_main.o monodll_volume.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \ @COND_TOOLKIT_OSX_COCOA@ = monodll_cocoa_power.o monodll_cocoa_utils.o -@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS \ -@COND_PLATFORM_MACOSX_1@ = monodll_socketiohandler.o monodll_sockunix.o \ -@COND_PLATFORM_MACOSX_1@ monodll_sockosx.o +COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS = \ + monodll_socketiohandler.o \ + monodll_sockunix.o \ + monodll_sockosx.o \ + monodll_webrequest_urlsession.o +@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS = $(COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS) @COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS = \ @COND_PLATFORM_UNIX_1@ monodll_socketiohandler.o monodll_sockunix.o @COND_PLATFORM_WIN32_1@__NET_PLATFORM_SRC_OBJECTS = \ @@ -6212,9 +6234,12 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 = \ @COND_PLATFORM_WIN32_1@ = monolib_msw_main.o monolib_volume.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \ @COND_TOOLKIT_OSX_COCOA@ = monolib_cocoa_power.o monolib_cocoa_utils.o -@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_1 \ -@COND_PLATFORM_MACOSX_1@ = monolib_socketiohandler.o monolib_sockunix.o \ -@COND_PLATFORM_MACOSX_1@ monolib_sockosx.o +COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_1 = \ + monolib_socketiohandler.o \ + monolib_sockunix.o \ + monolib_sockosx.o \ + monolib_webrequest_urlsession.o +@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_1 = $(COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_1) @COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_1 = \ @COND_PLATFORM_UNIX_1@ monolib_socketiohandler.o monolib_sockunix.o @COND_PLATFORM_WIN32_1@__NET_PLATFORM_SRC_OBJECTS_1 \ @@ -8393,9 +8418,12 @@ COND_USE_SOVERSOLARIS_1___netdll___so_symlinks_uninst_cmd = rm -f \ $(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) @COND_USE_SOVERSOLARIS_1@__netdll___so_symlinks_uninst_cmd = $(COND_USE_SOVERSOLARIS_1___netdll___so_symlinks_uninst_cmd) @COND_PLATFORM_WIN32_1@__netdll___win32rc = netdll_version_rc.o -@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_2 \ -@COND_PLATFORM_MACOSX_1@ = netdll_socketiohandler.o netdll_sockunix.o \ -@COND_PLATFORM_MACOSX_1@ netdll_sockosx.o +COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_2 = \ + netdll_socketiohandler.o \ + netdll_sockunix.o \ + netdll_sockosx.o \ + netdll_webrequest_urlsession.o +@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_2 = $(COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_2) @COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_2 = \ @COND_PLATFORM_UNIX_1@ netdll_socketiohandler.o netdll_sockunix.o @COND_PLATFORM_WIN32_1@__NET_PLATFORM_SRC_OBJECTS_2 \ @@ -8411,9 +8439,12 @@ COND_MONOLITHIC_0_SHARED_0___netlib___depname = \ @COND_ICC_PCH_1@ ./.pch/wxprec_netlib/wx/wxprec.h.gch @COND_USE_PCH_1@_____pch_wxprec_netlib_wx_wxprec_h_gch___depname \ @COND_USE_PCH_1@ = ./.pch/wxprec_netlib/wx/wxprec.h.gch -@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_3 \ -@COND_PLATFORM_MACOSX_1@ = netlib_socketiohandler.o netlib_sockunix.o \ -@COND_PLATFORM_MACOSX_1@ netlib_sockosx.o +COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_3 = \ + netlib_socketiohandler.o \ + netlib_sockunix.o \ + netlib_sockosx.o \ + netlib_webrequest_urlsession.o +@COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_3 = $(COND_PLATFORM_MACOSX_1___NET_PLATFORM_SRC_OBJECTS_3) @COND_PLATFORM_UNIX_1@__NET_PLATFORM_SRC_OBJECTS_3 = \ @COND_PLATFORM_UNIX_1@ netlib_socketiohandler.o netlib_sockunix.o @COND_PLATFORM_WIN32_1@__NET_PLATFORM_SRC_OBJECTS_3 \ @@ -15923,6 +15954,9 @@ monodll_url.o: $(srcdir)/src/common/url.cpp $(MONODLL_ODEP) monodll_webrequest.o: $(srcdir)/src/common/webrequest.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/webrequest.cpp +monodll_webrequest_curl.o: $(srcdir)/src/common/webrequest_curl.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/webrequest_curl.cpp + monodll_sockmsw.o: $(srcdir)/src/msw/sockmsw.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/sockmsw.cpp @@ -15935,6 +15969,9 @@ monodll_webrequest_winhttp.o: $(srcdir)/src/msw/webrequest_winhttp.cpp $(MONODLL monodll_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp +monodll_webrequest_urlsession.o: $(srcdir)/src/osx/webrequest_urlsession.mm $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/webrequest_urlsession.mm + monodll_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(MONODLL_ODEP) $(CCC) -c -o $@ $(MONODLL_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c @@ -21185,6 +21222,9 @@ monolib_url.o: $(srcdir)/src/common/url.cpp $(MONOLIB_ODEP) monolib_webrequest.o: $(srcdir)/src/common/webrequest.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/webrequest.cpp +monolib_webrequest_curl.o: $(srcdir)/src/common/webrequest_curl.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/webrequest_curl.cpp + monolib_sockmsw.o: $(srcdir)/src/msw/sockmsw.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/sockmsw.cpp @@ -21197,6 +21237,9 @@ monolib_webrequest_winhttp.o: $(srcdir)/src/msw/webrequest_winhttp.cpp $(MONOLIB monolib_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp +monolib_webrequest_urlsession.o: $(srcdir)/src/osx/webrequest_urlsession.mm $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/webrequest_urlsession.mm + monolib_gtk_eggtrayicon.o: $(srcdir)/src/gtk/eggtrayicon.c $(MONOLIB_ODEP) $(CCC) -c -o $@ $(MONOLIB_CFLAGS) $(srcdir)/src/gtk/eggtrayicon.c @@ -27017,6 +27060,9 @@ netdll_url.o: $(srcdir)/src/common/url.cpp $(NETDLL_ODEP) netdll_webrequest.o: $(srcdir)/src/common/webrequest.cpp $(NETDLL_ODEP) $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/common/webrequest.cpp +netdll_webrequest_curl.o: $(srcdir)/src/common/webrequest_curl.cpp $(NETDLL_ODEP) + $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/common/webrequest_curl.cpp + netdll_sockmsw.o: $(srcdir)/src/msw/sockmsw.cpp $(NETDLL_ODEP) $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/msw/sockmsw.cpp @@ -27029,6 +27075,9 @@ netdll_webrequest_winhttp.o: $(srcdir)/src/msw/webrequest_winhttp.cpp $(NETDLL_O netdll_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(NETDLL_ODEP) $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp +netdll_webrequest_urlsession.o: $(srcdir)/src/osx/webrequest_urlsession.mm $(NETDLL_ODEP) + $(CXXC) -c -o $@ $(NETDLL_OBJCXXFLAGS) $(srcdir)/src/osx/webrequest_urlsession.mm + @COND_PLATFORM_UNIX_1@netdll_socketiohandler.o: $(srcdir)/src/common/socketiohandler.cpp $(NETDLL_ODEP) @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETDLL_CXXFLAGS) $(srcdir)/src/common/socketiohandler.cpp @@ -27074,6 +27123,9 @@ netlib_url.o: $(srcdir)/src/common/url.cpp $(NETLIB_ODEP) netlib_webrequest.o: $(srcdir)/src/common/webrequest.cpp $(NETLIB_ODEP) $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/webrequest.cpp +netlib_webrequest_curl.o: $(srcdir)/src/common/webrequest_curl.cpp $(NETLIB_ODEP) + $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/webrequest_curl.cpp + netlib_sockmsw.o: $(srcdir)/src/msw/sockmsw.cpp $(NETLIB_ODEP) $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/msw/sockmsw.cpp @@ -27086,6 +27138,9 @@ netlib_webrequest_winhttp.o: $(srcdir)/src/msw/webrequest_winhttp.cpp $(NETLIB_O netlib_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(NETLIB_ODEP) $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp +netlib_webrequest_urlsession.o: $(srcdir)/src/osx/webrequest_urlsession.mm $(NETLIB_ODEP) + $(CXXC) -c -o $@ $(NETLIB_OBJCXXFLAGS) $(srcdir)/src/osx/webrequest_urlsession.mm + @COND_PLATFORM_UNIX_1@netlib_socketiohandler.o: $(srcdir)/src/common/socketiohandler.cpp $(NETLIB_ODEP) @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(NETLIB_CXXFLAGS) $(srcdir)/src/common/socketiohandler.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 66ac82af7b..0c6778fca6 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -751,6 +751,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/core/sockosx.cpp + src/osx/webrequest_urlsession.mm @@ -775,6 +776,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/socket.cpp src/common/url.cpp src/common/webrequest.cpp + src/common/webrequest_curl.cpp wx/fs_inet.h @@ -789,6 +791,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/socket.h wx/url.h wx/webrequest.h + wx/webrequest_curl.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 54659bf217..5bcef6950b 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -661,6 +661,11 @@ set(NET_UNIX_SRC set(NET_OSX_SRC src/osx/core/sockosx.cpp + src/osx/webrequest_urlsession.mm +) + +set(NET_OSX_HDR + wx/osx/webrequest_urlsession.h ) set(NET_WIN32_SRC @@ -685,6 +690,7 @@ set(NET_CMN_SRC src/common/socket.cpp src/common/url.cpp src/common/webrequest.cpp + src/common/webrequest_curl.cpp ) set(NET_CMN_HDR @@ -700,6 +706,7 @@ set(NET_CMN_HDR wx/socket.h wx/url.h wx/webrequest.h + wx/webrequest_curl.h ) set(QA_SRC diff --git a/build/cmake/lib/net/CMakeLists.txt b/build/cmake/lib/net/CMakeLists.txt index fa0af82227..c19c24c092 100644 --- a/build/cmake/lib/net/CMakeLists.txt +++ b/build/cmake/lib/net/CMakeLists.txt @@ -26,7 +26,7 @@ wx_add_library(net IS_BASE ${NET_FILES}) if(WIN32) wx_lib_link_libraries(net PRIVATE ws2_32) - if(wxUSE_WEBREQUEST) + if(wxUSE_WEBREQUEST_WINHTTP) wx_lib_link_libraries(net PRIVATE Winhttp) endif() endif() diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 155ca66a35..9d3852521e 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -146,7 +146,19 @@ wx_option(wxUSE_TEXTBUFFER "use wxTextBuffer class") wx_option(wxUSE_TEXTFILE "use wxTextFile class") wx_option(wxUSE_TIMER "use wxTimer class") wx_option(wxUSE_VARIANT "use wxVariant class") + +# WebRequest options wx_option(wxUSE_WEBREQUEST "use wxWebRequest class") +if(WIN32) + wx_option(wxUSE_WEBREQUEST_WINHTTP "use wxWebRequest WinHTTP backend") +endif() +if(APPLE) + wx_option(wxUSE_WEBREQUEST_URLSESSION "use wxWebRequest URLSession backend") +endif() +set(wxUSE_WEBREQUEST_CURL_DEFAULT OFF) +#TODO: determine wxUSE_WEBREQUEST_CURL_DEFAULT (based) +wx_option(wxUSE_WEBREQUEST_CURL "use wxWebRequest libcurl backend" ${wxUSE_WEBREQUEST_CURL_DEFAULT}) + wx_option(wxUSE_ZIPSTREAM "use wxZip streams") # URL-related classes diff --git a/build/cmake/setup.h.in b/build/cmake/setup.h.in index 7c06dd28e2..b3e964f146 100644 --- a/build/cmake/setup.h.in +++ b/build/cmake/setup.h.in @@ -299,7 +299,31 @@ #cmakedefine01 wxUSE_MIMETYPE + +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) +#cmakedefine01 wxUSE_WEBREQUEST_WINHTTP +#else +#cmakedefine01 wxUSE_WEBREQUEST_WINHTTP +#endif + +#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_9) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#cmakedefine01 wxUSE_WEBREQUEST_URLSESSION +#else +#cmakedefine01 wxUSE_WEBREQUEST_URLSESSION +#endif + +#if defined(__WINDOWS__) || defined(__APPLE__) +#cmakedefine01 wxUSE_WEBREQUEST_CURL +#else +#cmakedefine01 wxUSE_WEBREQUEST_CURL +#endif + +#if wxUSE_WEBREQUEST_WINHTTP || wxUSE_WEBREQUEST_URLSESSION || wxUSE_WEBREQUEST_CURL #cmakedefine01 wxUSE_WEBREQUEST +#else +#cmakedefine01 wxUSE_WEBREQUEST +#endif #cmakedefine01 wxUSE_PROTOCOL diff --git a/build/files b/build/files index 5a0ebe658c..eeee55a364 100644 --- a/build/files +++ b/build/files @@ -678,6 +678,9 @@ NET_UNIX_SRC = NET_OSX_SRC = src/osx/core/sockosx.cpp + src/osx/webrequest_urlsession.mm +NET_OSX_HDR = + wx/osx/webrequest_urlsession.h NET_WIN32_SRC = src/msw/sockmsw.cpp @@ -698,6 +701,7 @@ NET_CMN_SRC = src/common/socket.cpp src/common/url.cpp src/common/webrequest.cpp + src/common/webrequest_curl.cpp NET_CMN_HDR = wx/fs_inet.h wx/protocol/file.h @@ -711,6 +715,7 @@ NET_CMN_HDR = wx/socket.h wx/url.h wx/webrequest.h + wx/webrequest_curl.h # wxQA (non GUI library) diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index c9ccf9df3c..4e2d3249d1 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -494,6 +494,7 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_socket.obj \ $(OBJS)\monodll_url.obj \ $(OBJS)\monodll_webrequest.obj \ + $(OBJS)\monodll_webrequest_curl.obj \ $(OBJS)\monodll_sockmsw.obj \ $(OBJS)\monodll_urlmsw.obj \ $(OBJS)\monodll_webrequest_winhttp.obj \ @@ -648,6 +649,7 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_socket.obj \ $(OBJS)\monolib_url.obj \ $(OBJS)\monolib_webrequest.obj \ + $(OBJS)\monolib_webrequest_curl.obj \ $(OBJS)\monolib_sockmsw.obj \ $(OBJS)\monolib_urlmsw.obj \ $(OBJS)\monolib_webrequest_winhttp.obj \ @@ -942,6 +944,7 @@ NETDLL_OBJECTS = \ $(OBJS)\netdll_socket.obj \ $(OBJS)\netdll_url.obj \ $(OBJS)\netdll_webrequest.obj \ + $(OBJS)\netdll_webrequest_curl.obj \ $(OBJS)\netdll_sockmsw.obj \ $(OBJS)\netdll_urlmsw.obj \ $(OBJS)\netdll_webrequest_winhttp.obj @@ -966,6 +969,7 @@ NETLIB_OBJECTS = \ $(OBJS)\netlib_socket.obj \ $(OBJS)\netlib_url.obj \ $(OBJS)\netlib_webrequest.obj \ + $(OBJS)\netlib_webrequest_curl.obj \ $(OBJS)\netlib_sockmsw.obj \ $(OBJS)\netlib_urlmsw.obj \ $(OBJS)\netlib_webrequest_winhttp.obj @@ -6793,6 +6797,9 @@ $(OBJS)\monodll_url.obj: ..\..\src\common\url.cpp $(OBJS)\monodll_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\monodll_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\monodll_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -9345,6 +9352,9 @@ $(OBJS)\monolib_url.obj: ..\..\src\common\url.cpp $(OBJS)\monolib_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\monolib_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\monolib_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -12248,6 +12258,9 @@ $(OBJS)\netdll_url.obj: ..\..\src\common\url.cpp $(OBJS)\netdll_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) -q -c -P -o$@ $(NETDLL_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\netdll_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) -q -c -P -o$@ $(NETDLL_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\netdll_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) -q -c -P -o$@ $(NETDLL_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -12293,6 +12306,9 @@ $(OBJS)\netlib_url.obj: ..\..\src\common\url.cpp $(OBJS)\netlib_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) -q -c -P -o$@ $(NETLIB_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\netlib_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) -q -c -P -o$@ $(NETLIB_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\netlib_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) -q -c -P -o$@ $(NETLIB_CXXFLAGS) ..\..\src\msw\sockmsw.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 280498e6fc..a4417135d2 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -482,6 +482,7 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_socket.o \ $(OBJS)\monodll_url.o \ $(OBJS)\monodll_webrequest.o \ + $(OBJS)\monodll_webrequest_curl.o \ $(OBJS)\monodll_sockmsw.o \ $(OBJS)\monodll_urlmsw.o \ $(OBJS)\monodll_webrequest_winhttp.o \ @@ -637,6 +638,7 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_socket.o \ $(OBJS)\monolib_url.o \ $(OBJS)\monolib_webrequest.o \ + $(OBJS)\monolib_webrequest_curl.o \ $(OBJS)\monolib_sockmsw.o \ $(OBJS)\monolib_urlmsw.o \ $(OBJS)\monolib_webrequest_winhttp.o \ @@ -933,6 +935,7 @@ NETDLL_OBJECTS = \ $(OBJS)\netdll_socket.o \ $(OBJS)\netdll_url.o \ $(OBJS)\netdll_webrequest.o \ + $(OBJS)\netdll_webrequest_curl.o \ $(OBJS)\netdll_sockmsw.o \ $(OBJS)\netdll_urlmsw.o \ $(OBJS)\netdll_webrequest_winhttp.o @@ -957,6 +960,7 @@ NETLIB_OBJECTS = \ $(OBJS)\netlib_socket.o \ $(OBJS)\netlib_url.o \ $(OBJS)\netlib_webrequest.o \ + $(OBJS)\netlib_webrequest_curl.o \ $(OBJS)\netlib_sockmsw.o \ $(OBJS)\netlib_urlmsw.o \ $(OBJS)\netlib_webrequest_winhttp.o @@ -6975,6 +6979,9 @@ $(OBJS)\monodll_url.o: ../../src/common/url.cpp $(OBJS)\monodll_webrequest.o: ../../src/common/webrequest.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monodll_webrequest_curl.o: ../../src/common/webrequest_curl.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monodll_sockmsw.o: ../../src/msw/sockmsw.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9527,6 +9534,9 @@ $(OBJS)\monolib_url.o: ../../src/common/url.cpp $(OBJS)\monolib_webrequest.o: ../../src/common/webrequest.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monolib_webrequest_curl.o: ../../src/common/webrequest_curl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monolib_sockmsw.o: ../../src/msw/sockmsw.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -12430,6 +12440,9 @@ $(OBJS)\netdll_url.o: ../../src/common/url.cpp $(OBJS)\netdll_webrequest.o: ../../src/common/webrequest.cpp $(CXX) -c -o $@ $(NETDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\netdll_webrequest_curl.o: ../../src/common/webrequest_curl.cpp + $(CXX) -c -o $@ $(NETDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\netdll_sockmsw.o: ../../src/msw/sockmsw.cpp $(CXX) -c -o $@ $(NETDLL_CXXFLAGS) $(CPPDEPS) $< @@ -12475,6 +12488,9 @@ $(OBJS)\netlib_url.o: ../../src/common/url.cpp $(OBJS)\netlib_webrequest.o: ../../src/common/webrequest.cpp $(CXX) -c -o $@ $(NETLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\netlib_webrequest_curl.o: ../../src/common/webrequest_curl.cpp + $(CXX) -c -o $@ $(NETLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\netlib_sockmsw.o: ../../src/msw/sockmsw.cpp $(CXX) -c -o $@ $(NETLIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index ab3f90cd4e..3e366e2529 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -514,6 +514,7 @@ MONODLL_OBJECTS = \ $(OBJS)\monodll_socket.obj \ $(OBJS)\monodll_url.obj \ $(OBJS)\monodll_webrequest.obj \ + $(OBJS)\monodll_webrequest_curl.obj \ $(OBJS)\monodll_sockmsw.obj \ $(OBJS)\monodll_urlmsw.obj \ $(OBJS)\monodll_webrequest_winhttp.obj \ @@ -678,6 +679,7 @@ MONOLIB_OBJECTS = \ $(OBJS)\monolib_socket.obj \ $(OBJS)\monolib_url.obj \ $(OBJS)\monolib_webrequest.obj \ + $(OBJS)\monolib_webrequest_curl.obj \ $(OBJS)\monolib_sockmsw.obj \ $(OBJS)\monolib_urlmsw.obj \ $(OBJS)\monolib_webrequest_winhttp.obj \ @@ -994,6 +996,7 @@ NETDLL_OBJECTS = \ $(OBJS)\netdll_socket.obj \ $(OBJS)\netdll_url.obj \ $(OBJS)\netdll_webrequest.obj \ + $(OBJS)\netdll_webrequest_curl.obj \ $(OBJS)\netdll_sockmsw.obj \ $(OBJS)\netdll_urlmsw.obj \ $(OBJS)\netdll_webrequest_winhttp.obj @@ -1024,6 +1027,7 @@ NETLIB_OBJECTS = \ $(OBJS)\netlib_socket.obj \ $(OBJS)\netlib_url.obj \ $(OBJS)\netlib_webrequest.obj \ + $(OBJS)\netlib_webrequest_curl.obj \ $(OBJS)\netlib_sockmsw.obj \ $(OBJS)\netlib_urlmsw.obj \ $(OBJS)\netlib_webrequest_winhttp.obj @@ -7502,6 +7506,9 @@ $(OBJS)\monodll_url.obj: ..\..\src\common\url.cpp $(OBJS)\monodll_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\monodll_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\monodll_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -10054,6 +10061,9 @@ $(OBJS)\monolib_url.obj: ..\..\src\common\url.cpp $(OBJS)\monolib_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\monolib_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\monolib_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -12957,6 +12967,9 @@ $(OBJS)\netdll_url.obj: ..\..\src\common\url.cpp $(OBJS)\netdll_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) /c /nologo /TP /Fo$@ $(NETDLL_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\netdll_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(NETDLL_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\netdll_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) /c /nologo /TP /Fo$@ $(NETDLL_CXXFLAGS) ..\..\src\msw\sockmsw.cpp @@ -13002,6 +13015,9 @@ $(OBJS)\netlib_url.obj: ..\..\src\common\url.cpp $(OBJS)\netlib_webrequest.obj: ..\..\src\common\webrequest.cpp $(CXX) /c /nologo /TP /Fo$@ $(NETLIB_CXXFLAGS) ..\..\src\common\webrequest.cpp +$(OBJS)\netlib_webrequest_curl.obj: ..\..\src\common\webrequest_curl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(NETLIB_CXXFLAGS) ..\..\src\common\webrequest_curl.cpp + $(OBJS)\netlib_sockmsw.obj: ..\..\src\msw\sockmsw.cpp $(CXX) /c /nologo /TP /Fo$@ $(NETLIB_CXXFLAGS) ..\..\src\msw\sockmsw.cpp diff --git a/build/msw/wx_net.vcxproj b/build/msw/wx_net.vcxproj index 5b18ceda45..4c2eb69153 100644 --- a/build/msw/wx_net.vcxproj +++ b/build/msw/wx_net.vcxproj @@ -470,6 +470,7 @@ + @@ -513,6 +514,7 @@ + diff --git a/build/msw/wx_net.vcxproj.filters b/build/msw/wx_net.vcxproj.filters index 50bfaa3932..d7cf069b48 100644 --- a/build/msw/wx_net.vcxproj.filters +++ b/build/msw/wx_net.vcxproj.filters @@ -54,6 +54,9 @@ Common Sources + + Common Sources + MSW Sources @@ -109,6 +112,9 @@ Common Headers + + Common Headers + diff --git a/build/msw/wx_vc7_net.vcproj b/build/msw/wx_vc7_net.vcproj index 8acd78d68f..6e3b5bafae 100644 --- a/build/msw/wx_vc7_net.vcproj +++ b/build/msw/wx_vc7_net.vcproj @@ -336,6 +336,9 @@ + + + + diff --git a/build/msw/wx_vc8_net.vcproj b/build/msw/wx_vc8_net.vcproj index dc42378627..11a6ba819b 100644 --- a/build/msw/wx_vc8_net.vcproj +++ b/build/msw/wx_vc8_net.vcproj @@ -853,6 +853,10 @@ RelativePath="..\..\src\common\webrequest.cpp" > + + + + diff --git a/build/msw/wx_vc9_net.vcproj b/build/msw/wx_vc9_net.vcproj index be81ca3701..3118e85cad 100644 --- a/build/msw/wx_vc9_net.vcproj +++ b/build/msw/wx_vc9_net.vcproj @@ -849,6 +849,10 @@ RelativePath="..\..\src\common\webrequest.cpp" > + + + + diff --git a/configure b/configure index 60db7082ed..6501210d28 100755 --- a/configure +++ b/configure @@ -36621,6 +36621,11 @@ fi if test "$wxUSE_WEBREQUEST" = "yes"; then $as_echo "#define wxUSE_WEBREQUEST 1" >>confdefs.h + + if test "$wxUSE_MSW" = 1; then + $as_echo "#define wxUSE_WEBREQUEST_WINHTTP 1" >>confdefs.h + + fi fi diff --git a/configure.in b/configure.in index b632b2c84c..03959b657b 100644 --- a/configure.in +++ b/configure.in @@ -6347,6 +6347,11 @@ fi if test "$wxUSE_WEBREQUEST" = "yes"; then AC_DEFINE(wxUSE_WEBREQUEST) + + if test "$wxUSE_MSW" = 1; then + dnl TODO: Check for the required headers/libraries under Windows + AC_DEFINE(wxUSE_WEBREQUEST_WINHTTP) + fi fi dnl --------------------------------------------------------------------------- diff --git a/include/wx/android/setup.h b/include/wx/android/setup.h index 5ae9543714..29319adf15 100644 --- a/include/wx/android/setup.h +++ b/include/wx/android/setup.h @@ -647,11 +647,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. diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index d4db96bd15..9b524dfc79 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -2300,6 +2300,15 @@ # endif #endif /* wxUSE_WEBVIEW && !any web view backend */ +#if wxUSE_WEBREQUEST && !(wxUSE_WEBREQUEST_WINHTTP || wxUSE_WEBREQUEST_URLSESSION || wxUSE_WEBREQUEST_CURL) +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_WEBREQUEST requires at least one backend" +# else +# undef wxUSE_WEBREQUEST +# define wxUSE_WEBREQUEST 0 +# endif +#endif /* wxUSE_WEBREQUEST && !any web request backend */ + #if wxUSE_PREFERENCES_EDITOR /* We can use either a generic implementation, using wxNotebook, or a diff --git a/include/wx/gtk/setup0.h b/include/wx/gtk/setup0.h index ddb2d2688a..4b3e816a4f 100644 --- a/include/wx/gtk/setup0.h +++ b/include/wx/gtk/setup0.h @@ -648,11 +648,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. diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index d7e39b324e..4a5136a035 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -648,11 +648,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. diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index d4560537bf..3b94cad9a6 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -648,11 +648,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. diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h index 89d1fae92c..e1d6df71a9 100644 --- a/include/wx/osx/setup0.h +++ b/include/wx/osx/setup0.h @@ -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. diff --git a/include/wx/osx/webrequest_urlsession.h b/include/wx/osx/webrequest_urlsession.h new file mode 100644 index 0000000000..4997ac7305 --- /dev/null +++ b/include/wx/osx/webrequest_urlsession.h @@ -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 diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index cad052ed0c..e32adbb8ac 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -644,11 +644,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. diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h index 9028fe95fc..1fe8541ce7 100644 --- a/include/wx/univ/setup0.h +++ b/include/wx/univ/setup0.h @@ -647,11 +647,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. diff --git a/include/wx/webrequest_curl.h b/include/wx/webrequest_curl.h new file mode 100644 index 0000000000..9eb674095c --- /dev/null +++ b/include/wx/webrequest_curl.h @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/webrequest_curl.h +// Purpose: wxWebRequest implementation using libcurl +// Author: Tobias Taschner +// Created: 2018-10-25 +// Copyright: (c) 2018 wxWidgets development team +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_WEBREQUEST_CURL_H +#define _WX_WEBREQUEST_CURL_H + +#if wxUSE_WEBREQUEST_CURL + +class WXDLLIMPEXP_NET wxWebSessionCURL: public wxWebSession +{ +public: + wxWebSessionCURL(); + + ~wxWebSessionCURL(); + + wxWebRequest* CreateRequest(const wxString& url, int id = wxID_ANY) wxOVERRIDE; + +private: + wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL); +}; + +class WXDLLIMPEXP_NET wxWebSessionFactoryCURL: public wxWebSessionFactory +{ +public: + wxWebSession* Create() wxOVERRIDE + { return new wxWebSessionCURL(); } +}; + +#endif // wxUSE_WEBREQUEST_CURL + +#endif diff --git a/setup.h.in b/setup.h.in index 792e771fd3..071776d9c3 100644 --- a/setup.h.in +++ b/setup.h.in @@ -299,7 +299,31 @@ #define wxUSE_MIMETYPE 0 + +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) +#define wxUSE_WEBREQUEST_WINHTTP 0 +#else +#define wxUSE_WEBREQUEST_WINHTTP 0 +#endif + +#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 0 +#else +#define wxUSE_WEBREQUEST_URLSESSION 0 +#endif + +#if defined(__WINDOWS__) || defined(__APPLE__) +#define wxUSE_WEBREQUEST_CURL 0 +#else +#define wxUSE_WEBREQUEST_CURL 0 +#endif + +#if wxUSE_WEBREQUEST_WINHTTP || wxUSE_WEBREQUEST_URLSESSION || wxUSE_WEBREQUEST_CURL #define wxUSE_WEBREQUEST 0 +#else +#define wxUSE_WEBREQUEST 0 +#endif #define wxUSE_PROTOCOL 0 diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index c70bbb18d6..0433d9e5f9 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -24,16 +24,26 @@ #include "wx/translation.h" #endif -#if defined(__WINDOWS__) +#if wxUSE_WEBREQUEST_WINHTTP #include "wx/msw/webrequest_winhttp.h" #endif +#if wxUSE_WEBREQUEST_URLSESSION +#include "wx/osx/webrequest_urlsession.h" +#endif +#if wxUSE_WEBREQUEST_CURL +#include "wx/webrequest_curl.h" +#endif extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[] = "wxWebSessionBackendWinHTTP"; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[] = "wxWebSessionBackendURLSession"; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[] = "wxWebSessionBackendCURL"; -#if defined(__WINDOWS__) +#if wxUSE_WEBREQUEST_WINHTTP extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendWinHTTP"; +#elif wxUSE_WEBREQUEST_URLSESSION +extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendURLSession"; +#elif wxUSE_WEBREQUEST_CURL +extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendCURL"; #endif wxDEFINE_EVENT(wxEVT_WEBREQUEST_STATE, wxWebRequestEvent); @@ -156,10 +166,18 @@ void wxWebSession::RegisterFactory(const wxString& backend, wxSharedPtr(new wxWebSessionFactoryWinHTTP())); #endif +#if wxUSE_WEBREQUEST_URLSESSION + RegisterFactory(wxWebSessionBackendURLSession, + wxSharedPtr(new wxWebSessionFactoryURLSession())); +#endif +#if wxUSE_WEBREQUEST_CURL + RegisterFactory(wxWebSessionBackendCURL, + wxSharedPtr(new wxWebSessionFactoryCURL())); +#endif } // static diff --git a/src/common/webrequest_curl.cpp b/src/common/webrequest_curl.cpp new file mode 100644 index 0000000000..86ce25c337 --- /dev/null +++ b/src/common/webrequest_curl.cpp @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/webrequest_curl.h +// Purpose: wxWebRequest implementation using libcurl +// Author: Tobias Taschner +// Created: 2018-10-25 +// Copyright: (c) 2018 wxWidgets development team +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if defined(__BORLANDC__) +#pragma hdrstop +#endif + +#include "wx/webrequest.h" + +#if wxUSE_WEBREQUEST_CURL + +#include "wx/webrequest_curl.h" + +wxWebSessionCURL::wxWebSessionCURL() +{ + +} + +wxWebSessionCURL::~wxWebSessionCURL() +{ + +} + +wxWebRequest* wxWebSessionCURL::CreateRequest(const wxString& url, int id) +{ + wxFAIL_MSG("not implemented"); + return NULL; +} + +#endif // wxUSE_WEBREQUEST_CURL diff --git a/src/msw/webrequest_winhttp.cpp b/src/msw/webrequest_winhttp.cpp index f813cf37b2..e2e9663e03 100644 --- a/src/msw/webrequest_winhttp.cpp +++ b/src/msw/webrequest_winhttp.cpp @@ -16,7 +16,7 @@ #include "wx/webrequest.h" -#if wxUSE_WEBREQUEST +#if wxUSE_WEBREQUEST_WINHTTP #include "wx/mstream.h" #include "wx/uri.h" @@ -472,4 +472,4 @@ wxWebRequest* wxWebSessionWinHTTP::CreateRequest(const wxString& url, int id) return new wxWebRequestWinHTTP(id, *this, url); } -#endif // wxUSE_WEBREQUEST +#endif // wxUSE_WEBREQUEST_WINHTTP diff --git a/src/osx/webrequest_urlsession.mm b/src/osx/webrequest_urlsession.mm new file mode 100644 index 0000000000..7b241e8034 --- /dev/null +++ b/src/osx/webrequest_urlsession.mm @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/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 +/////////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if defined(__BORLANDC__) +#pragma hdrstop +#endif + +#include "wx/webrequest.h" + +#if wxUSE_WEBREQUEST_URLSESSION + +#import + +#include "wx/osx/webrequest_urlsession.h" + +wxWebSessionURLSession::wxWebSessionURLSession() +{ + m_session = [NSURLSession sessionWithConfiguration: + [NSURLSessionConfiguration defaultSessionConfiguration]]; +} + +wxWebSessionURLSession::~wxWebSessionURLSession() +{ + [m_session release]; +} + +wxWebRequest* wxWebSessionURLSession::CreateRequest(const wxString& url, int id) +{ + wxFAIL_MSG("not implemented"); + return NULL; +} + +#endif // wxUSE_WEBREQUEST_URLSESSION