Skip to content

Instantly share code, notes, and snippets.

@daedric
Created April 16, 2014 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daedric/10866664 to your computer and use it in GitHub Desktop.
Save daedric/10866664 to your computer and use it in GitHub Desktop.
using HTTPP::HTTP::Connection;
using HTTPP::HTTP::Request;
void handler(Connection* connection, Request&& request)
{
static int i = 0;
if (i < 4)
{
++i;
Connection::releaseFromHandler(connection);
return;
}
connection->response()
.setCode(HTTPP::HTTP::HttpCode::MovedTemporarily)
.addHeader("Location", "http://localhost:4001" + request.uri);
connection->sendResponse();
}
BOOST_AUTO_TEST_CASE(etcd_failure)
{
HTTPP::HttpServer server;
server.start();
server.bind("localhost", "4002");
server.bind("localhost", "4003");
server.bind("localhost", "4004");
server.bind("localhost", "4005");
server.bind("localhost", "4006");
server.setSink(&handler);
etcd::Etcd etcd_client = { {
{ "localhost", 4002 },
{ "localhost", 4003 },
{ "localhost", 4004 },
{ "localhost", 4005 },
{ "localhost", 4006 },
},
"test" };
auto r = etcd_client.set("test", "test", std::chrono::seconds(1));
BOOST_CHECK(!r.isError());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment