summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-10-14 01:50:58 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-10-14 01:50:58 +0100
commitbb940bd846bf01ed28a19702b83c11057168ca63 (patch)
treea5916ddc25f0b65247dbc6d25d63e817a149a6ca
parentAdd test over createNew (diff)
downloadlibadhocutil-bb940bd846bf01ed28a19702b83c11057168ca63.tar.bz2
libadhocutil-bb940bd846bf01ed28a19702b83c11057168ca63.tar.xz
libadhocutil-bb940bd846bf01ed28a19702b83c11057168ca63.zip
Test HTTP request with custom header
-rw-r--r--libadhocutil/unittests/testCurl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libadhocutil/unittests/testCurl.cpp b/libadhocutil/unittests/testCurl.cpp
index 1a8a595..ba7cfcf 100644
--- a/libadhocutil/unittests/testCurl.cpp
+++ b/libadhocutil/unittests/testCurl.cpp
@@ -7,6 +7,7 @@
#include "curlStream.h"
#include "definedDirs.h"
#include "net.h"
+#include <boost/algorithm/string/predicate.hpp>
using namespace AdHoc::Net;
@@ -56,6 +57,23 @@ BOOST_AUTO_TEST_CASE( fetch_missing )
BOOST_REQUIRE_THROW(ch.perform(), AdHoc::Net::CurlException);
}
+BOOST_AUTO_TEST_CASE( fetch_http_stream )
+{
+ CurlStreamSource css("http://sys.randomdan.homeip.net/env.cgi");
+ css.appendHeader("X-POWERED-BY: mature-cheddar");
+ CurlStream curlstrm(css);
+ std::string tok;
+ int expected = 0;
+ while (!curlstrm.eof()) {
+ curlstrm >> tok;
+ if (boost::algorithm::starts_with(tok, "HTTP_X_POWERED_BY=")) {
+ expected += 1;
+ BOOST_REQUIRE_EQUAL("HTTP_X_POWERED_BY=mature-cheddar", tok);
+ }
+ }
+ BOOST_REQUIRE_EQUAL(1, expected);
+}
+
BOOST_AUTO_TEST_CASE( fetch_file_stream )
{
auto url = "file://" + rootDir.string() + "/testCurl.cpp";