#include <string>
#include <sstream>
#include <iostream>
#include <boost/network/protocol/http/client.hpp>

namespace http = boost::network::http;

int main(int argc, char * argv[])
{
  if (argc != 3)
  {
    std::cerr << "Usage: " << argv[0] << " address port" << std::endl;
    return 1;
  }

  http::client client;
  try
  {
    std::ostringstream url;
    url << "http://" << argv[1] << ":" << argv[2] << "/";
    http::client::request request(url.str());
    request << boost::network::header("Connection", "close");

    http::client::response response = client.get(request);
    std::cout << "BODY: " << std::endl;
    std::cout << body(response) << std::endl;
    std::cout << "-------" << std::endl;
  }
  catch (std::exception & e)
  {
    std::cerr << e.what() << std::endl;
    return 1;
  }
  return 0;
}
