From 95ec68eb38dcbf0ffb39fdcca781906b2b053511 Mon Sep 17 00:00:00 2001 From: cnagune Date: Thu, 21 May 2015 23:09:05 +0900 Subject: [PATCH 1/7] fix timeout testcase - change broken link --- libs/network/test/http/client_get_timeout_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index 9eb0103b9..2b6807903 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -25,8 +25,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) { BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client, client_types) { typename client::request request( - "http://cznic.dl.sourceforge.net/project/boost/boost/1.55.0/" - "boost_1_55_0.tar.bz2"); + "http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-desktop-amd64.iso"); typename client::response response; typename client::options options; client client_(options.timeout(1)); From be97dfedbeb000a9c85904dbf994786ca56cba72 Mon Sep 17 00:00:00 2001 From: cnagune Date: Thu, 13 Aug 2015 15:49:59 +0900 Subject: [PATCH 2/7] fix boost::network::uri::decode error - out of range because of '%' --- boost/network/uri/decode.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index e9e80e984..f261e991a 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -59,8 +59,14 @@ OutputIterator decode(const InputIterator &in_begin, while (it != in_end) { if (*it == '%') { ++it; + if (it == in_end) { + throw std::runtime_error("decoding fail because of '%'"); + } value_type v0 = detail::letter_to_hex(*it); ++it; + if (it == in_end) { + throw std::runtime_error("decoding fail because of '%'"); + } value_type v1 = detail::letter_to_hex(*it); ++it; *out++ = 0x10 * v0 + v1; From 66dd835bbb4a96488e411a0a60ccbbc283061bb7 Mon Sep 17 00:00:00 2001 From: cnagune Date: Thu, 13 Aug 2015 16:08:30 +0900 Subject: [PATCH 3/7] Revert "fix timeout testcase - change broken link" This reverts commit 95ec68eb38dcbf0ffb39fdcca781906b2b053511. --- libs/network/test/http/client_get_timeout_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/network/test/http/client_get_timeout_test.cpp b/libs/network/test/http/client_get_timeout_test.cpp index 2b6807903..9eb0103b9 100644 --- a/libs/network/test/http/client_get_timeout_test.cpp +++ b/libs/network/test/http/client_get_timeout_test.cpp @@ -25,7 +25,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) { BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client, client_types) { typename client::request request( - "http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-desktop-amd64.iso"); + "http://cznic.dl.sourceforge.net/project/boost/boost/1.55.0/" + "boost_1_55_0.tar.bz2"); typename client::response response; typename client::options options; client client_(options.timeout(1)); From 0a5e2fba05347fb1140e6fc6a4060188dc6163ba Mon Sep 17 00:00:00 2001 From: cnagune Date: Thu, 13 Aug 2015 17:26:36 +0900 Subject: [PATCH 4/7] fix boost::network::uri::decode error - add header --- boost/network/uri/decode.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index f261e991a..33579d456 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace network { From 4ab9e488e1e64334ca67d897d3ce326a63d32575 Mon Sep 17 00:00:00 2001 From: cnagune Date: Fri, 14 Aug 2015 16:03:59 +0900 Subject: [PATCH 5/7] add testcase for boost::network::uri::decode --- boost/network/uri/decode.hpp | 10 ++-------- libs/network/test/uri/uri_encoding_test.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index 33579d456..0fd350014 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -59,15 +59,9 @@ OutputIterator decode(const InputIterator &in_begin, OutputIterator out = out_begin; while (it != in_end) { if (*it == '%') { - ++it; - if (it == in_end) { - throw std::runtime_error("decoding fail because of '%'"); - } + if (++it == in_end) throw std::runtime_error("decoding fail because of '%'"); value_type v0 = detail::letter_to_hex(*it); - ++it; - if (it == in_end) { - throw std::runtime_error("decoding fail because of '%'"); - } + if (++it == in_end) throw std::runtime_error("decoding fail because of '%'"); value_type v1 = detail::letter_to_hex(*it); ++it; *out++ = 0x10 * v0 + v1; diff --git a/libs/network/test/uri/uri_encoding_test.cpp b/libs/network/test/uri/uri_encoding_test.cpp index aaff45dbf..2190e33b6 100644 --- a/libs/network/test/uri/uri_encoding_test.cpp +++ b/libs/network/test/uri/uri_encoding_test.cpp @@ -47,3 +47,10 @@ BOOST_AUTO_TEST_CASE(decoding_multibyte_test) { uri::decode(encoded, std::back_inserter(instance)); BOOST_CHECK_EQUAL(instance, unencoded); } + +BOOST_AUTO_TEST_CASE(decoding_throw_test) { + const std::string encoded("%"); + + std::string instance; + BOOST_CHECK_THROW(uri::decoded(encoded), std::runtime_error); +} From 99b9eb38e8ebc8edb80ff1c4abbaf35e8cfcd146 Mon Sep 17 00:00:00 2001 From: cnagune Date: Fri, 14 Aug 2015 16:20:50 +0900 Subject: [PATCH 6/7] rename exception: std::out_of_range --- boost/network/uri/decode.hpp | 4 ++-- libs/network/test/uri/uri_encoding_test.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index 0fd350014..0efc839e3 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -59,9 +59,9 @@ OutputIterator decode(const InputIterator &in_begin, OutputIterator out = out_begin; while (it != in_end) { if (*it == '%') { - if (++it == in_end) throw std::runtime_error("decoding fail because of '%'"); + if (++it == in_end) throw std::out_of_range("out_of_range exception"); value_type v0 = detail::letter_to_hex(*it); - if (++it == in_end) throw std::runtime_error("decoding fail because of '%'"); + if (++it == in_end) throw std::out_of_range("out_of_range exception"); value_type v1 = detail::letter_to_hex(*it); ++it; *out++ = 0x10 * v0 + v1; diff --git a/libs/network/test/uri/uri_encoding_test.cpp b/libs/network/test/uri/uri_encoding_test.cpp index 2190e33b6..2c2ddaaf6 100644 --- a/libs/network/test/uri/uri_encoding_test.cpp +++ b/libs/network/test/uri/uri_encoding_test.cpp @@ -52,5 +52,5 @@ BOOST_AUTO_TEST_CASE(decoding_throw_test) { const std::string encoded("%"); std::string instance; - BOOST_CHECK_THROW(uri::decoded(encoded), std::runtime_error); + BOOST_CHECK_THROW(uri::decoded(encoded), std::out_of_range); } From 8f5831fef7339ab202ee010bd186fb08a9a7810c Mon Sep 17 00:00:00 2001 From: cnagune Date: Fri, 14 Aug 2015 16:31:56 +0900 Subject: [PATCH 7/7] change std::out_of_range constractor string (what_arg) --- boost/network/uri/decode.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boost/network/uri/decode.hpp b/boost/network/uri/decode.hpp index 0efc839e3..7503d5665 100644 --- a/boost/network/uri/decode.hpp +++ b/boost/network/uri/decode.hpp @@ -59,9 +59,9 @@ OutputIterator decode(const InputIterator &in_begin, OutputIterator out = out_begin; while (it != in_end) { if (*it == '%') { - if (++it == in_end) throw std::out_of_range("out_of_range exception"); + if (++it == in_end) throw std::out_of_range("unexpected end of stream"); value_type v0 = detail::letter_to_hex(*it); - if (++it == in_end) throw std::out_of_range("out_of_range exception"); + if (++it == in_end) throw std::out_of_range("unexpected end of stream"); value_type v1 = detail::letter_to_hex(*it); ++it; *out++ = 0x10 * v0 + v1;