void run_test(std::string const& url, int size, int status, int connected
	, boost::optional<error_code> ec, proxy_settings const& ps)
{
	reset_globals();

	std::cerr << " ===== TESTING: " << url << " =====" << std::endl;

	std::cerr << " expecting: size: " << size
		<< " status: " << status
		<< " connected: " << connected
		<< " error: " << (ec?ec->message():"no error") << std::endl;

	boost::shared_ptr<http_connection> h(new http_connection(ios, cq
		, &::http_handler, true, &::http_connect_handler));
	h->get(url, seconds(1), 0, &ps);
	ios.reset();
	error_code e;
	ios.run(e);

	std::cerr << "connect_handler_called: " << connect_handler_called << std::endl;
	std::cerr << "handler_called: " << handler_called << std::endl;
	std::cerr << "status: " << http_status << std::endl;
	std::cerr << "size: " << data_size << std::endl;
	std::cerr << "error_code: " << g_error_code.message() << std::endl;
	TEST_CHECK(connect_handler_called == connected);
	TEST_CHECK(handler_called == 1);	
	TEST_CHECK(data_size == size || size == -1);
	TEST_CHECK(!ec || g_error_code == *ec);
	TEST_CHECK(http_status == status || status == -1);
}
void run_test(std::string const& url, int size, int status, int connected
	, boost::optional<error_code> ec, aux::proxy_settings const& ps
	, std::string const& auth = std::string())
{
	reset_globals();

	std::cerr << " ===== TESTING: " << url << " =====" << std::endl;

	std::cerr << time_now_string()
		<< " expecting: size: " << size
		<< " status: " << status
		<< " connected: " << connected
		<< " error: " << (ec?ec->message():"no error") << std::endl;

	boost::shared_ptr<http_connection> h(new http_connection(ios
		, res, &::http_handler, true, 1024*1024, &::http_connect_handler));
	h->get(url, seconds(1), 0, &ps, 5, "test/user-agent", address_v4::any()
		, 0, auth);
	ios.reset();
	error_code e;
	ios.run(e);
	if (e) std::cerr << time_now_string() << " run failed: " << e.message() << std::endl;

	std::cerr << time_now_string() << " connect_handler_called: " << connect_handler_called << std::endl;
	std::cerr << time_now_string() << " handler_called: " << handler_called << std::endl;
	std::cerr << time_now_string() << " status: " << http_status << std::endl;
	std::cerr << time_now_string() << " size: " << data_size << std::endl;
	std::cerr << time_now_string() << " expected-size: " << size << std::endl;
	std::cerr << time_now_string() << " error_code: " << g_error_code.message() << std::endl;
	TEST_CHECK(connect_handler_called == connected);
	TEST_CHECK(handler_called == 1);
	TEST_CHECK(data_size == size || size == -1);
	TEST_CHECK(!ec || g_error_code == *ec);
	TEST_CHECK(http_status == status || status == -1);
}
Beispiel #3
0
void toy_ca_t::async_on_serv_error(boost::optional<boost::system::error_code const&> const& error, boost::optional<std::string const&> const& srt_msg){
	std::string msg("[serv]");
	if(error){
		msg.append("[").append(error->message()).append("]");
	}
	if(srt_msg){
		msg.append("[").append(*srt_msg).append("]");
	}

	post_log_message_(msg);

}