|
| 1 | +// Copyright (c) Glyn Matthews 2011. |
| 2 | +// Distributed under the Boost Software License, Version 1.0. |
| 3 | +// (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +#define BOOST_TEST_MODULE HTTP URL Test |
| 9 | +#include <boost/config/warning_disable.hpp> |
| 10 | +#include <boost/test/unit_test.hpp> |
| 11 | +#include <boost/network/uri/http/uri.hpp> |
| 12 | +#include <boost/mpl/list.hpp> |
| 13 | +#include <boost/range/algorithm/equal.hpp> |
| 14 | + |
| 15 | +using namespace boost::network; |
| 16 | + |
| 17 | +typedef boost::mpl::list< |
| 18 | + tags::default_string |
| 19 | + , tags::default_wstring |
| 20 | + > tag_types; |
| 21 | + |
| 22 | + |
| 23 | +BOOST_AUTO_TEST_CASE_TEMPLATE(not_http, T, tag_types) |
| 24 | +{ |
| 25 | + typedef uri::http::basic_uri<T> uri_type; |
| 26 | + typedef typename uri_type::string_type string_type; |
| 27 | + const std::string url( "mailto:[email protected]"); |
| 28 | + uri_type instance(string_type(boost::begin(url), boost::end(url))); |
| 29 | + std::copy(instance.begin(), instance.end(), |
| 30 | + std::ostream_iterator<char>(std::cout)); |
| 31 | + std::cout << std::endl; |
| 32 | + //BOOST_CHECK(!uri::is_valid(instance)); |
| 33 | +} |
| 34 | + |
| 35 | +// BOOST_AUTO_TEST_CASE(http_url_test) { |
| 36 | +// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type; |
| 37 | +// typedef uri_type::string_type string_type; |
| 38 | +// |
| 39 | +// const std::string url(https://github.com/"http://www.boost.org/"); |
| 40 | +// const std::string scheme("http"); |
| 41 | +// const std::string host("www.boost.org"); |
| 42 | +// const std::string path("/"); |
| 43 | +// |
| 44 | +// uri_type instance(string_type(boost::begin(url), boost::end(url))); |
| 45 | +// boost::optional<string_type> host_ = uri::host(instance); |
| 46 | +// boost::optional<boost::uint16_t> port_ = uri::port(instance); |
| 47 | +// |
| 48 | +// BOOST_REQUIRE(uri::is_valid(instance)); |
| 49 | +// BOOST_CHECK_EQUAL(instance.raw(), url); |
| 50 | +// BOOST_CHECK( !port_ ); |
| 51 | +// string_type scheme_ = uri::scheme(instance); |
| 52 | +// BOOST_CHECK_EQUAL(scheme_, scheme); |
| 53 | +// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme)); |
| 54 | +// BOOST_CHECK(boost::equal(uri::host(instance), host)); |
| 55 | +// BOOST_CHECK(boost::equal(uri::path(instance), path)); |
| 56 | +// } |
| 57 | +// |
| 58 | +// BOOST_AUTO_TEST_CASE(full_http_url_test) { |
| 59 | +// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type; |
| 60 | +// typedef uri_type::string_type string_type; |
| 61 | +// |
| 62 | +// const std::string url(https://github.com/"http://user:%3Ca%20href=%22/service/https://github.com/cdn-cgi/l/email-protection%22%20class=%22__cf_email__%22%20data-cfemail=%228fffeefcfcf8e0fdebcff8f8f8a1ede0e0fcfba1e0fde8%22%3E[email protected]%3C/a%3E:8000/path?query#fragment"); |
| 63 | +// const std::string scheme("http"); |
| 64 | +// const std::string user_info("user:password"); |
| 65 | +// const std::string host("www.boost.org"); |
| 66 | +// const boost::uint16_t port = 8000; |
| 67 | +// const std::string path("/path"); |
| 68 | +// const std::string query("query"); |
| 69 | +// const std::string fragment("fragment"); |
| 70 | +// |
| 71 | +// uri_type instance(string_type(boost::begin(url), boost::end(url))); |
| 72 | +// BOOST_REQUIRE(uri::is_valid(instance)); |
| 73 | +// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme)); |
| 74 | +// BOOST_CHECK(boost::equal(uri::user_info(instance), user_info)); |
| 75 | +// BOOST_CHECK(boost::equal(uri::host(instance), host)); |
| 76 | +// BOOST_CHECK_EQUAL(uri::port(instance), port); |
| 77 | +// BOOST_CHECK(boost::equal(uri::path(instance), path)); |
| 78 | +// BOOST_CHECK(boost::equal(uri::query(instance), query)); |
| 79 | +// BOOST_CHECK(boost::equal(uri::fragment(instance), fragment)); |
| 80 | +// } |
| 81 | +// |
| 82 | +// BOOST_AUTO_TEST_CASE(https_url_test) { |
| 83 | +// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type; |
| 84 | +// typedef uri_type::string_type string_type; |
| 85 | +// |
| 86 | +// const std::string url(https://github.com/"https://www.boost.org/"); |
| 87 | +// const std::string scheme("https"); |
| 88 | +// const std::string host("www.boost.org"); |
| 89 | +// const boost::uint16_t port = 443; |
| 90 | +// const std::string path("/"); |
| 91 | +// |
| 92 | +// uri_type instance(string_type(boost::begin(url), boost::end(url))); |
| 93 | +// BOOST_REQUIRE(uri::is_valid(instance)); |
| 94 | +// BOOST_CHECK(boost::equal(uri::scheme(instance), scheme)); |
| 95 | +// BOOST_CHECK(boost::equal(uri::host(instance), host)); |
| 96 | +// BOOST_CHECK_EQUAL(uri::port(instance), port); |
| 97 | +// BOOST_CHECK(boost::equal(uri::path(instance), path)); |
| 98 | +// } |
| 99 | +// |
| 100 | +//BOOST_AUTO_TEST_CASE(invalid_http_url_test) { |
| 101 | +// typedef uri::basic_uri<http::tags::http_default_8bit_tcp_resolve> uri_type; |
| 102 | +// typedef uri_type::string_type string_type; |
| 103 | +// const std::string url(https://github.com/"ftp://www.boost.org/"); |
| 104 | +// uri_type instance(string_type(boost::begin(url), boost::end(url))); |
| 105 | +// BOOST_CHECK(!uri::is_valid(instance)); |
| 106 | +//} |
0 commit comments