diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..ff86d7eb2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./work/ \ No newline at end of file diff --git a/src/curl/build_curl.ps1 b/src/curl/build_curl.ps1 index f011f2ab1..60787fa45 100644 --- a/src/curl/build_curl.ps1 +++ b/src/curl/build_curl.ps1 @@ -17,8 +17,6 @@ if (Test-Path $target\include\curl) { # expand unzip -q $src\curl\$curl -d $work -# copy headers -Copy-Item $work\$curl\include\curl $target\include\curl -Recurse #debug cd $work\$curl @@ -35,6 +33,9 @@ cd winbuild nmake /f Makefile.vc mode=static ENABLE_SSPI=no ENABLE_SSPI=no ENABLE_IPV6=no ENABLE_IDN=no MACHINE=x64 RTLIBCFG=static DEBUG=no Copy-Item ..\builds\libcurl-vc-x64-release-static\lib\libcurl_a.lib $target\lib\release\libcurl.lib +# copy headers +Copy-Item ..\builds\libcurl-vc-x64-release-static\include\curl $target\include\curl -Recurse + cd $root Remove-Item -Force -Recurse $work Pop-Location diff --git a/src/urdl/build_urdl.ps1 b/src/urdl/build_urdl.ps1 index 9502f54fb..283d59988 100644 --- a/src/urdl/build_urdl.ps1 +++ b/src/urdl/build_urdl.ps1 @@ -15,6 +15,7 @@ if (Test-Path $target\include\urdl) { unzip -q $src\urdl\$urdl -d $work Copy-Item $work\$urdl\include\urdl $target\include\urdl -Recurse +Copy-Item $work\$urdl\test $target\include\urdl\test -Recurse cd $root Remove-Item -Force -Recurse $work diff --git a/windows/include/curl/.gitignore b/windows/include/curl/.gitignore deleted file mode 100644 index 228a961fb..000000000 --- a/windows/include/curl/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -curlbuild.h -curlver.h.dist -stamp-h2 -stamp-h3 diff --git a/windows/include/curl/Makefile.am b/windows/include/curl/Makefile.am deleted file mode 100644 index 9011c793c..000000000 --- a/windows/include/curl/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at https://curl.haxx.se/docs/copyright.html. -# -# You may opt to use, copy, modify, merge, publish, distribute and/or sell -# copies of the Software, and permit persons to whom the Software is -# furnished to do so, under the terms of the COPYING file. -# -# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -# KIND, either express or implied. -# -########################################################################### -pkginclude_HEADERS = \ - curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \ - typecheck-gcc.h curlbuild.h curlrules.h system.h - -pkgincludedir= $(includedir)/curl - -# curlbuild.h does not exist in the git tree. When the original libcurl -# source code distribution archive file is created, curlbuild.h.dist is -# renamed to curlbuild.h and included in the tarball so that it can be -# used directly on non-configure systems. -# -# The distributed curlbuild.h will be overwritten on configure systems -# when the configure script runs, with one that is suitable and specific -# to the library being configured and built. -# -# curlbuild.h.in is the distributed template file from which the configure -# script creates curlbuild.h at library configuration time, overwiting the -# one included in the distribution archive. -# -# curlbuild.h.dist is not included in the source code distribution archive. - -EXTRA_DIST = curlbuild.h.in - -DISTCLEANFILES = curlbuild.h - -checksrc: - @@PERL@ $(top_srcdir)/lib/checksrc.pl -Wcurlbuild.h -D$(top_srcdir)/include/curl $(pkginclude_HEADERS) $(EXTRA_DIST) - -if CURLDEBUG -# for debug builds, we scan the sources on all regular make invokes -all-local: checksrc -endif diff --git a/windows/include/curl/curlbuild.h.dist b/windows/include/curl/curlbuild.h similarity index 100% rename from windows/include/curl/curlbuild.h.dist rename to windows/include/curl/curlbuild.h diff --git a/windows/include/curl/curlbuild.h.cmake b/windows/include/curl/curlbuild.h.cmake deleted file mode 100644 index bbb31a940..000000000 --- a/windows/include/curl/curlbuild.h.cmake +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/ - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.in or - * at file include/curl/curlbuild.h, this is due to the following reason: - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ -/* ================================================================ */ - -/* Configure process defines this to 1 when it finds out that system */ -/* header file ws2tcpip.h must be included by the external interface. */ -#cmakedefine CURL_PULL_WS2TCPIP_H -#ifdef CURL_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/types.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_TYPES_H -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file stdint.h must be included by the external interface. */ -#cmakedefine CURL_PULL_STDINT_H -#ifdef CURL_PULL_STDINT_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file inttypes.h must be included by the external interface. */ -#cmakedefine CURL_PULL_INTTYPES_H -#ifdef CURL_PULL_INTTYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/socket.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_SOCKET_H -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/poll.h must be included by the external interface. */ -#cmakedefine CURL_PULL_SYS_POLL_H -#ifdef CURL_PULL_SYS_POLL_H -# include -#endif - -/* The size of `long', as computed by sizeof. */ -#define CURL_SIZEOF_LONG ${CURL_SIZEOF_LONG} - -/* Integral data type used for curl_socklen_t. */ -#define CURL_TYPEOF_CURL_SOCKLEN_T ${CURL_TYPEOF_CURL_SOCKLEN_T} - -/* The size of `curl_socklen_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_SOCKLEN_T ${CURL_SIZEOF_CURL_SOCKLEN_T} - -/* Data type definition of curl_socklen_t. */ -typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; - -/* Signed integral data type used for curl_off_t. */ -#define CURL_TYPEOF_CURL_OFF_T ${CURL_TYPEOF_CURL_OFF_T} - -/* Data type definition of curl_off_t. */ -typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; - -/* curl_off_t formatting string directive without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_T "${CURL_FORMAT_CURL_OFF_T}" - -/* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_TU "${CURL_FORMAT_CURL_OFF_TU}" - -/* curl_off_t formatting string directive with "%" conversion specifier. */ -#define CURL_FORMAT_OFF_T "${CURL_FORMAT_OFF_T}" - -/* The size of `curl_off_t', as computed by sizeof. */ -#define CURL_SIZEOF_CURL_OFF_T ${CURL_SIZEOF_CURL_OFF_T} - -/* curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_T ${CURL_SUFFIX_CURL_OFF_T} - -/* unsigned curl_off_t constant suffix. */ -#define CURL_SUFFIX_CURL_OFF_TU ${CURL_SUFFIX_CURL_OFF_TU} - -#endif /* __CURL_CURLBUILD_H */ diff --git a/windows/include/curl/curlbuild.h.in b/windows/include/curl/curlbuild.h.in deleted file mode 100644 index ffab35670..000000000 --- a/windows/include/curl/curlbuild.h.in +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/ - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.in or - * at file include/curl/curlbuild.h, this is due to the following reason: - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */ -/* ================================================================ */ - -/* Configure process defines this to 1 when it finds out that system */ -/* header file ws2tcpip.h must be included by the external interface. */ -#undef CURL_PULL_WS2TCPIP_H -#ifdef CURL_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/types.h must be included by the external interface. */ -#undef CURL_PULL_SYS_TYPES_H -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file stdint.h must be included by the external interface. */ -#undef CURL_PULL_STDINT_H -#ifdef CURL_PULL_STDINT_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file inttypes.h must be included by the external interface. */ -#undef CURL_PULL_INTTYPES_H -#ifdef CURL_PULL_INTTYPES_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/socket.h must be included by the external interface. */ -#undef CURL_PULL_SYS_SOCKET_H -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Configure process defines this to 1 when it finds out that system */ -/* header file sys/poll.h must be included by the external interface. */ -#undef CURL_PULL_SYS_POLL_H -#ifdef CURL_PULL_SYS_POLL_H -# include -#endif - -/* The size of `long', as computed by sizeof. */ -#undef CURL_SIZEOF_LONG - -/* Integral data type used for curl_socklen_t. */ -#undef CURL_TYPEOF_CURL_SOCKLEN_T - -/* The size of `curl_socklen_t', as computed by sizeof. */ -#undef CURL_SIZEOF_CURL_SOCKLEN_T - -/* Data type definition of curl_socklen_t. */ -typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; - -/* Signed integral data type used for curl_off_t. */ -#undef CURL_TYPEOF_CURL_OFF_T - -/* Data type definition of curl_off_t. */ -typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; - -/* curl_off_t formatting string directive without "%" conversion specifier. */ -#undef CURL_FORMAT_CURL_OFF_T - -/* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#undef CURL_FORMAT_CURL_OFF_TU - -/* curl_off_t formatting string directive with "%" conversion specifier. */ -#undef CURL_FORMAT_OFF_T - -/* The size of `curl_off_t', as computed by sizeof. */ -#undef CURL_SIZEOF_CURL_OFF_T - -/* curl_off_t constant suffix. */ -#undef CURL_SUFFIX_CURL_OFF_T - -/* unsigned curl_off_t constant suffix. */ -#undef CURL_SUFFIX_CURL_OFF_TU - -#endif /* __CURL_CURLBUILD_H */ diff --git a/windows/include/urdl/test/Jamfile b/windows/include/urdl/test/Jamfile new file mode 100644 index 000000000..c223761a3 --- /dev/null +++ b/windows/include/urdl/test/Jamfile @@ -0,0 +1,27 @@ +# +# Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# + +project + : + requirements + ../build//urdl + /boost/thread//boost_thread + : + default-build + debug + multi + shared + shared + ; + +test-suite "urdl" : + [ run istream.cpp ] + [ run istreambuf.cpp ] + [ run option_set.cpp ] + [ run read_stream.cpp ] + [ run url.cpp ] + ; diff --git a/windows/include/urdl/test/http_server.hpp b/windows/include/urdl/test/http_server.hpp new file mode 100644 index 000000000..fad3c291a --- /dev/null +++ b/windows/include/urdl/test/http_server.hpp @@ -0,0 +1,118 @@ +// +// http_server.hpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER_HPP +#define HTTP_SERVER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Helper class to test HTTP client functionality. +class http_server +{ +public: + typedef boost::asio::ip::tcp tcp; + + http_server() + : acceptor_(io_service_, tcp::endpoint( + boost::asio::ip::address_v4::loopback(), 0)), + socket_(io_service_), + response_delay_(0), + content_delay_(0), + success_(false) + { + } + + unsigned short port() const + { + return acceptor_.local_endpoint().port(); + } + + void start(const std::string& expected_request, + std::size_t response_delay, const std::string& response, + std::size_t content_delay, const std::string& content) + { + success_ = false; + expected_request_ = expected_request; + response_delay_ = response_delay; + response_ = response; + content_delay_ = content_delay; + content_ = content; + thread_.reset(new boost::thread(boost::bind(&http_server::worker, this))); + } + + bool stop() + { + thread_->join(); + thread_.reset(); + return success_; + } + +private: + void worker() + { + try + { + acceptor_.accept(socket_); + + // Wait for request. + boost::asio::streambuf buffer; + std::size_t size = boost::asio::read_until(socket_, buffer, "\r\n\r\n"); + std::string request(size, 0); + buffer.sgetn(&request[0], size); + success_ = (request == expected_request_); + + // Introduce a delay before sending the response. + boost::asio::deadline_timer timer(io_service_); + timer.expires_from_now(boost::posix_time::milliseconds(response_delay_)); + timer.wait(); + + // Send response headers. + boost::system::error_code ec; + boost::asio::write(socket_, boost::asio::buffer(response_)); + + // Introduce a delay before sending the content. + timer.expires_from_now(boost::posix_time::milliseconds(content_delay_)); + timer.wait(); + + // Now we can write the content. + boost::asio::write(socket_, boost::asio::buffer(content_)); + + // We're done. Shut down the connection. + socket_.shutdown(tcp::socket::shutdown_both, ec); + socket_.close(ec); + } + catch (std::exception&) + { + } + } + + boost::asio::io_service io_service_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::string expected_request_; + std::size_t response_delay_; + std::string response_; + std::size_t content_delay_; + std::string content_; + boost::scoped_ptr thread_; + bool success_; +}; + +#endif // HTTP_SERVER_HPP diff --git a/windows/include/urdl/test/istream.cpp b/windows/include/urdl/test/istream.cpp new file mode 100644 index 000000000..4edf5d5d0 --- /dev/null +++ b/windows/include/urdl/test/istream.cpp @@ -0,0 +1,215 @@ +// +// istream.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "urdl/istream.hpp" + +#include "unit_test.hpp" +#include "urdl/http.hpp" +#include "urdl/option_set.hpp" +#include "http_server.hpp" +#include +#include + +// Ensure all functions compile correctly. +void istream_compile_test() +{ + // Constructors + + urdl::istream istream1; + urdl::istream istream2("file://foobar"); + urdl::istream istream3(urdl::url("file://foobar")); + urdl::istream istream4("file://foobar", urdl::option_set()); + urdl::istream istream5(urdl::url("file://foobar"), urdl::option_set()); + + // set_option() + + istream1.set_option(0); + istream1.set_option(0); + + // set_options() + + istream1.set_options(urdl::option_set()); + + // get_option() + + const urdl::istream& const_istream1 = istream1; + want(const_istream1.get_option()); + want(const_istream1.get_option()); + + // get_options() + + want(const_istream1.get_options()); + + // is_open() + + want(const_istream1.is_open()); + + // open() + + istream1.open("file://foobar"); + istream1.open(urdl::url("file://foobar")); + + // close() + + istream1.close(); + + // rdbuf() + + want(const_istream1.rdbuf()); + + // error() + + want(const_istream1.error()); + + // read_timeout() + + want(const_istream1.read_timeout()); + istream1.read_timeout(std::size_t(123)); + + // content_type() + + want(const_istream1.content_type()); + + // content_length() + + want(const_istream1.content_length()); + + // headers() + + want(const_istream1.headers()); +} + +// Test HTTP. +void istream_http_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 200 OK\r\n" + "Content-Length: 13\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Hello, World!"; + + server.start(request, 0, response, 0, content); + urdl::istream istream1("http://localhost:" + port + "/"); + std::string returned_content; + std::getline(istream1, returned_content); + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(istream1.content_type() == "text/plain"); + BOOST_CHECK(istream1.content_length() == 13); + BOOST_CHECK(returned_content == content); +} + +// Test HTTP with an error status returned by the server. +void istream_http_not_found_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 404 Not Found\r\n" + "Content-Length: 9\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Not Found"; + + server.start(request, 0, response, 0, content); + urdl::istream istream1("http://localhost:" + port + "/"); + std::string returned_content; + std::getline(istream1, returned_content); + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(istream1.error() == urdl::http::errc::not_found); +} + +// Test HTTP with an open timeout. +void istream_http_open_timeout_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 200 OK\r\n" + "Content-Length: 13\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Hello, World!"; + + server.start(request, 1500, response, 0, content); + urdl::istream istream1; + istream1.open_timeout(1000); + istream1.open("http://localhost:" + port + "/"); + server.stop(); + + BOOST_CHECK(istream1.error() == boost::system::errc::timed_out); +} + +// Test HTTP with a read timeout. +void istream_http_read_timeout_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 200 OK\r\n" + "Content-Length: 13\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Hello, World!"; + + server.start(request, 0, response, 1500, content); + urdl::istream istream1; + istream1.open("http://localhost:" + port + "/"); + istream1.read_timeout(1000); + std::string returned_content; + std::getline(istream1, returned_content); + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(istream1.error() == boost::system::errc::timed_out); +} + +test_suite* init_unit_test_suite(int, char*[]) +{ + test_suite* test = BOOST_TEST_SUITE("istream"); + test->add(BOOST_TEST_CASE(&istream_compile_test)); + test->add(BOOST_TEST_CASE(&istream_http_test)); + test->add(BOOST_TEST_CASE(&istream_http_not_found_test)); + test->add(BOOST_TEST_CASE(&istream_http_open_timeout_test)); + test->add(BOOST_TEST_CASE(&istream_http_read_timeout_test)); + return test; +} diff --git a/windows/include/urdl/test/istreambuf.cpp b/windows/include/urdl/test/istreambuf.cpp new file mode 100644 index 000000000..d40a7e209 --- /dev/null +++ b/windows/include/urdl/test/istreambuf.cpp @@ -0,0 +1,88 @@ +// +// istreambuf.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "urdl/istreambuf.hpp" + +#include "unit_test.hpp" +#include "urdl/option_set.hpp" + +// Ensure all functions compile correctly. +void istreambuf_compile_test() +{ + // Constructors + + urdl::istreambuf istreambuf1; + + // set_option() + + istreambuf1.set_option(0); + istreambuf1.set_option(0); + + // set_options() + + istreambuf1.set_options(urdl::option_set()); + + // get_option() + + const urdl::istreambuf& const_istreambuf1 = istreambuf1; + want(const_istreambuf1.get_option()); + want(const_istreambuf1.get_option()); + + // get_options() + + want(const_istreambuf1.get_options()); + + // is_open() + + want(const_istreambuf1.is_open()); + + // open() + + want(istreambuf1.open("file://foobar")); + want(istreambuf1.open(urdl::url("file://foobar"))); + + // close() + + want(istreambuf1.close()); + + // puberror() + + want(const_istreambuf1.puberror()); + + // read_timeout() + + want(const_istreambuf1.read_timeout()); + istreambuf1.read_timeout(std::size_t(123)); + + // content_type() + + want(const_istreambuf1.content_type()); + + // content_length() + + want(const_istreambuf1.content_length()); + + // headers() + + want(const_istreambuf1.headers()); +} + +test_suite* init_unit_test_suite(int, char*[]) +{ + test_suite* test = BOOST_TEST_SUITE("istreambuf"); + test->add(BOOST_TEST_CASE(&istreambuf_compile_test)); + return test; +} diff --git a/windows/include/urdl/test/option_set.cpp b/windows/include/urdl/test/option_set.cpp new file mode 100644 index 000000000..4d63a5452 --- /dev/null +++ b/windows/include/urdl/test/option_set.cpp @@ -0,0 +1,99 @@ +// +// option_set.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "urdl/option_set.hpp" + +#include "unit_test.hpp" + +// Ensure all functions compile correctly. +void option_set_compile_test() +{ + // Constructors + + urdl::option_set set1; + urdl::option_set set2(set1); + + // operator= + + set1 = set2; + + // set_option() + + set1.set_option(0); + set1.set_option(0); + + // set_options() + + const urdl::option_set& const_set1 = set1; + set2.set_options(const_set1); + + // get_option() + + want(const_set1.get_option()); + want(const_set1.get_option()); + + // clear_option() + + set1.clear_option(); + set1.clear_option(); +} + +// Test option_set runtime behaviour. +void option_set_runtime_test() +{ + urdl::option_set set1; + set1.set_option(std::string("foobar")); + set1.set_option(int(123)); + + urdl::option_set set2(set1); + BOOST_CHECK(set2.get_option() == set1.get_option()); + BOOST_CHECK(set2.get_option() == set1.get_option()); + + urdl::option_set set3; + set3 = set2; + BOOST_CHECK(set3.get_option() == set1.get_option()); + BOOST_CHECK(set3.get_option() == set1.get_option()); + + urdl::option_set set4; + set4.set_option(char('A')); + set4.set_options(set3); + BOOST_CHECK(set4.get_option() == 'A'); + BOOST_CHECK(set4.get_option() == set1.get_option()); + BOOST_CHECK(set4.get_option() == set1.get_option()); + + set4.clear_option(); + BOOST_CHECK(set4.get_option() == 'A'); + BOOST_CHECK(set4.get_option() == ""); + BOOST_CHECK(set4.get_option() == set1.get_option()); + + set4.set_option(int(321)); + BOOST_CHECK(set4.get_option() == 'A'); + BOOST_CHECK(set4.get_option() == ""); + BOOST_CHECK(set4.get_option() == 321); + + set4.set_options(set1); + BOOST_CHECK(set4.get_option() == 'A'); + BOOST_CHECK(set4.get_option() == set1.get_option()); + BOOST_CHECK(set4.get_option() == set1.get_option()); +} + +test_suite* init_unit_test_suite(int, char*[]) +{ + test_suite* test = BOOST_TEST_SUITE("option_set"); + test->add(BOOST_TEST_CASE(&option_set_compile_test)); + test->add(BOOST_TEST_CASE(&option_set_runtime_test)); + return test; +} diff --git a/windows/include/urdl/test/read_stream.cpp b/windows/include/urdl/test/read_stream.cpp new file mode 100644 index 000000000..107985eb6 --- /dev/null +++ b/windows/include/urdl/test/read_stream.cpp @@ -0,0 +1,280 @@ +// +// read_stream.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "urdl/read_stream.hpp" + +#include "unit_test.hpp" +#include "urdl/option_set.hpp" +#include "http_server.hpp" +#include +#include +#include + +void open_handler(const boost::system::error_code&) {} +void read_handler(const boost::system::error_code&, std::size_t) {} + +// Ensure all functions compile correctly. +void read_stream_compile_test() +{ + try + { + boost::asio::io_service io_service; + boost::system::error_code ec; + char buffer[1024]; + + // Constructors + + urdl::read_stream stream1(io_service); + + // get_io_service() + + want(stream1.get_io_service()); + + // set_option() + + stream1.set_option(0); + stream1.set_option(0); + + // set_options() + + stream1.set_options(urdl::option_set()); + + // get_option() + + const urdl::read_stream& const_stream1 = stream1; + want(const_stream1.get_option()); + want(const_stream1.get_option()); + + // get_options() + + want(const_stream1.get_options()); + + // is_open() + + want(const_stream1.is_open()); + + // open() + + stream1.open("file://xyz"); + stream1.open(urdl::url("file://xyz")); + want(stream1.open("file://xyz", ec)); + want(stream1.open(urdl::url("file://xyz"), ec)); + + // async_open() + + stream1.async_open("file://xyz", open_handler); + stream1.async_open(urdl::url("file://xyz"), open_handler); + + // close() + + stream1.close(); + want(stream1.close(ec)); + + // content_type() + + want(const_stream1.content_type()); + + // content_length() + + want(const_stream1.content_length()); + + // headers() + + want(const_stream1.headers()); + + // read_some() + + want(stream1.read_some(boost::asio::buffer(buffer))); + want(stream1.read_some(boost::asio::buffer(buffer), ec)); + + // async_read_some() + + stream1.async_read_some(boost::asio::buffer(buffer), read_handler); + } + catch (std::exception&) + { + } +} + +// Test synchronous HTTP. +void read_stream_synchronous_http_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 200 OK\r\n" + "Content-Length: 13\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Hello, World!"; + + server.start(request, 0, response, 0, content); + + boost::asio::io_service io_service; + urdl::read_stream stream1(io_service); + + stream1.open("http://localhost:" + port + "/"); + + std::string returned_content(stream1.content_length(), 0); + boost::asio::read(stream1, boost::asio::buffer( + &returned_content[0], returned_content.size())); + + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(stream1.content_type() == "text/plain"); + BOOST_CHECK(stream1.content_length() == 13); + BOOST_CHECK(returned_content == content); +} + +// Test synchronous HTTP with an error status returned by the server. +void read_stream_synchronous_http_not_found_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 404 Not Found\r\n" + "Content-Length: 9\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Not Found"; + + server.start(request, 0, response, 0, content); + + boost::asio::io_service io_service; + urdl::read_stream stream1(io_service); + + boost::system::error_code ec; + stream1.open("http://localhost:" + port + "/", ec); + + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(ec == urdl::http::errc::not_found); +} + +struct handler +{ + boost::system::error_code& ec_; + std::size_t& size_; + void operator()(const boost::system::error_code& ec, std::size_t size = 0) + { + ec_ = ec; + size_ = size; + } +}; + +// Test asynchronous HTTP. +void read_stream_asynchronous_http_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 200 OK\r\n" + "Content-Length: 13\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Hello, World!"; + + server.start(request, 0, response, 0, content); + + boost::asio::io_service io_service; + urdl::read_stream stream1(io_service); + + boost::system::error_code ec; + std::size_t bytes_transferred = 0; + handler h = { ec, bytes_transferred }; + + stream1.async_open("http://localhost:" + port + "/", h); + io_service.run(); + BOOST_CHECK(!ec); + + std::string returned_content(stream1.content_length(), 0); + boost::asio::async_read(stream1, boost::asio::buffer( + &returned_content[0], returned_content.size()), h); + io_service.reset(); + io_service.run(); + BOOST_CHECK(!ec); + BOOST_CHECK(bytes_transferred == returned_content.size()); + + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(stream1.content_type() == "text/plain"); + BOOST_CHECK(stream1.content_length() == 13); + BOOST_CHECK(returned_content == content); +} + +// Test asynchronous HTTP with an error status returned by the server. +void read_stream_asynchronous_http_not_found_test() +{ + http_server server; + std::string port = boost::lexical_cast(server.port()); + + std::string request = + "GET / HTTP/1.0\r\n" + "Host: localhost:" + port + "\r\n" + "Accept: */*\r\n" + "Connection: close\r\n\r\n"; + std::string response = + "HTTP/1.0 404 Not Found\r\n" + "Content-Length: 9\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "Not Found"; + + server.start(request, 0, response, 0, content); + + boost::asio::io_service io_service; + urdl::read_stream stream1(io_service); + + boost::system::error_code ec; + std::size_t bytes_transferred = 0; + handler h = { ec, bytes_transferred }; + + stream1.async_open("http://localhost:" + port + "/", h); + io_service.run(); + + bool request_matched = server.stop(); + + BOOST_CHECK(request_matched); + BOOST_CHECK(ec == urdl::http::errc::not_found); +} + +test_suite* init_unit_test_suite(int, char*[]) +{ + test_suite* test = BOOST_TEST_SUITE("read_stream"); + test->add(BOOST_TEST_CASE(&read_stream_compile_test)); + test->add(BOOST_TEST_CASE(&read_stream_synchronous_http_test)); + test->add(BOOST_TEST_CASE(&read_stream_synchronous_http_not_found_test)); + test->add(BOOST_TEST_CASE(&read_stream_asynchronous_http_test)); + test->add(BOOST_TEST_CASE(&read_stream_asynchronous_http_not_found_test)); + return test; +} diff --git a/windows/include/urdl/test/unit_test.hpp b/windows/include/urdl/test/unit_test.hpp new file mode 100644 index 000000000..6e098c4f1 --- /dev/null +++ b/windows/include/urdl/test/unit_test.hpp @@ -0,0 +1,39 @@ +// +// unit_test.hpp +// ~~~~~~~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef UNIT_TEST_HPP +#define UNIT_TEST_HPP + +#include + +#if defined(BOOST_MSVC) +# pragma warning (push) +# pragma warning (disable:4244) +# pragma warning (disable:4535) +# pragma warning (disable:4702) +# pragma warning (disable:4996) +#endif // defined(BOOST_MSVC) + +#include +#include +using boost::unit_test::test_suite; + +#if defined(BOOST_MSVC) +# pragma warning (pop) +# pragma warning (disable:4996) // Leave this disabled for the unit tests. +#endif // defined(BOOST_MSVC) + +// Helper function to check the return type of a function. +template +void want(const T&) +{ +} + +#endif // UNIT_TEST_HPP diff --git a/windows/include/urdl/test/url.cpp b/windows/include/urdl/test/url.cpp new file mode 100644 index 000000000..6cb407bf7 --- /dev/null +++ b/windows/include/urdl/test/url.cpp @@ -0,0 +1,311 @@ +// +// url.cpp +// ~~~~~~~ +// +// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "urdl/url.hpp" + +#include "unit_test.hpp" + +// Ensure all functions compile correctly. +void url_compile_test() +{ + // Constructors + + urdl::url url1; + urdl::url url2("http://foo/bar"); + urdl::url url3(std::string("http://foo/bar")); + urdl::url url4(url1); + urdl::url url5 = url1; + + // operator= + + url5 = url2; + + // protocol() + + const urdl::url& const_url1 = url1; + want(const_url1.protocol()); + + // user_info() + + want(const_url1.user_info()); + + // host() + + want(const_url1.host()); + + // port() + + want(const_url1.port()); + + // path() + + want(const_url1.path()); + + // query() + + want(const_url1.query()); + + // fragment() + + want(const_url1.fragment()); + + // to_string() + + want(const_url1.to_string()); + want(const_url1.to_string(urdl::url::protocol_component)); + want(const_url1.to_string(urdl::url::user_info_component)); + want(const_url1.to_string(urdl::url::host_component)); + want(const_url1.to_string(urdl::url::port_component)); + want(const_url1.to_string(urdl::url::path_component)); + want(const_url1.to_string(urdl::url::query_component)); + want(const_url1.to_string(urdl::url::fragment_component)); + want(const_url1.to_string(urdl::url::all_components)); + + // from_string() + + boost::system::error_code ec; + want(urdl::url::from_string("http://foo/bar")); + want(urdl::url::from_string("http://foo/bar", ec)); + want(urdl::url::from_string(std::string("http://foo/bar"))); + want(urdl::url::from_string(std::string("http://foo/bar"), ec)); + + // operator== + + const urdl::url& const_url2 = url2; + want(const_url1 == const_url2); + + // operator!= + + want(const_url1 != const_url2); + + // operator< + + want(const_url1 < const_url2); +} + +// Test URL parsing. +void url_from_string_test() +{ + boost::system::error_code ec; + + urdl::url url = urdl::url::from_string("http://host", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("HTTP://host", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host:123", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://user@host", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "user"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://user@host:123", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "user"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://user:pass@host", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "user:pass"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://user:pass@host:123", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "user:pass"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host/path", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host:123/path", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host?query", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host:123?query", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host/path?query", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == ""); + + url = urdl::url::from_string("http://host#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://host:123#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://host/path#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == ""); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://host?query#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://host/path?query#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 80); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://host:123/path?query#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == ""); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://user@host:123/path?query#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "user"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == "fragment"); + + url = urdl::url::from_string("http://u:p@host:123/path?query#fragment", ec); + BOOST_CHECK(!ec); + BOOST_CHECK(url.protocol() == "http"); + BOOST_CHECK(url.user_info() == "u:p"); + BOOST_CHECK(url.host() == "host"); + BOOST_CHECK(url.port() == 123); + BOOST_CHECK(url.path() == "/path"); + BOOST_CHECK(url.query() == "query"); + BOOST_CHECK(url.fragment() == "fragment"); +} + +test_suite* init_unit_test_suite(int, char*[]) +{ + test_suite* test = BOOST_TEST_SUITE("url"); + test->add(BOOST_TEST_CASE(&url_compile_test)); + test->add(BOOST_TEST_CASE(&url_from_string_test)); + return test; +} diff --git a/windows/lib/debug/libcurl.lib b/windows/lib/debug/libcurl.lib index 67f9f3958..90c5b2310 100644 Binary files a/windows/lib/debug/libcurl.lib and b/windows/lib/debug/libcurl.lib differ diff --git a/windows/lib/debug/libcurl.pdb b/windows/lib/debug/libcurl.pdb index 7188288b0..23bf781e3 100644 Binary files a/windows/lib/debug/libcurl.pdb and b/windows/lib/debug/libcurl.pdb differ diff --git a/windows/lib/release/libcurl.lib b/windows/lib/release/libcurl.lib index 9aaba967a..34e4b8eae 100644 Binary files a/windows/lib/release/libcurl.lib and b/windows/lib/release/libcurl.lib differ