From bb940bd846bf01ed28a19702b83c11057168ca63 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 14 Oct 2015 01:50:58 +0100 Subject: Test HTTP request with custom header --- libadhocutil/unittests/testCurl.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 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"; -- cgit v1.2.3