diff --git a/curlpp/.gitignore b/curlpp/.gitignore
new file mode 100644
index 0000000..1b5cf26
--- /dev/null
+++ b/curlpp/.gitignore
@@ -0,0 +1,47 @@
+*.Po
+*.o
+*.a
+*.la
+*.lo
+*.Plo
+*.dylib
+*.lai
+Makefile
+*~
+
+build/
+m4/
+CMakeFiles/
+
+examples/example01
+examples/example02
+examples/example03
+examples/example04
+examples/example05
+examples/example06
+examples/example07
+examples/example08
+examples/example09
+examples/example10
+examples/example11
+examples/example12
+examples/example13
+examples/example14
+examples/example15
+examples/example16
+examples/example17
+examples/example18
+examples/example19
+examples/example20
+examples/example21
+examples/example22
+examples/example23
+examples/example24
+examples/example25
+
+*.exe
+CMakeCache.txt
+
+conanbuildinfo.cmake
+conaninfo.txt
+bin/
diff --git a/curlpp/.hgignore b/curlpp/.hgignore
new file mode 100644
index 0000000..28ca539
--- /dev/null
+++ b/curlpp/.hgignore
@@ -0,0 +1,23 @@
+(^|/)\.svn($|/)
+(^|/)\.hg($|/)
+(^|/)\.hgtags($|/)
+^curlpp-svn.log$
+^tailor.state$
+^tailor.state.old$
+^tailor.state.journal$
+.*\.o
+.*\.lo
+.*\.a
+.*\.la
+.*\.Plo
+.*\.Po
+#.*#$
+Makefile$
+Makefile.in$
+include/curlpp/config.h.in
+include/curlpp/config.h
+^examples/example[0-9]*$
+aclocal.m4$
+.dylib$
+curlpp.pc$
+curlpp.spec$
diff --git a/curlpp/.travis.yml b/curlpp/.travis.yml
new file mode 100644
index 0000000..7550648
--- /dev/null
+++ b/curlpp/.travis.yml
@@ -0,0 +1,54 @@
+language: cpp
+
+# precise gcc doesn't have c++11 support
+
+matrix:
+ include:
+ - os: linux
+ dist: trusty
+ compiler: clang
+ env: NAME="trusty"
+ - os: linux
+ dist: trusty
+ compiler: gcc
+ env: NAME="trusty"
+ - os: linux
+ dist: precise
+ compiler: clang
+ env: NAME="precise"
+ - os: osx
+ osx_image: xcode7.2
+ - os: osx
+ compiler: clang
+ - os: osx
+ compiler: gcc
+
+addons:
+ apt:
+ packages:
+ - libcurl4-openssl-dev
+
+before_script:
+ - mkdir build && cd build
+ - cmake ../
+
+script:
+ - make && sudo make install
+ - cd ../examples && mkdir build && cd build
+ - cmake ../
+ - make
+
+
+install:
+- echo install-----------------------------------------------------------------
+# Download and install libcurl
+- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
+ brew update;
+ brew install curl;
+ fi
+# install cmake 3.2 for precise
+- if [[ $NAME == "precise" ]]; then
+ sudo add-apt-repository ppa:george-edison55/precise-backports --yes;
+ sudo apt-get update;
+ sudo apt-get install cmake-data cmake;
+ fi
\ No newline at end of file
diff --git a/curlpp/CMakeLists.txt b/curlpp/CMakeLists.txt
new file mode 100644
index 0000000..8b183a0
--- /dev/null
+++ b/curlpp/CMakeLists.txt
@@ -0,0 +1,115 @@
+project(curlpp)
+
+
+# In response to CMake 3.0 generating warnings regarding policy CMP0042,
+# the OSX RPATH settings have been updated per recommendations found
+# in the CMake Wiki:
+# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
+if(POLICY CMP0042)
+ cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH
+ set(CMAKE_MACOSX_RPATH TRUE)
+endif()
+
+# for unix platform, define install directories.
+include(GNUInstallDirs)
+
+if(WIN32)
+ # cmake 3.4 is required for CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
+ cmake_minimum_required(VERSION 3.4)
+
+ # c++ 11 support from cmake 3.4 or newer
+ set(CMAKE_CXX_STANDARD 11) # C++11...
+ set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
+ set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
+
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ else()
+ if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.1)
+ cmake_minimum_required(VERSION 2.8)
+ # c++11 support for cmake 2.8.12 - 3.0.x
+ #
+ # for non-windows platform we try to keep cmake 2.8 support
+ # since entreprise distribution tends to have 2.8 version.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ else()
+ # c++ 11 support from cmake 3.1 or newer
+ set(CMAKE_CXX_STANDARD 11) # C++11...
+ set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
+ set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
+ endif()
+endif()
+
+
+# Conan.io integration
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake)
+ include(${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake)
+ conan_basic_setup()
+endif()
+
+# extra (pkg-config-related files)
+add_subdirectory(extras)
+
+#########################################################################################
+# Look for dependencies
+
+# Documented at https://cmake.org/cmake/help/v3.0/module/FindCURL.html?highlight=curlpp
+# Seems simple.
+
+message(STATUS "Looking for CURL")
+include(FindCURL)
+find_package(CURL REQUIRED)
+
+if(CURL_FOUND)
+ message(STATUS "Found CURL version: ${CURL_VERSION_STRING}")
+ message(STATUS "Using CURL include dir(s): ${CURL_INCLUDE_DIRS}")
+ message(STATUS "Using CURL lib(s): ${CURL_LIBRARIES}")
+else()
+ message(FATAL_ERROR "Could not find CURL")
+endif()
+
+# All following targets should search these directories for headers
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CURL_INCLUDE_DIRS}
+)
+
+#########################################################################################
+# Define Targets
+
+# If building on windows, install path will be in build/winbuild
+if(CMAKE_SYSTEM MATCHES "Windows")
+ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX "winbuild")
+ endif()
+endif()
+
+file(GLOB_RECURSE HeaderFileList "${CMAKE_CURRENT_SOURCE_DIR}/include/*")
+file(GLOB_RECURSE SourceFileList "${CMAKE_CURRENT_SOURCE_DIR}/src/*")
+add_library(${PROJECT_NAME} SHARED ${HeaderFileList} ${SourceFileList})
+target_link_libraries(${PROJECT_NAME} ${CURL_LIBRARIES} ${CONAN_LIBS})
+set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1 VERSION 1.0.0)
+
+add_library(${PROJECT_NAME}_static STATIC ${HeaderFileList} ${SourceFileList})
+
+# Make sure that on unix-platforms shared and static libraries have
+# the same root name, but different suffixes.
+#
+# (solution taken from https://cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F)
+#
+# Making shared and static libraries have the same root name, but different suffixes
+SET_TARGET_PROPERTIES(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
+# Now the library target "curlpp_static" will be named "curlpp.lib" with MS tools.
+# This conflicts with the "curlpp.lib" import library corresponding to "curlpp.dll",
+# so we add a "lib" prefix (which is default on other platforms anyway):
+SET_TARGET_PROPERTIES(${PROJECT_NAME}_static PROPERTIES PREFIX "lib")
+target_link_libraries(${PROJECT_NAME}_static ${CURL_LIBRARIES} ${CONAN_LIBS})
+
+# install headers
+install(DIRECTORY include/utilspp/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/utilspp")
+install(DIRECTORY include/curlpp/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/curlpp")
+
+install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
diff --git a/curlpp/CNAME b/curlpp/CNAME
new file mode 100644
index 0000000..87ae8d9
--- /dev/null
+++ b/curlpp/CNAME
@@ -0,0 +1 @@
+www.curlpp.org
\ No newline at end of file
diff --git a/curlpp/Readme.md b/curlpp/Readme.md
new file mode 100644
index 0000000..506959f
--- /dev/null
+++ b/curlpp/Readme.md
@@ -0,0 +1,34 @@
+[](https://opensource.org/licenses/MIT) [](https://travis-ci.org/jpbarrette/curlpp) [](https://ci.appveyor.com/project/jpbarrette/curlpp)
+
+# Description
+
+[cURLpp](http://www.curlpp.org) is a C++ wrapper for libcURL. libcURL is described as:
+
+
+a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and more!
+
+
+
+libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more...
+
+
+
+libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported and fast.
+
+
+First, I need to quote Daniel Stenberg, the maintener of libcURL:
+You can use libcURL instantly from within your C++ programs. You don't need cURLpp for that, cURLpp just adds an OO'ified layer that libcURL doesn't normally provide. It means that you need to be sure that you need, or want, cURLpp features. If not, I suggest to use directly the libcURL library. So, what are thoses features that cURLpp offers?
+
+* You can query handles for option values (version 0.5.x and newer only).
+* It uses the C++ standard library structures instead of home made ones.
+* It is exception safe.
+* It is type safe.
+
+# Download
+
+Latest version is available on GitHub [here](https://github.com/jpbarrette/curlpp/releases/latest).
+
+# Documentation
+
+The programming guide is [here](https://github.com/jpbarrette/curlpp/tree/master/doc/guide.pdf). This guide is greatly inspired by the libcURL guide, that I strongly suggest to read. There's also some examples in the "[examples](http://github.com/jpbarrette/curlpp/tree/master/examples)/" source directory of cURLpp.
+
diff --git a/curlpp/_config.yml b/curlpp/_config.yml
new file mode 100644
index 0000000..2f7efbe
--- /dev/null
+++ b/curlpp/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
diff --git a/curlpp/appveyor.yml b/curlpp/appveyor.yml
new file mode 100644
index 0000000..6b66856
--- /dev/null
+++ b/curlpp/appveyor.yml
@@ -0,0 +1,45 @@
+version: '0.7.4.{build}'
+
+environment:
+ matrix:
+ - PRJ_GEN: "Visual Studio 11 2012 Win64"
+ BDIR: msvc2012
+ PRJ_CFG: Release
+ PRJ_GEN_VERSION: 11
+ - PRJ_GEN: "Visual Studio 12 2013 Win64"
+ BDIR: msvc2013
+ PRJ_CFG: Release
+ PRJ_GEN_VERSION: 12
+ - PRJ_GEN: "Visual Studio 14 2015 Win64"
+ BDIR: msvc2015
+ PRJ_CFG: Release
+ PRJ_GEN_VERSION: 14
+ - PRJ_GEN: "Visual Studio 11 2012 Win64"
+ BDIR: msvc2012
+ PRJ_CFG: Debug
+ PRJ_GEN_VERSION: 11
+ - PRJ_GEN: "Visual Studio 12 2013 Win64"
+ BDIR: msvc2013
+ PRJ_CFG: Debug
+ PRJ_GEN_VERSION: 12
+ - PRJ_GEN: "Visual Studio 14 2015 Win64"
+ BDIR: msvc2015
+ PRJ_CFG: Debug
+ PRJ_GEN_VERSION: 14
+
+install:
+ - cmd: echo "Downloading conan..."
+ - cmd: set PATH=%PATH%;%PYTHON%/Scripts/
+ - cmd: pip.exe install conan
+ - cmd: conan user # Create the conan data directory
+ - cmd: conan --version
+
+build_script:
+ - mkdir build.%BDIR%
+ - IF %PRJ_GEN_VERSION% == 11 call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
+ - conan install --build=missing -s compiler="Visual Studio" -s compiler.version=%PRJ_GEN_VERSION% -s build_type=%PRJ_CFG% .
+ - cd build.%BDIR%
+ - cmake .. -G"%PRJ_GEN%"
+ - cmake --build . --config %PRJ_CFG% --clean-first
+
+
diff --git a/curlpp/conanfile.txt b/curlpp/conanfile.txt
new file mode 100644
index 0000000..ece9ff0
--- /dev/null
+++ b/curlpp/conanfile.txt
@@ -0,0 +1,5 @@
+[requires]
+libcurl/7.50.3@lasote/stable
+
+[generators]
+cmake
diff --git a/curlpp/doc/AUTHORS b/curlpp/doc/AUTHORS
new file mode 100644
index 0000000..2a6ceb6
--- /dev/null
+++ b/curlpp/doc/AUTHORS
@@ -0,0 +1,13 @@
+Eric Lavigne (erlavigne at wanadoo.fr)
+Jean-Philippe Barrette-LaPierre (jpb at rrette.com)
+
+Thanks to some patch providers:
+Thomas Boutry
+Jonathan Wakely
+Peter Krumins
+Ben Golding
+Glenn
+Hoef Jan
+Gisle Vanem
+Paul Lacy
+Nicolas Le Goff
diff --git a/curlpp/doc/LICENSE b/curlpp/doc/LICENSE
new file mode 100644
index 0000000..8120c1f
--- /dev/null
+++ b/curlpp/doc/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) <2002-2004>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files
+(cURLpp), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/curlpp/doc/README.win32 b/curlpp/doc/README.win32
new file mode 100644
index 0000000..33340b9
--- /dev/null
+++ b/curlpp/doc/README.win32
@@ -0,0 +1,238 @@
+Read the README file first.
+
+As of version 0.6.0 curlpp has been built and run on win32.
+
+Information contained in this file does not apply to cygwin builds.
+
+curlpp has been tested on
+Microsoft Visual C++ 7.1 (2003), (by Giuseppe "Cowo" Corbelli)
+Microsoft Visual C++ 8.0 (2005), (by Andrei Korostelev)
+Microsoft Visual C++ 9.0 (2008), (by Piotr Dobrogost)
+but any modern C++ compiler should do the job.
+
+BUILDING CURLPP WITH MSVC
+-------------------------
+
+BUILDING CURLPP
+
+You can build curlpp in three different ways
+
+A. from within MS Visual Studio IDE
+B. using msbuild tool and solution files
+C. using namke and makefile
+
+
+A. and B.
+
+ In case of A. and B. first you have to create solution files for your version of MS Visual Studio.
+ To do this use win32\create-vc-solution.bat batch file with one of the following parameters:
+ 7.1, for Visual Studio 2003
+ 8, for Visual Studio 2005
+ 9, for Visual Studio 2008
+ This batch file needs sed to be run successfully. You can download sed for win32 platform here
+ http://gnuwin32.sourceforge.net/packages/sed.htm
+
+
+A. Building from within IDE
+
+ Choosing configuration
+
+ Choose configuration you would like to build. What configuration you want depens on three aspects.
+ 1. Weather you want to build dynamic library (dll) or static library (lib).
+ Choose configuration with DynamicLib or StaticLib prefix.
+ 2. Weather you want to build debug or release version of the library.
+ Choose configuration with Debug or Release infix.
+ 3. Weather you want static runtime library (RTL) to be used by curlpp or dynamic one.
+ Choose configuration with StaticRTL or DynamicRTL suffix.
+
+ Names' suffixes of output .lib and .dll files depend on the all three choices.
+
+ MTd - dynamic, debug, static RTL
+ MT - dynamic, release, static RTL
+ MDd - dynamic, debug, dynamic RTL
+ MD - dynamic, release, dynamic RTL
+
+ staticMTd - static, debug, static RTL
+ staticMT - static, release, static RTL
+ staticMDd - static, debug, dynamic RTL
+ staticMD - static, release, dynamic RTL
+
+ We will refer to these suffixes and types of libraries as "build category" further in this document.
+
+ Setting include directory
+
+ If you are building curlpp using the original directory structure then you don't need to set value of user macro
+ CURLPP_INCLUDE_PATH (by default ".\include"). If however you modified the original directory structure you have
+ to set value of this macro to the path, where you have curlpp source files.
+
+ Setting output directory
+
+ The output files will be placed in a directory set in CURLPP_LIB_PATH user macro (by default ".out\lib").
+
+
+B. Building using msbuild
+
+ Open a command prompt and change folder to the root of curlpp tree.
+
+ set LIBCURL_PATH=/where/curl/is/installed
+ set OPENSSL_PATH=/where/openssl/is/installed (only if you have libcurl with ssl support and ssl installed)
+ msbuild curlpp.sln /t:Rebuild /p:Configuration=
+ where is one of
+ - DynamicLibDebugDynamicRTL
+ - DynamicLibDebugStaticRTL
+ - DynamicLibReleaseDynamicRTL
+ - DynamicLibReleaseStaticRTL
+ - StaticLibDebugDynamicRTL
+ - StaticLibDebugStaticRTL
+ - StaticLibReleaseDynamicRTL
+ - StaticLibReleaseStaticRTL
+
+ Output files will be placed in a directory set in CURLPP_LIB_PATH.
+
+ Any of DynamicLib* configurations will build a .dll library file and a .lib library import file.
+ Any of StaticLib* configurations will build the .lib static (inline) library.
+ Any of *Debug* configurations will in addition build a .pdb Program Database file.
+
+
+C. Building using nmake
+
+ Open a command prompt and change folder to the root of curlpp tree.
+ Run nmake /f makefile with the following parameters
+ BUILD_CFG=[dynamic|static]-[debug|release]
+ RTLIB_CFG=[dynamic|static]-[debug|release]
+ LIBCURL_CFG=[dynamic|static]-[debug|release]
+
+ All options are optional.
+ Default for BUILD_CFG is dynamic-release.
+ Default for others is the value of BUILD_CFG.
+ Edit the LIBCURL_PATH or set LIBCURL_PATH envvar!
+
+
+NOTES
+
+ Linking with libcurl
+
+ All versions of this library need libcurl (c library) include files to compile and lib file to link successfully.
+ To build curlpp you first have to set value of LIBCURL_PATH user macro to your installation of libcurl.
+ This macro is used in the project file for VC9 to find include and lib files of libcurl.
+ Steps to set user macro. Select View/Property Manager, double-click curlpp property sheet, go to
+ Common Properties/User Macros/, double-click name of macro you want to modify, modify it and click OK.
+ Filename of libcurl's lib file should be in the form libcurlX.lib where X denotes build category chosen for curlpp.
+ (see Linking with RTL)
+ If it has different name you have to change .lib filename in
+ Project properties\Librarian\Additional Dependencies (when building static library)
+ or
+ Project properties\Linker\Input\Additional Dependencies (when building dynamic library).
+
+
+ Linking with static libcurl
+
+ If you are not going to use libcurl as a dll and you would like to include it into your library/executable by
+ linking to static version of libcurl you have to define preprocessor symbol CURL_STATICLIB. You can do it in
+ Project/Properties/C/C++/Preprocessor/Preprocessor Definitions.
+ By default all StaticLib* configurations define this symbol. If for some reason you would like to build static
+ curlpp library which links do dynamic libcurl library you have to remove CURL_STATICLIB define.
+
+
+ Linking with RTL
+
+ You have to link with libcurl which uses RTL in the same way as you are going to use RTL in curlpp lib.
+ Refering to build categories defined earlier in section "Choosing configuration" both libcurl and curlpp
+ must have the same build category.
+ If you are going to use dynamic RTL in curlpp (MD[x]), use libcurl which also uses dynamic RTL (MD[x]).
+ If you are going to use static RTL in curlpp (MT[x]), use libcurl which also uses static RTL (MT[x]).
+ You can use debug build of libcurl (MDd or MTd) in the release build of curlpp (MD or MT) and
+ you can use release build of libcurl (MD or MT) in the debug build of curlpp (MDd or MTd).
+ However you shouldn't do this.
+
+ Building self-contained version of the library
+
+ curlpp is mostly a template library. For this reason during build of it, only non template entities are placed in the
+ .lib and .dll files. Most of the library's features used in your application causes code generation during compilation
+ of _your project_ and the code is placed in your executable. This is often not desirable. If you want to build
+ the curlpp as self-contained library (one which has all code called by clients in its .lib and .dll files) you can
+ define preprocesor symbol CURL_SELF_CONTAINED. In this case curlpp uses explicit template instantiation (all such
+ instantiantions are placed in separte .ins files) to force generating code into .lib and .dll files. You have to
+ define this preprocesor symbol during build of your application to avoid including templates' definitions as they
+ are not needed in this phase. If you get linker errors connected with curlpp features when using self-contained
+ version of the library it's because there are some missing explicit instantiantions. Please let us know if it happens.
+
+
+ Using curlpp in .NET applications
+
+ If you are going to use curlpp library in a .NET project you have to use dynamic RTL.
+ This is because all .NET applications must use dynamic RTL and if your application uses curlpp,
+ the library itself has to use dynamic RTL as well.
+
+
+ Additional dependencies
+
+ To build examples (and your project as well) you need the following Windows lib files to link successfully
+ WSock32.lib, Wldap32.lib
+ These files comes with WindowsSDK. Macro $(WIN_SDK_DIR) (by default $(WindowsSdkDir)) is used in the properties
+ sheet file curlpp.examples.VC9.vsprops by VC9 solution to find these libraries.
+
+
+ Linking with OpenSSL
+
+ If you have libcurl compiled with OpenSSL support and want to have support for OpenSSL in curlpp as well
+ you have to set value of OPENSSL_PATH user macro to your installation of OpenSSL before building curlpp.
+ This variable is used in the project file for VC9 to find include and lib files of OpenSSL.
+ Steps to set user macro. Select View/Property Manager, double-click curlpp property sheet, go to
+ Common Properties/User Macros/, double-click name of macro you want to modify, modify it and click OK.
+ You have to link with OpenSSL which uses RTL in the same way as you are going to use RTL in curlpp lib.
+ Refering to build categories defined earlier in section "Choosing configuration" both OpenSSL and curlpp
+ must have the same build category.
+ Filenames of OpenSSL lib files should be in the form libeay32X.lib and ssleay32X.lib, where X denotes
+ build category chosen for curlpp. You have to add both this filenames to
+ Project properties\Librarian\Additional Dependencies (when building static library)
+ or
+ Project properties\Linker\Input\Additional Dependencies (when building dynamic library).
+
+ If you need OpenSSL for Windows platform take a look at http://www.slproweb.com/products/Win32OpenSSL.html
+ If you installed OpenSSL downloaded from the above link you'll find .lib files of all four build categories
+ in the /lib/vc directory.
+
+
+ Building with support for Boost
+
+ curlpp has ability to use some features from the Boost library. If you want to build curlpp with support for Boost
+ you have to set value of BOOST_PATH user macro to your installation of Boost before building curlpp.
+ This variable is used in the project file for VC9 to find include files of Boost.
+ You also have to define preprocessor symbol HAVE_BOOST. You can do it in
+ Project/Properties/C/C++/Preprocessor/Preprocessor Definitions.
+
+
+ Project propery sheets
+
+ All user macros like LIBCURL_PATH, OPENSSL_PATH, BOOST_PATH, CURLPP_INCLUDE_PATH, CURLPP_LIB_PATH, WIN_SDK_DIR,
+ CURLPP_EXAMPLES_OUT_DIR, etc.
+ are defined in project property sheet files named
+ curlpp.common.vsprops - options and macros used during build of library itself and during build of examples
+ curlpp.lib.vsprops - options and macros used during build of library itself
+ curlpp.examples.vsprops - options and macros used during build of examples
+
+
+ Compiler warnings
+
+ There are a few kinds of compiler warnings which we haven't managed to remove.
+
+ warning C4251: class X needs to have dll-interface to be used by clients of class Y
+ warning C4275: non dll-interface class X used as base for dll-interface class Y
+ warning C4512: X : assignment operator could not be generated
+ warning C4661: methodX : no suitable definition provided for explicit template instantiation request
+
+
+BUILDING CURLPP EXAMPLES
+
+Your can either build the examples from MS Visual Studio IDE or from the command line from within examples folder:
+
+ nmake -f Makefile.msvc all
+ or
+ nmake -f Makefile.msvc exampleXY
+ to build example XY
+
+
+Giuseppe "Cowo" Corbelli, cowo at lugbs dot linux dot it
+Andrei Korostelev, andrei at korostelev dot net
+Piotr Dobrogost, pd.curlpp.org (November 2008 - March 2009)
\ No newline at end of file
diff --git a/curlpp/doc/TODO b/curlpp/doc/TODO
new file mode 100644
index 0000000..a68450e
--- /dev/null
+++ b/curlpp/doc/TODO
@@ -0,0 +1,4 @@
+- Need to fix the OptionList::print function.
+- Need to put WriteStream and ReadStream to be exception safe.
+- Need to put WriteStream and ReadStream to be exception safe.
+- Get rid of example 18 and 20
diff --git a/curlpp/doc/guide.pdf b/curlpp/doc/guide.pdf
new file mode 100644
index 0000000..fb98200
Binary files /dev/null and b/curlpp/doc/guide.pdf differ
diff --git a/curlpp/doc/guide.tex b/curlpp/doc/guide.tex
new file mode 100644
index 0000000..12165e7
--- /dev/null
+++ b/curlpp/doc/guide.tex
@@ -0,0 +1,706 @@
+\LoadClass[12pt,letterpaper]{article}
+\documentclass{article}
+\usepackage{verbatim}
+\author{Jean-Philippe Barrette-LaPierre}
+\title{Programming with cURLpp}
+\begin{document}
+\maketitle
+\section{About this Document}
+\newcommand{\Cpp}{C{\tt ++}}
+
+
+This document attempts to describe the general principles and some basic
+approaches to consider when programming with cURLpp. Don't forget that cURLpp
+is a \Cpp wrapper of libcurl, so cURLpp needs libcurl to be installed already.
+
+This document will refer to 'the user' as the person writing the source code
+that uses cURLpp. That would probably be you or someone in a similar position.
+What will be generally refered to as 'the program' will be the collective
+source code that you write and that is using cURLpp for transfers. The program
+is outside cURLpp and cURLpp is outside of the program.
+
+To get more details on all options and functions described herein, please
+refer to their respective man pages. You should always have in mind that this
+is a \Cpp wrapper of libcurl. It would be unproductive to duplicate libcurl's
+documentation here, so this document will show you how to interact with cURLpp,
+but you should read the libcurl programming tutorial, which this document is
+strongly inspired from, and the libcurl man pages.
+
+\section{Building}
+
+There are many different ways to build C++ programs. This chapter will assume a
+unix-style build process. If you use a different build system, you can still
+read this to get general information that may apply to your environment as
+well. Note that cURLpp need libcurl to be already installed.
+
+\subsection{Compiling the Program}
+
+Your compiler needs to know where cURLpp's and libcurl's headers are
+located. Therefore you must set your compiler's include path to point to
+the directory where you installed them. The 'curlpp-config'\footnote{
+The curlpp-config tool, which wraps all functions of curl-config,
+is generated at build-time (on unix-like systems) and should be installed
+with the 'make install' or similar instruction that installs the library,
+header files, man pages etc.} tool can be
+used to get this information:
+
+\begin{verbatim} # curlpp-config --cflags\end{verbatim}
+
+If pkg-config is installed, you can use it this way:
+
+\begin{verbatim} # pkg-config --cflags curlpp\end{verbatim}
+
+But, if you're using \verb+autoconf+ for your project you can use
+\verb+pkg-config+ macros. See \verb+pkg-config+ man pages for more
+details.
+
+\subsection{Linking the Program with cURLpp}
+
+When having compiled the program, you need to link your object files to
+create a single executable. For that to succeed, you need to link with
+cURLpp and possibly also with other libraries that cURLpp itself depends
+on (such as libcurl). This may include OpenSSL libraries and even some standard
+OS libraries may be needed on the command line. To figure out which flags to use,
+the 'curlpp-config' tool comes to the rescue once again:
+
+\begin{verbatim} # curlpp-config --libs\end{verbatim}
+
+Again, if pkg-config is installed, you can use it this way:
+
+\begin{verbatim} # pkg-config --libs curlpp\end{verbatim}
+
+\subsection{SSL or Not}
+
+cURLpp, like libcurl, can be built and customized in many ways. One of the things that
+varies between different libraries and builds is the support for SSL-based
+transfers, like HTTPS and FTPS. If OpenSSL was detected properly by libcurl
+at build-time, cURLpp will be built with SSL support. To figure out if an
+installed cURLpp has been built with SSL support enabled, use
+'curlpp-config' like this:
+
+\begin{verbatim} # curlpp-config --feature\end{verbatim}
+
+If SSL is supported, the keyword 'SSL' will be written to stdout,
+possibly together with a few other features that can be on and off on
+different cURLpps.
+
+
+\subsection{Portable Code in a Portable World}
+
+The people behind libcurl have put a considerable effort to make libcurl work
+on a large number of different operating systems and environments.
+
+You program cURLpp the same way on all platforms that cURLpp runs on. There
+are only very few minor considerations that differ. If you make sure just to
+write your code portably enough, you may very well create yourself a very
+portable program. cURLpp shouldn't stop you from that.
+
+\section{Global Preparation}
+
+The program must initialize some of the cURLpp functionality globally. That
+means it should be done exactly once, no matter how many times you intend to
+use the library. Once for your program's entire lifetime. This is done using
+
+\begin{verbatim}
+cURLpp::initialize( long flags = cURLpp::CURL_GLOBAL_ALL )
+\end{verbatim}
+
+and it takes one parameter which is a bit pattern that tells cURLpp what to
+intialize. Check the man page of \verb+curl_global_init+ for more details on flags.
+
+When the program no longer uses cURLpp, it should call \verb+cURLpp::terminate()+,
+which is the opposite of the init call. It will then do the operations needed
+to cleanup the resources that the \verb+cURLpp::initialize()+ call initialized.
+
+Repeated calls to \verb+cURLpp::initialize()+ and \verb+cURLpp::terminate()+ must not be made.
+They must only be called once each. The cURLpp::Cleanup class can be used to do this. It will
+call the \verb+cURLpp::initialize()+ function in its constructor and \verb+cURLpp::terminate()+
+in its destructor. Check example01.cpp in the examples/ directory of
+the source distribution for an example.
+
+\section{Handle the Easy cURLpp}
+
+To use the easy interface, you must first create yourself an easy handle. You
+need one handle for each easy session you want to perform. Basically, you
+should use one handle for every thread you plan to use for transferring. You
+must never share the same handle in multiple threads.
+
+Get an easy handle with
+
+\begin{verbatim} cURLpp::Easy easyhandle;\end{verbatim}
+
+This creates an easy handle. Using that you proceed to the next step: setting
+up your preferred actions. A handle is just a logic entity for the upcoming
+transfer or series of transfers. You can use it to do HTTP or FTP
+requests.
+
+You set properties and options for this handle using \verb+cURLpp::Options+,
+or \verb+cURLpp::OptionList+ classes; we will discuss \verb+cURLpp::OptionList+
+later. They control how the subsequent transfer or transfers will be made.
+Options remain set in the handle until set again to something different.
+Alas, multiple requests using the same handle will use the same options.
+
+Many of the informationals you set in cURLpp are \Cpp standard library strings.
+Keep in mind that when you set strings with member functions, cURLpp will copy
+the data. It will not merely point to the data. You don't need to make sure
+that the data remains available for cURLpp.
+
+One of the most basic properties to set in the handle is the URL. You set
+your preferred URL to transfer with a
+\verb+void cURLpp::Options::Url(const char *link)+
+option class, in a manner similar to:
+
+\begin{verbatim}
+easyhandle.setOpt(cURLpp::Options::Url("http://example.com/"));
+\end{verbatim}
+
+There are of course many more options you can set, and we'll get back to a
+few of them later. Let's instead continue to the actual transfer:
+
+\begin{verbatim}
+easyhandle.perform();
+\end{verbatim}
+
+The \verb+cURLpp::Easy::perform()+ will connect to the remote site, do the necessary
+commands and receive the transfer. Whenever it receives data, it calls the
+trait function we previously set. The function may get one byte at a time,
+or it may get many kilobytes at once. cURLpp delivers as much as possible as
+often as possible. Your trait function should return the number of bytes
+it "took care of". If that is not the exact same amount of bytes that was
+passed to it, cURLpp will abort the operation and throw an exception.
+
+When the transfer is complete, the function throws a
+\verb+cURLpp::Exception+ if it
+doesn't succeed in its mission. the \verb+const char *cURLpp::Exception::what()+ will
+return the human readable reason of failure.
+
+\section{Wrapping libcurl}
+
+As previously said, \verb+cURLpp+ is just a \Cpp libcurl wrapper. It wouldn't be a good
+idea to reproduce here, in this project, all the libcurl documentation. This means
+that when you will be programming with \verb+cURLpp+, you will refer more to libcurl's
+documentation than to \verb+cURLpp+'s. We will explain here how \verb+cURLpp+ wraps libcurl, so
+you will able to use it, without constantly refering to its manual.
+
+First, you must know that there are two main things that constitute \verb+cURLpp+: There are
+its options value setting/retrieving behavior and its utilities that helps you to use
+libcurl's options more easily.
+
+\subsection{Option setting/retrieving}
+
+The main feature of \verb+cURLpp+ is that you can retrieve options previously set on handles.
+\verb+cURLpp+ gives you the opportunity to retrieve options values that were previously set
+on a specific handle and then use them again for other handles. But first, let's show
+you how to set an option on a handle, in comparison to libcurl's way of setting an option.
+
+libcurl sets options on handles with this function:
+
+\begin{verbatim}
+curl_easy_setopt(CURL *handle, CURLoption option, parameter)
+\end{verbatim}
+
+Here's a part of the documentation taken from the man pages:
+
+\begin{quote}
+\verb+curl_easy_setopt()+ is used to tell libcurl how to behave. By using the appropriate options to
+\verb+curl_easy_setopt()+, you can change libcurl's behavior. All options are set with the option
+followed by a parameter. That parameter can be a long, a function pointer or an object pointer,
+all depending on what the specific option expects.
+\end{quote}
+
+Lets code a simple example:
+
+\begin{verbatim}
+CURL *handle = curl_easy_init();
+if(handle == NULL) {
+ //something went wrong.
+}
+
+CURLcode code = curl_easy_setopt(handle,
+ CURLOPT_URL, ``http://www.example.com'');
+if(code != CURLE_OK) {
+ //something went wrong
+}
+\end{verbatim}
+The code below does the same thing but with \verb+cURLpp+:
+
+\begin{verbatim}
+cURLpp::Easy handle;
+handle.setOpt(cURLpp::Options::Url(``http://www.example.com'');
+\end{verbatim}
+
+If a problem occur, \verb+cURLpp+ will throw an exception, for more detail on this subject,
+see the next section named \textit{Exception issues}. As you see, the equivalent
+of the \verb+curl_easy_setopt+ function is the cURLpp::Easy::setOpt member function.
+
+\subsubsection{cURLpp::Options}
+
+The question that you might ask you at this moment is: ``what exactly is the
+\verb+cURLpp::Options::Url+ class mentioned in the previous example?'' In fact,
+this class is used to store values of options, but also to retrieve them, as shown
+below:
+
+\begin{verbatim}
+cURLpp::Easy handle;
+handle.setOpt(cURLpp::Options::Url(``http://www.example.com'');
+
+cURLpp::Options::Url myUrl;
+handle.getOpt(myUrl);
+std::cout << myUrl.getValue() << std::endl;
+\end{verbatim}
+
+This piece of code should print the URL on the standard output. Here's the
+code of the \verb+examples/example01.cpp+ file.
+
+\begin{verbatim}
+#include
+#include
+
+#include
+#include
+
+#define MY_PORT 8080
+
+/**
+ * This example is made to show you how you can use the Options.
+ */
+int main()
+{
+ try
+ {
+ cURLpp::Cleanup myCleanup;
+
+ // Creation of the URL option.
+ cURLpp::Options::Url myUrl(
+ std::string("http://example.com"));
+
+ // Copy construct from the other URL.
+ cURLpp::Options::Url myUrl2(myUrl);
+
+ // Creation of the port option.
+ cURLpp::Options::Port myPort(MY_PORT);
+
+ // Creation of the request.
+ cURLpp::Easy myRequest;
+
+
+ // Creation of an option that contain a copy
+ // of the URL option.
+ cURLpp::OptionBase *mytest = myUrl.clone();
+ myRequest.setOpt(*mytest);
+
+ // You can reuse the base option for other type of option
+ // and set the option to the request. but first, don't forget
+ // to delete the previous memory. You can delete it since the
+ // option is internally duplicated for the request.
+ delete mytest;
+ mytest = myPort.clone();
+ myRequest.setOpt(*mytest);
+ delete mytest;
+
+ // You can clone an option directly to the same type of
+ // option.
+ cURLpp::Options::Url *myUrl3 = myUrl.clone();
+ myRequest.setOpt(myUrl3);
+ // Now myUrl3 is owned by the request we will NOT use
+ // it anymore.
+
+
+ // You don't need to declare an option if you just want
+ // to use it once.
+ myRequest.setOpt(cURLpp::Options::Url("example.com"));
+
+
+ // Note that the previous line wasn't really efficient
+ // because we create the option, this option is duplicated
+ // for the request and then the option destructor is called.
+ // You can use this instead:
+ myRequest.setOpt(new cURLpp::Options::Url("example.com"));
+ // Note that with this the request will use directly this
+ // instance we just created. Be aware that if you pass an
+ // Option pointer to the setOpt function, it will consider
+ // the instance has its own instance. The Option instance
+ // will be deleted when the request will be deleted, so
+ // don't use the instance further in your code.
+
+
+ // Doing the previous line is efficient as this:
+ myRequest.setOpt(myUrl.clone());
+
+
+ // You can retrieve the value of a specific option.
+ std::cout << myUrl2.getValue() << std::endl;
+
+
+ // You can see what are the options set for a request
+ // with this function. This function will print the option
+ // to the stdout.
+ myRequest.print();
+
+ // Perform the transaction with the options set.
+ myRequest.perform();
+ }
+ catch( cURLpp::RuntimeError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+ catch( cURLpp::LogicError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+\end{verbatim}
+
+
+
+\subsection{cURLpp::Option types}
+This section will explain the use of the types that we use for
+some options that differ from types that libcurl uses for the
+same option.
+
+\subsubsection{The bool type}
+A true value is binded to a non-zero long value, a false value
+is binded to a zero long value.
+
+\subsubsection{The std::string type}
+The \verb+std::string::c_str()+ function is passed to libcurl.
+
+\subsubsection{The std::list template of std::string type}
+This type is used when libcurl's option need a \verb+curl_slist+. Instead of
+using this homemade struct, cURLpp allow you to use a known type, the
+\verb+std::list+. cURLpp this transform internally the \verb+std::list+
+to a \verb+curl_slist+.
+
+\subsection{cURLpp::Options}
+This section just list how each libcurl's option is binded by cURLpp.
+Some options might not be there, if it's the case and you want to use them,
+see the ``how to enhance cURLpp'' section.
+
+\subsubsection{Behavior options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< bool,
+ CURLOPT_VERBOSE > Verbose;
+ typedef cURLpp::OptionTrait< bool,
+ CURLOPT_HEADER > Header;
+ typedef cURLpp::OptionTrait< bool,
+ CURLOPT_NOSIGNAL > NoSignal;
+ typedef cURLpp::OptionTrait< bool,
+ CURLOPT_NOPROGRESS > NoProgress;
+\end{verbatim}
+
+\subsubsection{Callback options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< cURL::curl_write_callback,
+ CURLOPT_WRITEFUNCTION > WriteFunction;
+ typedef cURLpp::OptionTrait< void *,
+ CURLOPT_WRITEDATA > WriteData;
+ typedef cURLpp::OptionTrait< cURL::curl_read_callback,
+ CURLOPT_READFUNCTION > ReadFunction;
+ typedef cURLpp::OptionTrait< void *,
+ CURLOPT_READDATA > ReadData;
+ typedef cURLpp::OptionTrait< cURL::curl_progress_callback,
+ CURLOPT_PROGRESSFUNCTION > ProgressFunction;
+ typedef cURLpp::OptionTrait< void *,
+ CURLOPT_PROGRESSDATA > ProgressData;
+ typedef cURLpp::OptionTrait< cURL::curl_write_callback,
+ CURLOPT_HEADERFUNCTION > HeaderFunction;
+ typedef cURLpp::OptionTrait< void *,
+ CURLOPT_HEADERDATA > HeaderData;
+ typedef cURLpp::OptionTrait< cURL::curl_debug_callback,
+ CURLOPT_DEBUGFUNCTION > DebugFunction;
+ typedef cURLpp::OptionTrait< void *,
+ CURLOPT_DEBUGDATA > DebugData;
+#ifdef CURLOPT_SSL_CTX_FUNCTION
+ typedef cURLpp::OptionTrait< cURL::curl_ssl_ctx_callback,
+ CURLOPT_SSL_CTX_FUNCTION > SslCtxFunction;
+ typedef cURLpp::OptionTrait< void *,
+ cURL::CURLOPT_SSL_CTX_DATA > SslCtxData;
+#endif
+\end{verbatim}
+
+\subsubsection{Error options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< char *,
+ cURL::CURLOPT_ERRORBUFFER > ErrorBuffer;
+ typedef cURLpp::OptionTrait< FILE *,
+ cURL::CURLOPT_STDERR > StdErr;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FAILONERROR > FailOnError;
+\end{verbatim}
+
+\subsubsection{Network options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_URL > Url;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_PROXY > Proxy;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_PROXYPORT > ProxyPort;
+ typedef cURLpp::OptionTrait< curl_proxytype,
+ cURL::CURLOPT_PROXYTYPE > ProxyType;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_HTTPPROXYTUNNEL > HttpProxyTunnel;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_INTERFACE > Interface;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_DNS_CACHE_TIMEOUT > DnsCacheTimeout;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_DNS_USE_GLOBAL_CACHE > DnsUseGlobalCache;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_BUFFERSIZE > BufferSize;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_PORT > Port;
+#ifdef cURL::CURLOPT_TCP_NODELAY
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_TCP_NODELAY > TcpNoDelay;
+#endif
+\end{verbatim}
+
+
+\subsubsection{Names and passwords options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_NETRC > Netrc;
+#ifdef cURL::CURLOPT_NETRC_FILE
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_NETRC_FILE > NetrcFile;
+#endif
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_USERPWD > UserPwd;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_PROXYUSERPWD > ProxyUserPwd;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_HTTPAUTH > HttpAuth;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_PROXYAUTH > ProxyAuth;
+\end{verbatim}
+
+\subsubsection{HTTP options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_AUTOREFERER > AutoReferer;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_ENCODING > Encoding;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FOLLOWLOCATION > FollowLocation;
+#ifdef cURL::CURLOPT_UNRESTRICTED_AUTH
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_UNRESTRICTED_AUTH > UnrestrictedAuth;
+#endif
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_MAXREDIRS > MaxRedirs;
+#ifndef cURL::CURLOPT_UPLOAD
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_PUT > Put;
+#else
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_UPLOAD > Put;
+#endif
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_POST > Post;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_POSTFIELDS > PostFields;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_POSTFIELDSIZE > PostFieldSize;
+#ifdef cURL::CURLOPT_POSTFIELDSIZE_LARGE
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_POSTFIELDSIZE_LARGE > PostFieldSizeLarge;
+#endif
+ typedef cURLpp::OptionTrait< struct cURLpp::cURL::HttpPost *,
+ cURL::CURLOPT_HTTPPOST > HttpPost;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_REFERER > Referer;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_USERAGENT > UserAgent;
+ typedef cURLpp::OptionTrait< std::list< std::string >,
+ cURL::CURLOPT_HTTPHEADER > HttpHeader;
+ typedef cURLpp::OptionTrait< std::list< std::string >,
+ cURL::CURLOPT_HTTP200ALIASES > Http200Aliases;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_COOKIE > Cookie;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_COOKIEFILE > CookieFile;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_COOKIEJAR > CookieJar;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_COOKIESESSION > CookieSession;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_HTTPGET > HttpGet;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_HTTP_VERSION > HttpVersion;
+\end{verbatim}
+
+\subsubsection{FTP options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_FTPPORT > FtpPort;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_QUOTE > Quote;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_POSTQUOTE > PostQuote;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_PREQUOTE > PreQuote;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FTPLISTONLY > FtpListOnly;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FTPAPPEND > FtpAppend;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FTP_USE_EPSV > FtpUseEpsv;
+#ifdef cURL::CURLOPT_FTP_CREATE_MISSING_DIRS
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FTP_CREATE_MISSING_DIRS > FtpCreateMissingDirs;
+#endif
+#ifdef cURL::CURLOPT_FTP_RESPONSE_TIMEOUT
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FTP_RESPONSE_TIMEOUT > FtpResponseTimeout;
+#endif
+#ifdef cURL::CURLOPT_FTP_SSL
+ typedef cURLpp::OptionTrait< cURLpp::curl_ftpssl,
+ cURL::CURLOPT_FTP_SSL > FtpSsl;
+#endif
+#ifdef cURL::CURLOPT_FTP_AUTH
+ typedef cURLpp::OptionTrait< cURLpp::curl_ftpauth,
+ cURL::CURLOPT_FTP_AUTH > FtpAuth;
+#endif
+\end{verbatim}
+
+\subsubsection{Protocol options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_TRANSFERTEXT > TransferText;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_CRLF > Crlf;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_RANGE > Range;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_RESUME_FROM > ResumeFrom;
+#ifdef cURL::CURLOPT_RESUME_FROM_LARGE
+ typedef cURLpp::OptionTrait< curl_off_t,
+ cURL::CURLOPT_RESUME_FROM_LARGE > ResumeFromLarge;
+#endif
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_CUSTOMREQUEST > CustomRequest;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FILETIME > FileTime;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_NOBODY > NoBody;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_INFILESIZE > InfileSize;
+#ifdef cURL::CURLOPT_INFILESIZE_LARGE
+ typedef cURLpp::OptionTrait< cURL::curl_off_t,
+ cURL::CURLOPT_INFILESIZE_LARGE > InfileSizeLarge;
+#endif
+#ifdef cURL::CURLOPT_UPLOAD
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_UPLOAD > Upload;
+#else
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_PUT > Upload;
+#endif
+#ifdef cURL::CURLOPT_MAXFILESIZE
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_MAXFILESIZE > MaxFileSize;
+#endif
+#ifdef cURL::CURLOPT_MAXFILESIZE_LARGE
+ typedef cURLpp::OptionTrait< cURL::curl_off_t,
+ cURL::CURLOPT_MAXFILESIZE_LARGE > MaxFileSizeLarge;
+#endif
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_TIMECONDITION > TimeCondition;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_TIMECONDITION > TimeValue;
+\end{verbatim}
+
+\subsubsection{Connection options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_TIMEOUT > Timeout;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_LOW_SPEED_LIMIT > LowSpeedLimit;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_LOW_SPEED_TIME > LowSpeedTime;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_MAXCONNECTS > MaxConnects;
+ typedef cURLpp::OptionTrait< cURL::curl_closepolicy,
+ cURL::CURLOPT_CLOSEPOLICY > ClosePolicy;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FRESH_CONNECT > FreshConnect;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_FORBID_REUSE > ForbidReuse;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_CONNECTTIMEOUT > ConnectTimeout;
+#ifdef cURL::CURLOPT_IPRESOLVE
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_IPRESOLVE > IpResolve;
+#endif
+\end{verbatim}
+
+\subsubsection{SSL and security options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLCERT > SslCert;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLCERTTYPE > SslCertType;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLCERTPASSWD > SslCertPasswd;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLKEY > SslKey;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLKEYTYPE > SslKeyType;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLKEYPASSWD > SslKeyPasswd;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSLENGINE > SslEngine;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_SSLVERSION > SslVersion;
+ typedef cURLpp::OptionTrait< bool,
+ cURL::CURLOPT_SSL_VERIFYPEER > SslVerifyPeer;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_CAINFO > CaInfo;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_CAPATH > CaPath;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_RANDOM_FILE > RandomFile;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_EGDSOCKET > EgdSocket;
+ typedef cURLpp::OptionTrait< long,
+ cURL::CURLOPT_SSL_VERIFYHOST > SslVerifyHost;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_SSL_CIPHER_LIST > SslCipherList;
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_KRB4LEVEL > Krb4Level;
+\end{verbatim}
+
+\subsubsection{Others options}
+\begin{verbatim}
+ typedef cURLpp::OptionTrait< std::string,
+ cURL::CURLOPT_KRB4LEVEL > Krb4Level;
+\end{verbatim}
+
+
+\section{How the enhance cURLpp}
+Need to be written.
+
+\section{Exceptions issues}
+
+As previously said, cURLpp (libcurl in fact) offer the possibility to reimplement the data
+writing/reading functions. Those functions called from within libcurl might
+raise exceptions. Raising an exception in C code might cause problems. cURLpp
+protect you from doing so\footnote{This feature will be added only in the
+0.6.0 version}. All exceptions are caught by cURLpp before they could
+cause damage to libcurl. If you want to raise an exception within traits, you need
+to do this:
+
+\begin{verbatim}
+ cURLpp::raiseException(MyException(``Exception Raised'');
+\end{verbatim}
+
+Then, the \verb+cURLpp::Easy::perform()+ will raise your exception at the end of
+the process. If an exception is raised but not by this mechanism, a
+\verb+cURLpp::UnknownExceptionError+ will be raised.
+
+
+
+\end{document}
diff --git a/curlpp/examples/CMakeLists.txt b/curlpp/examples/CMakeLists.txt
new file mode 100644
index 0000000..b32f9ae
--- /dev/null
+++ b/curlpp/examples/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.0)
+include(FindPkgConfig)
+pkg_check_modules(CURLPP REQUIRED curlpp)
+
+set(CMAKE_CXX_STANDARD 11) # C++11...
+set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
+set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
+
+
+file(GLOB ExamplesFileList "*.cpp")
+
+# Create a meta target to create examples
+add_custom_target(build_all_examples COMMENT A target that requires all the examples.)
+
+message(STATUS "Creating build rules for Examples:")
+foreach(Example ${ExamplesFileList})
+ message(STATUS "\tCreating build rule for ${Example}")
+ # Get the name without extension or directory
+ get_filename_component(ExampleName ${Example} NAME_WE)
+ # Define example executable
+ add_executable(${ExampleName} ${Example})
+ # Link example against curlpp
+ target_link_libraries(${ExampleName} ${CURLPP_LDFLAGS})
+ # make the meta target depend on this example.
+ add_dependencies(build_all_examples ${ExampleName})
+endforeach(Example ${ExamplesFileList})
diff --git a/curlpp/examples/README b/curlpp/examples/README
new file mode 100644
index 0000000..c6f399c
--- /dev/null
+++ b/curlpp/examples/README
@@ -0,0 +1,36 @@
+configure.in is a good example to add curlpp to your project
+
+Note that example 22 is contains the easiest and shorter examples of cURLpp
+usage.
+
+ Example 01: This example is made to show you how you can use the Options.
+ Example 02: an upload example.
+ Example 03: verbose callback example.
+ Example 04: GetInfo example.
+ Example 05: Function functor for WriteFunction example.
+ Example 06: Method functor for WriteFunction example.
+ Example 07: Cookie interface example via getInfo.
+ Demonstrates usage of Infos::CookieList which example04 did not.
+ Example 08: verbose callback example, with exception safe handling.
+ Example 09: verbose callback example, with exception safe handling,
+ but without raiseException function.
+ Example 10: Binded function functor for WriteFunction example.
+ Example 11: Plain write function example.
+ Example 12: HTTP POST example.
+ Example 13: Simple Multi interface example.
+ Example 14: Multi interface example with info function example.
+ Example 15: Simple example for demonstrating the NoValueOptionTrait.
+ (SslEngineDefault)
+ Example 16: HTTP POST example with HTTP Authentification.
+ Example 17: Binded method functor for WriteFunction example.
+ Example 18: No longer available. This used to be a boost usage example, but it's no longer relevant since c++11.
+ Example 19: Multipart/formdata HTTP POST example.
+ Example 20: std::ostream usage.
+ Example 21: upload example with std::istream.
+ Example 22: Real easy and quick examples.
+ Example 23: Setting request options using iterators to custom container
+ of curlpp options.
+ Example 24: Binded method functor for DebugFunction example.
+
+
+
diff --git a/curlpp/examples/example00.cpp b/curlpp/examples/example00.cpp
new file mode 100644
index 0000000..81be6e3
--- /dev/null
+++ b/curlpp/examples/example00.cpp
@@ -0,0 +1,43 @@
+/**
+* \file
+* The most simple example.
+*
+*/
+
+#include
+#include
+#include
+
+
+using namespace curlpp::options;
+
+int main(int, char **)
+{
+ try
+ {
+ // That's all that is needed to do cleanup of used resources (RAII style).
+ curlpp::Cleanup myCleanup;
+
+ // Our request to be sent.
+ curlpp::Easy myRequest;
+
+ // Set the URL.
+ myRequest.setOpt("http://example.com");
+
+ // Send request and get a result.
+ // By default the result goes to standard output.
+ myRequest.perform();
+ }
+
+ catch(curlpp::RuntimeError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch(curlpp::LogicError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
diff --git a/curlpp/examples/example01.cpp b/curlpp/examples/example01.cpp
new file mode 100644
index 0000000..c07e21c
--- /dev/null
+++ b/curlpp/examples/example01.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Setting and copying options.
+*
+*/
+
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+
+namespace
+{
+const long MyPort = 80;
+}
+
+/**
+ * This example is made to show you how you can use the Options.
+ */
+int main(int, char **)
+{
+ try
+ {
+ curlpp::Cleanup myCleanup;
+
+ // First easy example.
+ {
+ // The first easiest example is to retreive the content of
+ // a web page and put it in a stream.
+ std::cout << curlpp::options::Url("http://example.com");
+
+ // You don't need to use just the standard outputs. You
+ // can use any stream:
+ std::ostringstream os;
+ os << curlpp::options::Url("http://example.com");
+ }
+
+ // More elaborate example.
+ {
+ // What the previous example done there was simply
+ // to create a curlpp::Easy class, which is the basic
+ // object in cURLpp, and then set the Url option.
+ // curlpp::options classes are the primitives that allow to specify
+ // values to the requests.
+ curlpp::options::Url myUrl(std::string("http://example.com"));
+ curlpp::Easy myRequest;
+ myRequest.setOpt(myUrl);
+
+ // Now that all the options we wanted to set are there, we need to
+ // actually do the request. the "perform" method does actually that.
+ // With that call, the request will be done and the content of that URL
+ // will be printed in std::cout (which is the default).
+ myRequest.perform();
+
+ // If we wanted to put the content of the URL within a string stream
+ // (or any type of std::ostream, for that matter), like the first example,
+ // we would use the WriteStrem option like this:
+ std::ostringstream os;
+ curlpp::options::WriteStream ws(&os);
+ myRequest.setOpt(ws);
+ myRequest.perform();
+
+ // There is some shorcut within curlpp that allow you to write shorter code
+ // like this:
+ os << myRequest;
+
+ // That would do exactly what the previous code was doing.
+ }
+
+ // Creation of the URL option.
+ curlpp::options::Url myUrl(std::string("http://example.com"));
+
+ // Copy construct from the other URL.
+ curlpp::options::Url myUrl2(myUrl);
+
+ // Creation of the port option.
+ curlpp::options::Port myPort(MyPort);
+
+ // Creation of the request.
+ curlpp::Easy myRequest;
+
+ // Creation of an option that contain a copy of the URL option.
+ curlpp::OptionBase *mytest = myUrl.clone();
+ myRequest.setOpt(*mytest);
+
+ // You can reuse the base option for other type of option
+ // and set the option to the request. but first, don't forget
+ // to delete the previous memory. You can delete it since the
+ // option is internally duplicated for the request.
+ delete mytest;
+ mytest = myPort.clone();
+ myRequest.setOpt(*mytest);
+ delete mytest;
+
+ // You can clone an option directly to the same type of
+ // option.
+ curlpp::options::Url *myUrl3 = myUrl.clone();
+ myRequest.setOpt(myUrl3);
+ // Now myUrl3 is owned by the request we will NOT use
+ // it anymore.
+
+
+ // You don't need to declare an option if you just want
+ // to use it once.
+ myRequest.setOpt(curlpp::options::Url("example.com"));
+
+
+ // Note that the previous line wasn't really efficient
+ // because we create the option, this option is duplicated
+ // for the request and then the option destructor is called.
+ // You can use this instead:
+ myRequest.setOpt(new curlpp::options::Url("example.com"));
+ // Note that with this the request will use directly this
+ // instance we just created. Be aware that if you pass an
+ // Option pointer to the setOpt function, it will consider
+ // the instance has its own instance. The Option instance
+ // will be deleted when the request will be deleted, so
+ // don't use the instance further in your code.
+
+
+ // Doing the previous line is efficient as this:
+ myRequest.setOpt(myUrl.clone());
+
+
+ // You can retreive the value of a specific option.
+ std::cout << myUrl2.getValue() << std::endl;
+
+ // Perform the transaction with the options set.
+ myRequest.perform();
+ }
+
+ catch( curlpp::RuntimeError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch( curlpp::LogicError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
diff --git a/curlpp/examples/example02.cpp b/curlpp/examples/example02.cpp
new file mode 100644
index 0000000..b66db2e
--- /dev/null
+++ b/curlpp/examples/example02.cpp
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) <2002-2005>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* \file
+* Uploading of string.
+* ReadFunction option using functor.
+* Setting custom headers.
+*/
+
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+/*
+ anonymous namespace to prevent name clash in case other examples using the same global entities
+ would be compiled in the same project
+*/
+namespace
+{
+
+char *data = NULL;
+
+size_t readData(char *buffer, size_t size, size_t nitems)
+{
+ strncpy(buffer, data, size * nitems);
+ return size * nitems;
+}
+
+} // namespace
+
+int main(int argc, char *argv[])
+{
+ if(argc != 3)
+ {
+ std::cerr << "Example 2: Missing argument" << std::endl
+ << "Example 2: Usage: example02 url string-to-send"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+ data = argv[2];
+ int size = strlen(data);
+
+ char buf[50];
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ std::list headers;
+ headers.push_back("Content-Type: text/*");
+ sprintf(buf, "Content-Length: %d", size);
+ headers.push_back(buf);
+
+ using namespace curlpp::Options;
+ request.setOpt(new Verbose(true));
+ request.setOpt(new ReadFunction(curlpp::types::ReadFunctionFunctor(readData)));
+ request.setOpt(new InfileSize(size));
+ request.setOpt(new Upload(true));
+ request.setOpt(new HttpHeader(headers));
+ request.setOpt(new Url(url));
+
+ request.perform();
+ }
+ catch (curlpp::LogicError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+ catch (curlpp::RuntimeError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example03.cpp b/curlpp/examples/example03.cpp
new file mode 100644
index 0000000..6230614
--- /dev/null
+++ b/curlpp/examples/example03.cpp
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) <2002-2005>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* \file
+* DebugFunction option using functor as a callback.
+*/
+
+
+#include
+
+#include
+#include
+#include
+#include
+
+class MyWindow
+{
+public:
+ int writeDebug(curl_infotype, char *data, size_t size)
+ {
+ fprintf(stderr, "Debug: ");
+ fwrite(data, size, 1, stderr);
+ return size;
+ }
+};
+
+int main(int argc, char *argv[])
+{
+
+ if(argc != 2)
+ {
+ std::cerr << "Example 3: Wrong number of arguments" << std::endl
+ << "Example 3: Usage: example3 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ MyWindow myWindow;
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ using namespace curlpp::Options;
+ request.setOpt(Verbose(true));
+ using namespace std::placeholders;
+ request.setOpt(DebugFunction(std::bind(&MyWindow::writeDebug, &myWindow, _1, _2, _3)));
+ request.setOpt(Url(url));
+
+ request.perform();
+ }
+
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example04.cpp b/curlpp/examples/example04.cpp
new file mode 100644
index 0000000..c9e91bf
--- /dev/null
+++ b/curlpp/examples/example04.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Getting options using curlpp::infos.
+*
+*/
+
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ {
+ std::cerr << "Example 04: Wrong number of arguments" << std::endl
+ << "Example 04: Usage: example04 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ using namespace curlpp::Options;
+ request.setOpt(Verbose(true));
+ request.setOpt(Url(url));
+
+ request.perform();
+
+ std::string effURL;
+ curlpp::infos::EffectiveUrl::get(request, effURL);
+ std::cout << "Effective URL: " << effURL << std::endl;
+
+ //other way to retreive URL
+ std::cout << std::endl
+ << "Effective URL: "
+ << curlpp::infos::EffectiveUrl::get(request)
+ << std::endl;
+
+ std::cout << "Response code: "
+ << curlpp::infos::ResponseCode::get(request)
+ << std::endl;
+
+ std::cout << "SSL engines: "
+ << curlpp::infos::SslEngines::get(request)
+ << std::endl;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example05.cpp b/curlpp/examples/example05.cpp
new file mode 100644
index 0000000..346913c
--- /dev/null
+++ b/curlpp/examples/example05.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Write function using free function as a callback.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#define MAX_FILE_LENGTH 20000
+
+char *m_pBuffer = NULL;
+size_t m_Size = 0;
+
+void* Realloc(void* ptr, size_t size)
+{
+ if(ptr)
+ return realloc(ptr, size);
+ else
+ return malloc(size);
+};
+
+// Callback must be declared static, otherwise it won't link...
+size_t WriteMemoryCallback(char* ptr, size_t size, size_t nmemb)
+{
+ // Calculate the real size of the incoming buffer
+ size_t realsize = size * nmemb;
+
+ // (Re)Allocate memory for the buffer
+ m_pBuffer = (char*) Realloc(m_pBuffer, m_Size + realsize);
+
+ // Test if Buffer is initialized correctly & copy memory
+ if (m_pBuffer == NULL) {
+ realsize = 0;
+ }
+
+ memcpy(&(m_pBuffer[m_Size]), ptr, realsize);
+ m_Size += realsize;
+
+ // return the real size of the buffer...
+ return realsize;
+};
+
+
+void print()
+{
+ std::cout << "Size: " << m_Size << std::endl;
+ std::cout << "Content: " << std::endl << m_pBuffer << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+ m_pBuffer = (char*) malloc(MAX_FILE_LENGTH * sizeof(char));
+
+ if(argc != 2)
+ {
+ std::cerr << "Example 05: Wrong number of arguments" << std::endl
+ << "Example 05: Usage: example05 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ // Set the writer callback to enable cURL
+ // to write result in a memory area
+ curlpp::types::WriteFunctionFunctor functor(WriteMemoryCallback);
+ curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
+ request.setOpt(test);
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+ request.perform();
+
+ print();
+ }
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+}
diff --git a/curlpp/examples/example06.cpp b/curlpp/examples/example06.cpp
new file mode 100644
index 0000000..78cfe1d
--- /dev/null
+++ b/curlpp/examples/example06.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* WriteFunction option using functor as a callback.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#define MAX_FILE_LENGTH 20000
+
+class WriterMemoryClass
+{
+public:
+ // Helper Class for reading result from remote host
+ WriterMemoryClass()
+ {
+ this->m_pBuffer = NULL;
+ this->m_pBuffer = (char*) malloc(MAX_FILE_LENGTH * sizeof(char));
+ this->m_Size = 0;
+ };
+
+ ~WriterMemoryClass()
+ {
+ if (this->m_pBuffer)
+ free(this->m_pBuffer);
+ };
+
+ void* Realloc(void* ptr, size_t size)
+ {
+ if(ptr)
+ return realloc(ptr, size);
+ else
+ return malloc(size);
+ };
+
+ // Callback must be declared static, otherwise it won't link...
+ size_t WriteMemoryCallback(char* ptr, size_t size, size_t nmemb)
+ {
+ // Calculate the real size of the incoming buffer
+ size_t realsize = size * nmemb;
+
+ // (Re)Allocate memory for the buffer
+ m_pBuffer = (char*) Realloc(m_pBuffer, m_Size + realsize);
+
+ // Test if Buffer is initialized correctly & copy memory
+ if (m_pBuffer == NULL) {
+ realsize = 0;
+ }
+
+ memcpy(&(m_pBuffer[m_Size]), ptr, realsize);
+ m_Size += realsize;
+
+
+ // return the real size of the buffer...
+ return realsize;
+ };
+
+
+ void print()
+ {
+ std::cout << "Size: " << m_Size << std::endl;
+ std::cout << "Content: " << std::endl << m_pBuffer << std::endl;
+ }
+
+ // Public member vars
+ char* m_pBuffer;
+ size_t m_Size;
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ {
+ std::cerr << "Example 06: Wrong number of arguments" << std::endl
+ << "Example 06: Usage: example06 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ WriterMemoryClass mWriterChunk;
+
+ // Set the writer callback to enable cURL
+ // to write result in a memory area
+ using namespace std::placeholders;
+ curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, _1, _2, _3);
+
+ curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
+ request.setOpt(test);
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+ request.perform();
+
+ mWriterChunk.print();
+ }
+
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+}
diff --git a/curlpp/examples/example07.cpp b/curlpp/examples/example07.cpp
new file mode 100644
index 0000000..9a97c64
--- /dev/null
+++ b/curlpp/examples/example07.cpp
@@ -0,0 +1,174 @@
+/**
+* \file
+* Cookies.
+*
+*/
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+
+#define CURLPP_ALLOW_NOT_AVAILABLE
+
+#include
+#include
+
+
+class YesNo
+{
+public:
+ explicit YesNo(bool yn) : yesno(yn) {}
+ std::string operator()() const {
+ return yesno ? "Yes" : "No";
+ }
+ friend std::ostream &operator<<(std::ostream &strm, const YesNo &yn) {
+ strm << yn();
+ return strm;
+ }
+private:
+ bool yesno;
+};
+
+struct MyCookie
+{
+ std::string name;
+ std::string value;
+ std::string domain;
+ std::string path;
+ time_t expires;
+ bool tail;
+ bool secure;
+};
+
+std::ostream &
+operator<<(std::ostream &strm, const MyCookie &cook)
+{
+ strm << "Cookie: '" << cook.name << "' (secure: " << YesNo(cook.secure) << ", tail: "
+ << YesNo(cook.tail) << ") for domain: '" << cook.domain << "', "
+ << "path: '" << cook.path << "'.\n";
+ strm << "Value: '" << cook.value << "'.\n";
+ strm << "Expires: '" << ctime(&cook.expires) << "'.\n";
+
+ return strm;
+}
+
+std::vector &
+split_cookie_str(const std::string &str, std::vector &in)
+{
+ std::string part;
+
+ std::istringstream strm(str);
+ while (getline(strm, part, '\t'))
+ in.push_back(part);
+
+ return in;
+}
+
+std::vector
+splitCookieStr(const std::string &str)
+{
+ std::vector split;
+ split_cookie_str(str, split);
+ return split;
+}
+
+std::vector &
+splitCookieStr(const std::string &str, std::vector &in)
+{
+ return split_cookie_str(str, in);
+}
+
+int StrToInt(const std::string &str)
+{
+ std::istringstream strm(str);
+ int i = 0;
+ if (!(strm >> i)) {
+ throw curlpp::RuntimeError("Unable to convert string '" + str + "' to integer!");
+ }
+ return i;
+}
+
+MyCookie
+MakeCookie(const std::string &str_cookie)
+{
+ std::vector vC = splitCookieStr(str_cookie);
+ MyCookie cook;
+
+ cook.domain = vC[0];
+ cook.tail = vC[1] == "TRUE";
+ cook.path = vC[2];
+ cook.secure = vC[3] == "TRUE";
+ cook.expires = StrToInt(vC[4]);
+ cook.name = vC[5];
+ cook.value = vC[6];
+
+ return cook;
+}
+
+int
+main(void)
+{
+ try
+ {
+ curlpp::Cleanup myCleanup;
+ curlpp::Easy exEasy;
+ std::vector cookieList;
+
+ // a cookie as in HTTP header
+ cookieList.push_back("Set-Cookie: GMAIL_AT=EXPIRED;expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
+
+ // a Netscape style cookie with \t
+ cookieList.push_back(".google.com\tTRUE\t/\tFALSE\t2147483647\tLSID\tI like you GOOGLE");
+
+ // a Netscape style cookie with tabs in string
+ cookieList.push_back(".yahoo.com TRUE / FALSE 0 YAHOO_COOKIE I like you yahoo, too");
+
+ exEasy.setOpt(new curlpp::options::Url("http://www.google.com"));
+ exEasy.setOpt(new curlpp::options::FileTime(true));
+ exEasy.setOpt(new curlpp::options::Verbose(true));
+
+ // loop throught the cookies and add one by one
+ //
+ for (std::vector::iterator it = cookieList.begin();
+ it != cookieList.end();
+ ++it)
+ {
+ exEasy.setOpt(curlpp::options::CookieList(*it));
+ }
+ exEasy.perform();
+
+ // see what cookies we got
+ //
+ std::cout << "\nCookies from cookie engine:" << std::endl;
+ std::list cookies;
+ curlpp::infos::CookieList::get(exEasy, cookies);
+ int i = 1;
+ for (std::list::const_iterator it = cookies.begin();
+ it != cookies.end();
+ ++it, i++)
+ {
+ std::cout << "[" << i << "]: " << MakeCookie(*it) << std::endl;
+ }
+
+ exit(EXIT_SUCCESS);
+ }
+
+ catch(curlpp::RuntimeError &e)
+ {
+ std::cerr << e.what() << std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ catch(curlpp::LogicError &e)
+ {
+ std::cout << e.what() << std::endl;
+ exit(EXIT_FAILURE);
+ }
+}
diff --git a/curlpp/examples/example08.cpp b/curlpp/examples/example08.cpp
new file mode 100644
index 0000000..a56302c
--- /dev/null
+++ b/curlpp/examples/example08.cpp
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) <2002-2005>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* \file
+* DebugFunction option using functor.
+*
+*/
+
+
+#include
+
+#include
+#include
+#include
+#include
+
+
+
+class MyWindow
+{
+
+public:
+
+ int writeDebug(curl_infotype, char *, size_t)
+ {
+ curlpp::raiseException(std::runtime_error("This is our exception."));
+ std::cout << "We never reach this line." << std::endl;
+ return 0;
+ }
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ {
+ std::cerr << "Example 8: Wrong number of arguments" << std::endl
+ << "Example 8: Usage: example8 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ MyWindow myWindow;
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ using namespace curlpp::Options;
+ request.setOpt(Verbose(true));
+ using namespace std::placeholders;
+ request.setOpt(DebugFunction(std::bind(&MyWindow::writeDebug, &myWindow, _1, _2, _3)));
+ request.setOpt(Url(url));
+
+ request.perform();
+ }
+
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( std::runtime_error &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example09.cpp b/curlpp/examples/example09.cpp
new file mode 100644
index 0000000..fb97643
--- /dev/null
+++ b/curlpp/examples/example09.cpp
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) <2002-2005>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* \file
+* DebugFunction option using functor.
+*
+*/
+
+
+#include
+
+#include
+#include
+#include
+#include
+
+
+class MyWindow
+{
+
+public:
+
+ int writeDebug(curl_infotype, char *, size_t)
+ {
+ throw std::runtime_error("This is the unknown exception.");
+ std::cout << "We never reach this line." << std::endl;
+ return 0;
+ }
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ {
+ std::cerr << "Example 9: Wrong number of arguments" << std::endl
+ << "Example 9: Usage: example9 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ MyWindow myWindow;
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ using namespace curlpp::Options;
+ request.setOpt(Verbose(true));
+ using namespace std::placeholders;
+ request.setOpt(DebugFunction(std::bind(&MyWindow::writeDebug, &myWindow, _1, _2, _3)));
+ request.setOpt(Url(url));
+
+ request.perform();
+ }
+
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( std::runtime_error &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example10.cpp b/curlpp/examples/example10.cpp
new file mode 100644
index 0000000..e406122
--- /dev/null
+++ b/curlpp/examples/example10.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* WriteFunction option using functor.
+* Writing to FILE*
+*
+*/
+
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#define MAX_FILE_LENGTH 20000
+
+size_t
+FileCallback(FILE *f, char* ptr, size_t size, size_t nmemb)
+{
+ return fwrite(ptr, size, nmemb, f);
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 3)
+ {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url file"
+ << std::endl;
+
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+ char *filename = argv[2];
+ FILE * file = fopen(filename, "w");
+ if (!file)
+ {
+ std::cerr << "Error opening " << filename << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ // Set the writer callback to enable cURL to write result in a memory area
+ using namespace std::placeholders;
+ curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(std::bind(&FileCallback, file, _1, _2, _3));
+ request.setOpt(test);
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+ request.perform();
+
+ return EXIT_SUCCESS;
+ }
+
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/examples/example11.cpp b/curlpp/examples/example11.cpp
new file mode 100644
index 0000000..64d6676
--- /dev/null
+++ b/curlpp/examples/example11.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* WriteFunction option using free function.
+* Writing to FILE*
+*
+*/
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+
+/// Callback must be declared static, otherwise it won't link...
+size_t WriteCallback(char* ptr, size_t size, size_t nmemb, void *f)
+{
+ FILE *file = (FILE *)f;
+ return fwrite(ptr, size, nmemb, file);
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2)
+ {
+ std::cerr << "Example 11: Wrong number of arguments" << std::endl
+ << "Example 11: Usage: example11 url [file]"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+ char *filename = NULL;
+ if(argc >= 3)
+ {
+ filename = argv[2];
+ }
+
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ /// Set the writer callback to enable cURL to write result in a memory area
+ curlpp::options::WriteFunctionCurlFunction
+ myFunction(WriteCallback);
+
+ FILE *file = stdout;
+ if(filename != NULL)
+ {
+ file = fopen(filename, "wb");
+ if(file == NULL)
+ {
+ fprintf(stderr, "%s/n", strerror(errno));
+ return EXIT_FAILURE;
+ }
+ }
+
+ curlpp::OptionTrait
+ myData(file);
+
+ request.setOpt(myFunction);
+ request.setOpt(myData);
+
+ /// Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+ request.perform();
+ }
+
+ catch (curlpp::LogicError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch (curlpp::RuntimeError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+}
diff --git a/curlpp/examples/example12.cpp b/curlpp/examples/example12.cpp
new file mode 100644
index 0000000..f59a30c
--- /dev/null
+++ b/curlpp/examples/example12.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Simple POST demo.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2) {
+ std::cerr << "Example 11: Wrong number of arguments" << std::endl
+ << "Example 11: Usage: example12 url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+
+ std::list header;
+ header.push_back("Content-Type: application/octet-stream");
+
+ request.setOpt(new curlpp::options::HttpHeader(header));
+
+ request.setOpt(new curlpp::options::PostFields("abcd"));
+ request.setOpt(new curlpp::options::PostFieldSize(5));
+
+ request.perform();
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/curlpp/examples/example13.cpp b/curlpp/examples/example13.cpp
new file mode 100644
index 0000000..b989ae8
--- /dev/null
+++ b/curlpp/examples/example13.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) <2002-2006>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Simple Multi demo.
+*
+*/
+
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#pragma comment(lib, "Ws2_32.lib")
+#endif // WIN32
+
+int main(int argc, char *argv[])
+{
+ if(argc < 3) {
+ std::cerr << "Example 13: Wrong number of arguments" << std::endl
+ << "Example 13: Usage: example13 url1 url2"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url1 = argv[1];
+ char *url2 = argv[2];
+
+ try {
+ curlpp::Cleanup cleaner;
+
+ curlpp::Easy request1;
+ curlpp::Easy request2;
+
+ request1.setOpt(new curlpp::options::Url(url1));
+ request1.setOpt(new curlpp::options::Verbose(true));
+
+ request2.setOpt(new curlpp::options::Url(url2));
+ request2.setOpt(new curlpp::options::Verbose(true));
+
+ int nbLeft;
+ curlpp::Multi requests;
+ requests.add(&request1);
+ requests.add(&request2);
+
+ /* we start some action by calling perform right away */
+ while(!requests.perform(&nbLeft)) {};
+
+ while(nbLeft) {
+ struct timeval timeout;
+ int rc; /* select() return code */
+
+ fd_set fdread;
+ fd_set fdwrite;
+ fd_set fdexcep;
+ int maxfd;
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ /* set a suitable timeout to play around with */
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ /* get file descriptors from the transfers */
+ requests.fdset(&fdread, &fdwrite, &fdexcep, &maxfd);
+
+ rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ switch(rc) {
+ case -1:
+ /* select error */
+ nbLeft = 0;
+ printf("select() returns error, this is badness\n");
+ break;
+ case 0:
+ default:
+ /* timeout or readable/writable sockets */
+ while(!requests.perform(&nbLeft)) {};
+ break;
+ }
+ }
+
+ std::cout << "NB lefts: " << nbLeft << std::endl;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
diff --git a/curlpp/examples/example14.cpp b/curlpp/examples/example14.cpp
new file mode 100644
index 0000000..08c1196
--- /dev/null
+++ b/curlpp/examples/example14.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) <2002-2006>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Multi demo.
+*
+*/
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#pragma comment(lib, "Ws2_32.lib")
+#endif // WIN32
+
+int main(int argc, char *argv[])
+{
+ if(argc < 3) {
+ std::cerr << "Example 13: Wrong number of arguments" << std::endl
+ << "Example 13: Usage: example13 url1 url2"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url1 = argv[1];
+ char *url2 = argv[2];
+
+ try {
+ curlpp::Cleanup cleaner;
+
+ curlpp::Easy request1;
+ curlpp::Easy request2;
+
+ request1.setOpt(new curlpp::options::Url(url1));
+ request1.setOpt(new curlpp::options::Verbose(true));
+
+ request2.setOpt(new curlpp::options::Url(url2));
+ request2.setOpt(new curlpp::options::Verbose(true));
+
+ int nbLeft;
+ curlpp::Multi requests;
+ requests.add(&request1);
+ requests.add(&request2);
+
+ /* we start some action by calling perform right away */
+ while(!requests.perform(&nbLeft)) {};
+
+ while(nbLeft) {
+ struct timeval timeout;
+ int rc; /* select() return code */
+
+ fd_set fdread;
+ fd_set fdwrite;
+ fd_set fdexcep;
+ int maxfd;
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ /* set a suitable timeout to play around with */
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ /* get file descriptors from the transfers */
+ requests.fdset(&fdread, &fdwrite, &fdexcep, &maxfd);
+
+ rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+ switch(rc) {
+ case -1:
+ /* select error */
+ nbLeft = 0;
+ printf("select() returns error, this is badness\n");
+ break;
+ case 0:
+ /* timeout, do something else */
+ break;
+ default:
+ /* one or more of curl's file descriptors say there's data to read
+ or write */
+ while(!requests.perform(&nbLeft)) {};
+ break;
+ }
+ }
+
+ std::cout << "NB lefts: " << nbLeft << std::endl;
+
+ /* See how the transfers went */
+ /*
+ Multi::info returns a list of:
+ std::pair< curlpp::Easy, curlpp::Multi::Info >
+ */
+ curlpp::Multi::Msgs msgs = requests.info();
+ for(curlpp::Multi::Msgs::iterator pos = msgs.begin();
+ pos != msgs.end();
+ pos++) {
+ if(pos->second.msg == CURLMSG_DONE) {
+
+ /* Find out which handle this message is about */
+ if(pos->first == &request1) {
+ printf("First request completed with status %d\n", pos->second.code);
+ }
+ else if(pos->first == &request2) {
+ printf("Second request completed with status %d\n", pos->second.code);
+ }
+ }
+ }
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
diff --git a/curlpp/examples/example15.cpp b/curlpp/examples/example15.cpp
new file mode 100644
index 0000000..c2b2834
--- /dev/null
+++ b/curlpp/examples/example15.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Using options.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+
+
+int main(int, char **)
+{
+ try
+ {
+ curlpp::Cleanup myCleanup;
+
+ // Creation of the URL option.
+ curlpp::Easy myRequest;
+ myRequest.setOpt(new curlpp::options::Url(std::string("https://example.com")));
+ myRequest.setOpt(new curlpp::options::SslEngineDefault());
+ myRequest.perform();
+ }
+ catch( curlpp::RuntimeError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+ catch( curlpp::LogicError &e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
diff --git a/curlpp/examples/example16.cpp b/curlpp/examples/example16.cpp
new file mode 100644
index 0000000..13557a3
--- /dev/null
+++ b/curlpp/examples/example16.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Simple POST demo.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << "Usage: " << argv[0] << " url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+
+ std::list header;
+ header.push_back("Content-Type: application/octet-stream");
+
+ request.setOpt(new curlpp::options::HttpHeader(header));
+
+ request.setOpt(new curlpp::options::PostFields("abcd"));
+ request.setOpt(new curlpp::options::PostFieldSize(5));
+
+ request.setOpt(new curlpp::options::UserPwd("user:password"));
+
+ request.perform();
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/curlpp/examples/example17.cpp b/curlpp/examples/example17.cpp
new file mode 100644
index 0000000..db7a959
--- /dev/null
+++ b/curlpp/examples/example17.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+struct MethodClass
+{
+private:
+ MethodClass();
+
+public:
+ MethodClass(std::ostream * stream)
+ : mStream(stream)
+ , writeRound(0)
+ {}
+
+ // Helper Class for reading result from remote host
+ size_t write(curlpp::Easy *handle, char* ptr, size_t size, size_t nmemb)
+ {
+ ++writeRound;
+
+ curlpp::options::Url url;
+ handle->getOpt(url);
+
+ // Calculate the real size of the incoming buffer
+ size_t realsize = size * nmemb;
+ std::cerr << "write round: " << writeRound << ", url: " << url.getValue() << std::endl;
+ mStream->write(ptr, realsize);
+ // return the real size of the buffer...
+ return realsize;
+ };
+
+ // Public member vars
+ std::ostream * mStream;
+ unsigned writeRound;
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url "
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ MethodClass mObject(&std::cout);
+
+ // Set the writer callback to enable cURL
+ // to write result in a memory area
+ using namespace std::placeholders;
+ curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(std::bind(&MethodClass::write, &mObject, &request, _1, _2, _3));
+ request.setOpt(test);
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.perform();
+
+ return EXIT_SUCCESS;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/examples/example18.cpp b/curlpp/examples/example18.cpp
new file mode 100644
index 0000000..21f4c56
--- /dev/null
+++ b/curlpp/examples/example18.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* WriteFunction using streams.
+*
+*/
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+
+struct MethodClass
+{
+private:
+ MethodClass();
+
+public:
+ MethodClass(std::ostream * stream)
+ : mStream(stream)
+ , writeRound(0)
+ {}
+
+ // Helper Class for reading result from remote host
+ size_t write(curlpp::Easy *handle, char* ptr, size_t size, size_t nmemb)
+ {
+ ++writeRound;
+
+ curlpp::options::Url url;
+ handle->getOpt(url);
+
+ // Calculate the real size of the incoming buffer
+ size_t realsize = size * nmemb;
+ std::cerr << "write round: " << writeRound << ", url: " << url.getValue() << std::endl;
+ mStream->write(ptr, realsize);
+ // return the real size of the buffer...
+ return realsize;
+ };
+
+ // Public member vars
+ std::ostream * mStream;
+ unsigned writeRound;
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url "
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ std::ostringstream myStream;
+ MethodClass mObject(&myStream);
+
+
+ // Set the writer callback to enable cURL
+ // to write result in a memory area
+#ifdef HAVE_BOOST
+ curlpp::options::BoostWriteFunction *test = new curlpp::options::BoostWriteFunction(boost::bind(&MethodClass::write, &mObject, &request, _1, _2, _3));
+ request.setOpt(test);
+#endif /* HAVE_BOOST */
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+
+ request.perform();
+
+ return EXIT_SUCCESS;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/examples/example19.cpp b/curlpp/examples/example19.cpp
new file mode 100644
index 0000000..86e158e
--- /dev/null
+++ b/curlpp/examples/example19.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Forms demo.
+*
+*/
+
+
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << "Usage: " << argv[0] << " url"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ request.setOpt(new curlpp::options::Url(url));
+ //request.setOpt(new curlpp::options::Verbose(true));
+
+ {
+ // Forms takes ownership of pointers!
+ curlpp::Forms formParts;
+ formParts.push_back(new curlpp::FormParts::Content("name1", "value1"));
+ formParts.push_back(new curlpp::FormParts::Content("name2", "value2"));
+
+ request.setOpt(new curlpp::options::HttpPost(formParts));
+ }
+
+ // The forms have been cloned and are valid for the request, even
+ // if the original forms are out of scope.
+ std::ofstream myfile("/dev/null");
+ myfile << request << std::endl << request << std::endl;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/curlpp/examples/example20.cpp b/curlpp/examples/example20.cpp
new file mode 100644
index 0000000..8e6ae27
--- /dev/null
+++ b/curlpp/examples/example20.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Using WriteStream option.
+*
+*/
+
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url "
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ // Set the writer callback to enable cURL
+ // to write result in a memory area
+ request.setOpt(new curlpp::options::WriteStream(&std::cout));
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+
+ request.perform();
+
+ return EXIT_SUCCESS;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/examples/example21.cpp b/curlpp/examples/example21.cpp
new file mode 100644
index 0000000..6ec6dcf
--- /dev/null
+++ b/curlpp/examples/example21.cpp
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) <2002-2005>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* \file
+* Using ReadStream option.
+*
+*/
+
+
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if(argc != 3) {
+ std::cerr << "Example 2: Missing argument" << std::endl
+ << "Example 2: Usage: example02 url string-to-send"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+ char *url = argv[1];
+
+ std::istringstream myStream(argv[2]);
+ int size = myStream.str().size();
+
+ char buf[50];
+ try
+ {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ std::list< std::string > headers;
+ headers.push_back("Content-Type: text/*");
+ sprintf(buf, "Content-Length: %d", size);
+ headers.push_back(buf);
+
+ using namespace curlpp::Options;
+ request.setOpt(new Verbose(true));
+ request.setOpt(new ReadStream(&myStream));
+ request.setOpt(new InfileSize(size));
+ request.setOpt(new Upload(true));
+ request.setOpt(new HttpHeader(headers));
+ request.setOpt(new Url(url));
+
+ request.perform();
+ }
+ catch ( curlpp::LogicError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e )
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
+
diff --git a/curlpp/examples/example22.cpp b/curlpp/examples/example22.cpp
new file mode 100644
index 0000000..9e90618
--- /dev/null
+++ b/curlpp/examples/example22.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+* \file
+* Using options::Url as stream input.
+*
+*/
+
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url "
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+
+ std::cout << request << std::endl;
+
+ // Even easier version. It does the same thing
+ // but if you need to download only an url,
+ // this is the easiest way to do it.
+ std::cout << curlpp::options::Url(url) << std::endl;
+
+ return EXIT_SUCCESS;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/examples/example23.cpp b/curlpp/examples/example23.cpp
new file mode 100644
index 0000000..73b207a
--- /dev/null
+++ b/curlpp/examples/example23.cpp
@@ -0,0 +1,55 @@
+/**
+* \file
+* Setting request options using iterators to custom container of curlpp options.
+*
+*/
+
+#include
+
+#include
+#include
+#include
+
+
+using namespace curlpp::options;
+
+int main(int, char **)
+{
+
+ try
+ {
+
+ // That's all that is needed to do cleanup of used resources (RAII style).
+ curlpp::Cleanup myCleanup;
+
+ // Our request to be sent.
+ curlpp::Easy myRequest;
+
+ // Container of our choice with pointers to curlpp options.
+ std::vector options;
+
+ options.push_back(new Url("http://example.com"));
+ options.push_back(new Port(80));
+
+ // Set all options in range to the Easy handle.
+ myRequest.setOpt(options.begin(), options.end());
+
+ // Send request and get a result.
+ // By default the result goes to standard output.
+ myRequest.perform();
+
+ }
+
+
+ catch(curlpp::RuntimeError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ catch(curlpp::LogicError & e)
+ {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
diff --git a/curlpp/examples/example24.cpp b/curlpp/examples/example24.cpp
new file mode 100644
index 0000000..3d5213c
--- /dev/null
+++ b/curlpp/examples/example24.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) <2002-2005>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+struct MethodClass
+{
+private:
+ MethodClass();
+
+public:
+ MethodClass(std::ostream * stream)
+ : mStream(stream)
+ , writeRound(0)
+ {}
+
+ // Helper Class for reading result from remote host
+ size_t debug(curlpp::Easy *handle, curl_infotype type, char* ptr, size_t size)
+ {
+ ++writeRound;
+
+ curlpp::options::Url url;
+ handle->getOpt(url);
+
+ // Calculate the real size of the incoming buffer
+ std::cerr << "write round: " << writeRound << ", url: " << url.getValue() << ", type: " << type << std::endl;
+ mStream->write(ptr, size);
+
+ // return the real size of the buffer...
+ return size;
+ };
+
+ // Public member vars
+ std::ostream * mStream;
+ unsigned writeRound;
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ std::cerr << argv[0] << ": Wrong number of arguments" << std::endl
+ << argv[0] << ": Usage: " << " url "
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ char *url = argv[1];
+
+ try {
+ curlpp::Cleanup cleaner;
+ curlpp::Easy request;
+
+ MethodClass mObject(&std::cerr);
+
+ // Set the debug callback to enable cURL
+ // to write result in a stream
+ using namespace std::placeholders;
+ curlpp::options::DebugFunction * test = new curlpp::options::DebugFunction(std::bind(&MethodClass::debug, &mObject, &request, _1, _2, _3));
+ request.setOpt(test);
+
+ // Setting the URL to retrive.
+ request.setOpt(new curlpp::options::Url(url));
+ request.setOpt(new curlpp::options::Verbose(true));
+ request.perform();
+
+ return EXIT_SUCCESS;
+ }
+ catch ( curlpp::LogicError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+ catch ( curlpp::RuntimeError & e ) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/curlpp/extras/CMakeLists.txt b/curlpp/extras/CMakeLists.txt
new file mode 100644
index 0000000..5a474ab
--- /dev/null
+++ b/curlpp/extras/CMakeLists.txt
@@ -0,0 +1,40 @@
+# extracting curlpp version text + version num
+file (READ ${CMAKE_CURRENT_SOURCE_DIR}/../include/curlpp/cURLpp.hpp CURLPP_VERSION_H_CONTENTS)
+
+string (REGEX MATCH "#define LIBCURLPP_VERSION \"[^\"]*"
+ CURLPP_VERSION ${CURLPP_VERSION_H_CONTENTS})
+string (REGEX REPLACE "[^\"]+\"" "" CURLPP_VERSION ${CURLPP_VERSION})
+string (REGEX MATCH "#define LIBCURLPP_VERSION_NUM 0x[0-9a-fA-F]+"
+ CURLPP_VERSION_NUM ${CURLPP_VERSION_H_CONTENTS})
+string (REGEX REPLACE "[^0]+0x" "" CURLPP_VERSION_NUM ${CURLPP_VERSION_NUM})
+
+message(STATUS "curlpp version=[${CURLPP_VERSION}]")
+message(STATUS "curlpp version num=[${CURLPP_VERSION_NUM}]")
+
+
+# curlpp-config needs the following options to be set.
+string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")
+set(CC "${CMAKE_C_COMPILER}")
+set(libdir "${CMAKE_INSTALL_LIBDIR}")
+set(libdir_static "${CMAKE_INSTALL_LIBDIR}")
+set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+
+set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
+
+# Finally generate a "curl-config" matching this config
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/curlpp-config.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/curlpp-config" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/curlpp-config"
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
+
+
+# Finally generate a pkg-config file matching this config
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/curlpp.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/curlpp.pc" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/curlpp.pc"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
diff --git a/curlpp/extras/curlpp-config.in b/curlpp/extras/curlpp-config.in
new file mode 100644
index 0000000..b0bd964
--- /dev/null
+++ b/curlpp/extras/curlpp-config.in
@@ -0,0 +1,91 @@
+#! /bin/sh
+#
+# The idea to this kind of setup info script was stolen from numerous
+# other packages, such as neon, libxml and gnome.
+#
+# $Id: curlpp-config.in,v 1.4 2004/10/05 01:48:40 jpbl Exp $
+#
+prefix=@prefix@
+includedir=@includedir@
+
+usage()
+{
+ cat < Jun-21-2005
+#
+# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
+# specify whether to default to --with-libcurl or --without-libcurl.
+# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
+# minimum version of libcurl to accept. Pass the version as a regular
+# version number like 7.10.1. If not supplied, any version is
+# accepted. ACTION-IF-YES is a list of shell commands to run if
+# libcurl was successfully found and passed the various tests.
+# ACTION-IF-NO is a list of shell commands that are run otherwise.
+# Note that using --without-libcurl does run ACTION-IF-NO.
+#
+# This macro defines HAVE_LIBCURL if a working libcurl setup is found,
+# and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary values.
+# Other useful defines are LIBCURL_FEATURE_xxx where xxx are the
+# various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
+# where yyy are the various protocols supported by libcurl. Both xxx
+# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
+# the macro for the complete list of possible defines. Shell
+# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
+# defined to 'yes' for those features and protocols that were found.
+# Note that xxx and yyy keep the same capitalization as in the
+# curl-config list (e.g. it's "HTTP" and not "http").
+#
+# Users may override the detected values by doing something like:
+# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
+#
+# For the sake of sanity, this macro assumes that any libcurl that is
+# found is after version 7.7.2, the first version that included the
+# curl-config script. Note that it is very important for people
+# packaging binary versions of libcurl to include this script!
+# Without curl-config, we can only guess what protocols are available.
+
+AC_DEFUN([CURLPP_CHECK_CONFIG],
+[
+ LIBCURL_CHECK_CONFIG
+
+ if test x"$LIBCURL" != "x" ; then
+
+ AC_ARG_WITH(curlpp,
+ AC_HELP_STRING([--with-curlpp=DIR],[look for the curlpp library in DIR]),
+ [_curlpp_with=$withval],[_curlpp_with=ifelse([$1],,[yes],[$1])])
+
+ if test "$_curlpp_with" != "no" ; then
+
+ AC_PROG_AWK
+
+ _curlpp_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
+
+ _curlpp_try_link=yes
+
+ if test -d "$_curlpp_with" ; then
+ CPPFLAGS="${CPPFLAGS} -I$withval/include"
+ LDFLAGS="${LDFLAGS} -L$withval/lib"
+ fi
+
+ AC_PATH_PROG([_curlpp_config],[curlpp-config])
+
+ if test x$_curlpp_config != "x" ; then
+ AC_CACHE_CHECK([for the version of curlpp],
+ [curlpp_cv_lib_curlpp_version],
+ [curlpp_cv_lib_curlpp_version=`$_curlpp_config --version | $AWK '{print $[]2}'`])
+
+ _curlpp_version=`echo $curlpp_cv_lib_curlpp_version | $_curlpp_version_parse`
+ _curlpp_wanted=`echo ifelse([$2],,[0],[$2]) | $_curlpp_version_parse`
+
+ if test $_curlpp_wanted -gt 0 ; then
+ AC_CACHE_CHECK([for curlpp >= version $2],
+ [curlpp_cv_lib_version_ok],
+ [
+ if test $_curlpp_version -ge $_curlpp_wanted ; then
+ curlpp_cv_lib_version_ok=yes
+ else
+ curlpp_cv_lib_version_ok=no
+ fi
+ ])
+ fi
+
+ if test $_curlpp_wanted -eq 0 || test x$curlpp_cv_lib_version_ok = xyes ; then
+ if test x"$CURLPP_CPPFLAGS" = "x" ; then
+ CURLPP_CPPFLAGS=`$_curlpp_config --cflags`
+ fi
+ if test x"$CURLPP" = "x" ; then
+ CURLPP=`$_curlpp_config --libs`
+ fi
+ else
+ _curlpp_try_link=no
+ fi
+
+ unset _curlpp_wanted
+ fi
+
+ if test $_curlpp_try_link = yes ; then
+
+ # we didn't find curl-config, so let's see if the user-supplied
+ # link line (or failing that, "-lcurl") is enough.
+ CURLPP=${CURLPP-"-lcurl"}
+
+ AC_CACHE_CHECK([whether curlpp is usable],
+ [curlpp_cv_lib_curlpp_usable],
+ [
+ _curlpp_save_cppflags=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $CURLPP_CPPFLAGS"
+ _libcurl_save_libs=$LIBS
+ LIBS="$LIBS $CURLPP"
+
+ AC_LINK_IFELSE(AC_LANG_PROGRAM([#include ],[
+/* Try and use a few common options to force a failure if we are
+ missing symbols or can't link. */
+int x;
+cURLpp::initialize();
+]),curlpp_cv_lib_curlpp_usable=yes,curlpp_cv_lib_curlpp_usable=no)
+
+ CPPFLAGS=$_curlpp_save_cppflags
+ LIBS=$_curlpp_save_libs
+ unset _curlpp_save_cppflags
+ unset _curlpp_save_libs
+ ])
+
+ if test $curlpp_cv_lib_curlpp_usable = yes ; then
+
+ AC_DEFINE(HAVE_CURLPP,1,
+ [Define to 1 if you have a functional curlpp library.])
+ AC_SUBST(CURLPP_CPPFLAGS)
+ AC_SUBST(CURLPP)
+ fi
+ fi
+
+ unset _curlpp_try_link
+ unset _curlpp_version_parse
+ unset _curlpp_config
+ unset _curlpp_feature
+ unset _curlpp_features
+ unset _curlpp_protocol
+ unset _curlpp_protocols
+ unset _curlpp_version
+ fi
+
+ if test x$_curlpp_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
+ # This is the IF-NO path
+ ifelse([$4],,:,[$4])
+ else
+ # This is the IF-YES path
+ ifelse([$3],,:,[$3])
+ fi
+
+ unset _curlpp_with
+ fi
+])dnl
diff --git a/curlpp/extras/curlpp.pc.in b/curlpp/extras/curlpp.pc.in
new file mode 100644
index 0000000..b040ee0
--- /dev/null
+++ b/curlpp/extras/curlpp.pc.in
@@ -0,0 +1,13 @@
+# This is a comment
+prefix=@prefix@
+exec_prefix=@prefix@
+includedir=@includedir@
+
+Name: curlpp
+Description: cURLpp is a libcurl C++ wrapper
+Version: @VERSION@
+Libs: -L@libdir@ -lcurlpp @LDFLAGS@ @LIBS@
+Cflags: -I@includedir@ @CURLPP_CXXFLAGS@
+# libcurl is required as non-private because CurlHandle.inl uses curl_easy_setopt.
+Requires: libcurl
+
diff --git a/curlpp/extras/curlpp.spec.in b/curlpp/extras/curlpp.spec.in
new file mode 100644
index 0000000..7359584
--- /dev/null
+++ b/curlpp/extras/curlpp.spec.in
@@ -0,0 +1,96 @@
+Summary: cURLpp is a libcurl C++ wrapper
+Name: cURLpp
+Version: @RPM_VERSION@
+Release: 1
+License: MIT
+Group: Development/Libraries
+URL: http://rrette.com/curlpp.html
+Source0: curlpp-@VERSION@.tar.gz
+BuildRoot: %{_tmppath}/curlpp-@VERSION@-%{release}-buildroot
+Requires: curl >= 7.10.0
+
+
+%package devel
+Summary: The includes and libs to develop with cURLpp
+Group: Development/Libraries
+Requires: curl >= 7.10.0
+Provides: curlpp-devel
+
+%description
+cURLpp is a libcurl C++ wrapper. There is the libcurl description: "libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and more!
+
+libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, Net/Free/Open BSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS and more... "
+
+%description devel
+This packages contains all the libs and headers to develop applications using cURLpp.
+
+
+%prep
+%setup -qn curlpp-@VERSION@
+
+
+%build
+%configure
+make
+
+%install
+[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
+
+%clean
+rm -rf %{buildroot}
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%{_libdir}/libcurlpp.so*
+
+
+%files devel
+%defattr(-,root,root)
+%attr(0755,root,root) %{_bindir}/curlpp-config
+%dir %{_includedir}/curlpp
+%{_includedir}/curlpp/*.hpp
+%{_includedir}/curlpp/*.inl
+%{_includedir}/curlpp/*.h
+%dir %{_includedir}/curlpp/utilspp
+%dir %{_includedir}/curlpp/utilspp/singleton
+%{_includedir}/curlpp/utilspp/singleton/*.hpp
+%{_includedir}/curlpp/utilspp/singleton/*.inl
+%dir %{_includedir}/utilspp
+%{_includedir}/utilspp/*.hpp
+%{_includedir}/utilspp/*.inl
+%dir %{_includedir}/utilspp/functor
+%{_includedir}/utilspp/functor/*.hpp
+%{_libdir}/libcurlpp.la
+%{_libdir}/libcurlpp.a
+%{_libdir}/pkgconfig/curlpp.pc
+%dir
+
+
+%changelog
+
+* Sun Jul 17 2005 Jean-Philippe Barrette-LaPierre - 0.5.1-1
+- removed {%name} use
+
+* Wed Jan 5 2005 Jean-Philippe Barrette-LaPierre - 0.3.2-rc1-1
+- Version depends now on configure script
+
+* Thu Sep 30 2004 Jean-Philippe Barrette-LaPierre 0.3.1-1
+- Removed any utilspp reference. (Not used anymore)
+
+* Thu Jun 17 2004 Jean-Philippe Barrette-LaPierre 0.3.1-1
+- Removed the unusefull BuildRequires
+
+* Mon Oct 20 2003 Jean-Philippe Barrette-LaPierre - 0.3.0-2
+- Added the devel package
+
+* Wed Oct 15 2003 Jean-Philippe Barrette-LaPierre - 0.3.0-1
+- Initial build.
+
+
diff --git a/curlpp/include/curlpp/Easy.hpp b/curlpp/include/curlpp/Easy.hpp
new file mode 100644
index 0000000..48a1746
--- /dev/null
+++ b/curlpp/include/curlpp/Easy.hpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) <2002-2009>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CURLPP_EASY_HPP
+#define CURLPP_EASY_HPP
+
+
+#include "internal/CurlHandle.hpp"
+#include "internal/OptionList.hpp"
+
+#include "Option.hpp"
+
+#include
+
+
+namespace curlpp
+{
+
+
+ /**
+ * Easy class.
+ * Detailed description.
+ */
+
+ class Easy
+ {
+
+ public:
+
+ friend struct InfoGetter;
+
+ Easy();
+
+ /**
+ * This allow to have a handle, which might have
+ * some option set, but we don't care about them.
+ */
+ Easy(std::unique_ptr handle);
+ virtual ~Easy();
+
+ /**
+ * it will call the curl_easy_perform function will all the options
+ * previously set for this handle.
+ */
+ void perform();
+
+ /**
+ * This function will set the option value of the OptionBase
+ * to the handle.
+ */
+ virtual void setOpt(const OptionBase & option);
+
+ /**
+ * This function will set the option value of the OptionBase to the
+ * handle.
+ */
+ virtual void setOpt(std::unique_ptr option);
+
+ /**
+ * This function will set the option value of the OptionBase to the
+ * handle.
+ *
+ * Note: be carefull when using this function, see
+ * curlpp::OptionList::setOpt(OptionBase * option) function for more
+ * details.
+ */
+ virtual void setOpt(OptionBase * option);
+
+ /**
+ * This function will create OptionTrait class with the value given and call
+ * virtual void setOpt(const OptionBase & option) with it.
+ */
+ template
+ void setOpt(typename OptionTrait::ParamType);
+
+ /**
+ * Setting options from custom container with curlpp options.
+ */
+ template
+ void setOpt(InputIterator first, InputIterator last);
+
+ /**
+ * This function will get the current option value of the corresponding
+ * OptionBase. Note that if the option is not set, the option passed in
+ * parameter will be cleared. (See Option::getOpt for more details)
+ */
+ void getOpt(OptionBase * option) const;
+
+ /**
+ * This function will get the current option value of the corresponding
+ * OptionBase. Note that if the option is not set, the option passed in
+ * parameter will be cleared. (See Option::getOpt for more details)
+ */
+ void getOpt(OptionBase & option) const;
+
+ /**
+ * Get all options.
+ */
+ //template
+ //void getOptions(OutputIterator out);
+
+ /*
+ * This function empties the option collection and reset all options
+ * to their default value
+ */
+ virtual void reset ();
+
+ /**
+ * This function will return the cURL * handle.
+ * DO NOT use this, unless you REALLY know what you
+ * are doing.
+ */
+ CURL * getHandle() const;
+
+ internal::CurlHandle & getCurlHandle() { return *mCurl; }
+ const internal::CurlHandle & getCurlHandle() const { return *mCurl; }
+
+ private:
+
+ /**
+ * This function will call the setOpt on each options
+ * contained by * the option list passed in argument.
+ */
+ virtual void setOpt(const internal::OptionList & options);
+
+ /**
+ * This is the function that curlpp::InfoGetter will call
+ * to retreive option.
+ */
+ template
+ void getInfo(CURLINFO info, T & value) const;
+
+ std::unique_ptr mCurl;
+
+ internal::OptionList mOptions;
+
+ };
+
+
+} // namespace curlpp
+
+namespace cURLpp = curlpp;
+
+#include "Easy.inl"
+
+// Not quite sure if we shouldn't pass a const handle and clone it instead.
+std::ostream & operator<<(std::ostream & stream, const curlpp::Easy & handle);
+
+
+#endif // #ifndef CURLPP_EASY_HPP
diff --git a/curlpp/include/curlpp/Easy.inl b/curlpp/include/curlpp/Easy.inl
new file mode 100644
index 0000000..e06bc24
--- /dev/null
+++ b/curlpp/include/curlpp/Easy.inl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) <2002-2006>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+template
+void curlpp::Easy::getInfo(CURLINFO info, T & value) const
+{
+ mCurl->getInfo(info, value);
+}
+
+
+template
+void
+curlpp::Easy::setOpt(typename OptionTrait::ParamType value)
+{
+ setOpt(curlpp::OptionTrait(value));
+}
+
+
+template
+void
+curlpp::Easy::setOpt(InputIterator first, InputIterator last)
+{
+ for(InputIterator it=first; it != last; ++it)
+ {
+ setOpt(*it);
+ }
+}
diff --git a/curlpp/include/curlpp/Exception.hpp b/curlpp/include/curlpp/Exception.hpp
new file mode 100644
index 0000000..66b11d0
--- /dev/null
+++ b/curlpp/include/curlpp/Exception.hpp
@@ -0,0 +1,306 @@
+/*
+* Copyright (c) <2002-2009>
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files
+* (curlpp), to deal in the Software without restriction,
+* including without limitation the rights to use, copy, modify, merge,
+* publish, distribute, sublicense, and/or sell copies of the Software,
+* and to permit persons to whom the Software is furnished to do so,
+* subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef CURLPP_EXCEPTION_HPP
+#define CURLPP_EXCEPTION_HPP
+
+
+
+#include
+
+#include
+#include
+
+
+namespace curlpp
+{
+
+
+ /**
+ * This class is a parent to all curlpp's RuntimeErrors.
+ *
+ * This class takes a const std::string & as argument for it's parent: std::runtime_errors.
+ * This class is thrown when curlpp is encountering an error, but for runtime
+ * considerations, "unpredictable" by the library user.
+ */
+
+ class RuntimeError : public std::runtime_error
+ {
+
+ public:
+
+ RuntimeError(const char * reason);
+ RuntimeError(const std::string & string);
+ virtual ~RuntimeError() throw();
+
+ };
+
+
+ /**
+ * This class is a parent to all curlpp's RuntimeErrors.
+ *
+ * This class takes a const std::string & as argument for it's parent: std::runtime_errors.
+ * This class is thrown when curlpp is encountering an error, but for logic
+ * considerations, "predictable" by the library user. Predictable means
+ * that the library user is missusing the library.
+ */
+
+ class LogicError : public std::logic_error
+ {
+
+ public:
+
+ LogicError(const char * reason);
+ LogicError(const std::string & string);
+ virtual ~LogicError() throw();
+
+ };
+
+
+ /**
+ * This is a class derived from curlpp::RuntimeError.
+ *
+ * It takes a const char * and a CURLcode as arguments. This class is thrown when libcurl is
+ * returning an error with a CURLcode, but for runtime considerations,
+ * "unpredictable" by the library user.
+ */
+
+ class LibcurlRuntimeError : public curlpp::RuntimeError
+ {
+
+ public:
+
+ LibcurlRuntimeError(const std::string & reason, CURLcode code);
+ LibcurlRuntimeError(const char * reason, CURLcode code);
+
+ /**
+ * Returns the CURLcode that libcurl returned.
+ */
+ CURLcode whatCode() const throw();
+
+ private:
+
+ CURLcode mCode;
+
+ };
+
+
+ /*
+ * This is a class derived from curlpp::LogicError, that takes a const
+ * char * and a CURLcode as arguments. This class is thrown when libcurl is
+ * returning an error with a CURLcode, but for logic considerations,
+ * "predictable" by the library user. Predictable means that the library
+ * user is missusing the library.
+ */
+
+ class LibcurlLogicError : public curlpp::LogicError
+ {
+
+ public:
+
+ LibcurlLogicError(const std::string & reason, CURLcode code);
+ LibcurlLogicError(const char * reason, CURLcode code);
+
+ /*
+ * return the CURLcode that libcurl returned
+ */
+ CURLcode whatCode() const throw();
+
+ private:
+
+ CURLcode mCode;
+
+ };
+
+
+ /**
+ * This exception is thrown when you try to retreive a value for an
+ * unset option.
+ */
+
+ class UnsetOption : public curlpp::RuntimeError
+ {
+
+ public:
+
+ UnsetOption(const std::string & reason);
+ UnsetOption(const char * reason);
+
+ };
+
+
+ /**
+ * This exception is thrown when you try to instantiate an option
+ * that isn't available for your current libcURL version.
+ */
+
+ class NotAvailable : public curlpp::LogicError
+ {
+
+ public:
+
+ NotAvailable();
+
+ };
+
+
+ /**
+ * This exception is thrown when an exception is thrown within
+ * a callback without the curlpp::raiseException function.
+ */
+
+ class UnknowException : public curlpp::RuntimeError
+ {
+
+ public:
+
+ UnknowException();
+
+ };
+
+
+ /**
+ * This exception is thrown by the curlpp::raiseException function.
+ * It's used to throw exceptions within callbacks
+ */
+
+ class CallbackExceptionBase : public curlpp::RuntimeError
+ {
+
+ protected:
+
+ CallbackExceptionBase();
+ CallbackExceptionBase(const CallbackExceptionBase & other);
+
+ public:
+
+ virtual void throwMe() = 0;
+ virtual CallbackExceptionBase * clone() = 0;
+
+ };
+
+
+ /**
+ * This exception is thrown by the curlpp::raiseException function.
+ * It's used to throw exceptions within callbacks
+ */
+
+ template
+ class CallbackException : public CallbackExceptionBase
+ {
+
+ public:
+
+ typedef CallbackException _CE;
+
+ CallbackException(const ExceptionType & e)
+ : mException(e)
+ {}
+
+ virtual void throwMe()
+ {
+ throw mException;
+ }
+
+ virtual _CE * clone()
+ {
+ return new _CE(*this);
+ }
+
+ private:
+
+ ExceptionType mException;
+
+ };
+
+
+ /**
+ * This function is the function to be called within callbacks
+ * if you want an exception to be thrown at the
+ * curlpp::Easy::perform function call level.
+ */
+
+ template
+ void raiseException(const T & e)
+ {
+ throw (CallbackExceptionBase *)(new CallbackException(e));
+ }
+
+
+ template
+ CallbackException * createCallbackException(const T & e)
+ {
+ return CallbackException(e);
+ }
+
+
+ /**
+ * if CURLcode is not equal to CURLE_OK, it throws a
+ * curlpp::LibcurlRuntimeError with the reason and the code. It's used
+ * in inline function, because throwing an exception is heavy in binary
+ * code, something we don't want in inline functions.
+ */
+
+ void libcurlRuntimeAssert(const std::string & reason, CURLcode code);
+ void libcurlRuntimeAssert(const char * reason, CURLcode code);
+
+
+ /**
+ * if CURLcode is not equal to CURLE_OK, it throws a
+ * curlpp::LibcurlLogicError with the reason and the code. It's used
+ * in inline function, because throwing an exception is heavy in binary
+ * code, something we don't want in inline functions.
+ */
+
+ void libcurlLogicAssert(const std::string & reason, CURLcode code);
+ void libcurlLogicAssert(const char * reason, CURLcode code);
+
+
+ /**
+ * if isOkay is false, it throws a curlpp::RuntimeError
+ * with the reason. It's used in inline function, because throwing
+ * an exception is heavy in binary code, something we don't want in
+ * an inline function.
+ */
+
+ void runtimeAssert(const std::string & reason, bool isOkay);
+ void runtimeAssert(const char * reason, bool isOkay);
+
+
+ /**
+ * if is_true is false, it throws a curlpp::LogicError with
+ * the reason. It's used in inline function, because throwing
+ * an exception is heavy in binary code, something we don't
+ * want in an inline function.
+ */
+
+ void logicAssert(const std::string & reason, bool isOkay);
+ void logicAssert(const char * reason, bool isOkay);
+
+
+} // namespace curlpp
+
+namespace cURLpp = curlpp;
+
+
+#endif // #ifndef CURLPP_EXCEPTION_HPP
diff --git a/curlpp/include/curlpp/Form.hpp b/curlpp/include/curlpp/Form.hpp
new file mode 100644
index 0000000..c499aee
--- /dev/null
+++ b/curlpp/include/curlpp/Form.hpp
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) <2002-2009>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CURLPP_FORM_HPP
+#define CURLPP_FORM_HPP
+
+
+#include
+
+#include
+
+#include
+#include
+
+
+namespace curlpp
+{
+
+
+ class FormPart;
+
+
+ typedef std::list > Forms;
+
+
+ /**
+ * This class is used internally to wrap over curl_httppost
+ * class.
+ */
+
+ class HttpPost
+ {
+
+ public:
+
+ HttpPost(const Forms & posts);
+ HttpPost();
+ ~HttpPost();
+
+ /**
+ * initialize the HTTP post with the list of forms. The Forms
+ * will be cloned.
+ */
+ HttpPost & operator=(const Forms & posts);
+
+ operator Forms() { return getList(); }
+
+
+ /**
+ * return the curl_httppost representation of this HTTP Post.
+ * Be aware that the memory return is owned by the current
+ * instance, so don't try to delete it.
+ */
+ ::curl_httppost * cHttpPost() const;
+
+ /**
+ * Free all HTTP posts.
+ */
+ void clear();
+
+ /**
+ * Get the list.
+ */
+ Forms getList();
+
+ private:
+
+ ::curl_httppost * mFirst;
+ ::curl_httppost * mLast;
+ Forms mForms;
+
+ };
+
+
+ /**
+ * This class is the base representation of a post. You need
+ * to inherit from it to define a type of post.
+ */
+
+ class FormPart
+ {
+ friend class HttpPost;
+
+ public:
+
+ /**
+ * initialize the FormPart. "name" is the name of the field.
+ */
+ FormPart(const char * name);
+
+ /**
+ * initialize the FormPart. "name" is the name of the field.
+ */
+ FormPart(const std::string & name);
+
+ virtual ~FormPart();
+
+ virtual FormPart * clone() const = 0;
+
+ protected:
+
+ /**
+ * it will add himself to the curl_httppost * first.
+ */
+ virtual void add(::curl_httppost ** first,
+ ::curl_httppost ** last) = 0;
+
+ /**
+ * Contain the name of the field.
+ */
+ const std::string mName;
+
+ };
+
+
+namespace FormParts
+{
+
+
+ /**
+ * This class is a file post. It will send a file in the
+ * HTTP post.
+ */
+
+ class File : public FormPart
+ {
+
+ public:
+
+ /**
+ * initialize a File part. "name" is the name of the field.
+ * "filename" is the string that holds the filename.
+ */
+ File(const char * name,
+ const char * filename);
+
+ /**
+ * initialize a File part. "name" is the name of the field.
+ * "filename" is the string that holds the filename.
+ * "contentType" is the MIME type of the file.
+ */
+ File(const char * name,
+ const char * filename,
+ const char * contentType);
+
+ /**
+ * initialize a File part. "name" is the name of the field.
+ * "filename" is the string that holds the filename.
+ */
+ File(const std::string & name,
+ const std::string & filename);
+
+ /**
+ * initialize a File part. "name" is the name of the field.
+ * "filename" is the string that holds the filename.
+ * "contentType" is the MIME type of the file.
+ */
+ File(const std::string & name,
+ const std::string & filename,
+ const std::string & contentType);
+
+ virtual ~File();
+
+ /**
+ * This function will return a copy of the instance.
+ */
+ virtual File * clone() const;
+
+ private:
+
+ void add(::curl_httppost ** first,
+ ::curl_httppost ** last);
+
+ private:
+
+ const std::string mFilename;
+ const std::string mContentType;
+
+ };
+
+
+ /**
+ * This class is a file post. It will send a file in the
+ * HTTP post.
+ */
+
+ class Content : public FormPart
+ {
+
+ public:
+
+ /**
+ * initialize a Content part. "name" is the name of the field.
+ * "content" is the string that holds the filename.
+ */
+ Content(const char * name,
+ const char * content);
+
+ /**
+ * initialize a Content part. "name" is the name of the field.
+ * "content" is the string that holds the filename.
+ * "contentType" is the MIME type of the file.
+ */
+ Content(const char * name,
+ const char * content,
+ const char * contentType);
+
+ /**
+ * initialize a Content part. "name" is the name of the field.
+ * "content" is the string that holds the content.
+ */
+ Content(const std::string & name,
+ const std::string & content);
+
+ /**
+ * initialize a Content part. "name" is the name of the field.
+ * "content" is the string that holds the content.
+ * "content_type" is the MIME type of the file.
+ */
+ Content(const std::string & name,
+ const std::string & content,
+ const std::string & content_type);
+
+ virtual ~Content();
+
+ /**
+ * This function will return a copy of the instance.
+ */
+ virtual Content * clone() const;
+
+ private:
+
+ void add(::curl_httppost ** first,
+ ::curl_httppost ** last);
+
+ private:
+
+ const std::string mContent;
+ const std::string mContentType;
+
+ };
+
+
+} // namespace FormParts
+
+
+} // namespace curlpp
+
+namespace cURLpp = curlpp;
+
+
+#endif //CURLPP_FORM_HPP
diff --git a/curlpp/include/curlpp/Info.hpp b/curlpp/include/curlpp/Info.hpp
new file mode 100644
index 0000000..5132218
--- /dev/null
+++ b/curlpp/include/curlpp/Info.hpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) <2002-2009>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef CURLPP_INFO_HPP
+#define CURLPP_INFO_HPP
+
+
+
+#include "Easy.hpp"
+
+
+namespace curlpp
+{
+
+
+ /**
+ * This class is responsible of retreiving the Info from
+ * a handle. This is the class you use when you want to do
+ * so.
+ */
+
+ template
+ struct Info
+ {
+ static void get(const curlpp::Easy & handle, T & value);
+ static T get(const curlpp::Easy & handle);
+ };
+
+
+ /**
+ * This class is used when an info is not available for the
+ * current libcURL version.
+ */
+
+ template
+ struct NotAvailableInfo : Info
+ {
+ static void get(const curlpp::Easy & handle, T & value);
+ static T get(const curlpp::Easy & handle);
+ };
+
+
+ /**
+ * This is the class you need to specialize if you use
+ * a special type that libcURL is not aware of. This class
+ * need to call curlpp::InfoGetter::get function. See
+ * curlpp::InfoGetter for more information.
+ */
+
+ template
+ struct InfoTypeConverter
+ {
+ static void get(const curlpp::Easy & handle, CURLINFO info, T & value);
+ };
+
+
+ template<>
+ void InfoTypeConverter
+ ::get(const curlpp::Easy & handle, CURLINFO info, std::string & value);
+
+
+ template<>
+ void InfoTypeConverter >
+ ::get(const curlpp::Easy & handle, CURLINFO info, std::list & value);
+
+
+ template<>
+ void InfoTypeConverter
+ ::get(const curlpp::Easy & handle, CURLINFO info, long & value);
+
+
+ template<>
+ void InfoTypeConverter
+ ::get(const curlpp::Easy & handle, CURLINFO info, double & value);
+
+
+ /**
+ * This is the only class that is authorized to retreive
+ * info from a curlpp::Easy class. So, this is the class
+ * you need to use when you specialize the class
+ * curlpp::InfoTypeConverter. This class is in fact used
+ * as a proxy, just to be sure that nobody access curlpp::Easy's
+ * private data.
+ */
+
+ struct InfoGetter
+ {
+ template
+ static void get(const curlpp::Easy & handle, CURLINFO info, T & value);
+ };
+
+
+} // namespace curlpp
+
+namespace cURLpp = curlpp;
+
+
+#include "Info.inl"
+
+#endif // #ifndef CURLPP_INFO_HPP
diff --git a/curlpp/include/curlpp/Info.inl b/curlpp/include/curlpp/Info.inl
new file mode 100644
index 0000000..d15d090
--- /dev/null
+++ b/curlpp/include/curlpp/Info.inl
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) <2002-2006>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (curlpp), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CURLPP_INFO_INL
+#define CURLPP_INFO_INL
+
+template
+void
+curlpp::Info